Skip to content

Commit

Permalink
tests: switch to cextras testlib
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed Jul 31, 2023
1 parent 8f3aa41 commit 104d286
Show file tree
Hide file tree
Showing 26 changed files with 177 additions and 290 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ meson_benchmark_setup.dat
meson_test_setup.dat
sanitycheckcpp.cc # C++ specific
sanitycheckcpp.exe # C++ specific
subprojects

# Ninja
build.ninja
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ $(BUILD_DIR): meson.build Makefile
.PHONY: clean

clean:
rm -rf "$(BUILD_DIR)" subprojects
rm -rf "$(BUILD_DIR)"
8 changes: 8 additions & 0 deletions subprojects/cextras.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[wrap-git]
url=https://github.com/Gottox/cextras.git
revision=main
depth=1

[provide]
cextras=cextras_dep
testlib=testlib_dep
2 changes: 2 additions & 0 deletions test/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include "../include/sqsh_archive.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>

/*
* _______________ __ byte 0
Expand Down
10 changes: 4 additions & 6 deletions test/cpp-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@
# error "This file is C++ only"
#endif

extern "C" {
#include "common.h"
#include "test.h"
}
#include <testlib.h>
#include <sqsh_archive.h>
#include <sqsh_directory.h>
#include <sqsh_error.h>
Expand All @@ -58,6 +56,6 @@ sqsh_empty() {
assert(archive == NULL);
}

DEFINE
TEST(sqsh_empty);
DEFINE_END
DECLARE_TESTS
TEST(sqsh_empty)
END_TESTS
8 changes: 4 additions & 4 deletions test/directory/directory_iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

#include "../common.h"
#include "../test.h"
#include <testlib.h>

#include "../../include/sqsh_archive_private.h"
#include "../../include/sqsh_data_private.h"
Expand Down Expand Up @@ -100,6 +100,6 @@ iter_two_files(void) {
sqsh__archive_cleanup(&archive);
}

DEFINE
TEST(iter_two_files);
DEFINE_END
DECLARE_TESTS
TEST(iter_two_files)
END_TESTS
29 changes: 14 additions & 15 deletions test/extract/extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@

/**
* @author Enno Boland (mail@eboland.de)
* @file buffer.c
* @file extract.c
*/

#include "../common.h"
#include "../test.h"

#include <testlib.h>
#include "../../include/sqsh_extract_private.h"
#include <stdint.h>

Expand Down Expand Up @@ -186,15 +185,15 @@ decompress_zstd_split(void) {
decompress_test_split(sqsh__impl_zstd, input, sizeof(input));
}

DEFINE
TEST(decompress_lzma);
TEST_OFF(decompress_lzma_split);
TEST(decompress_xz);
TEST(decompress_xz_split);
TEST(decompress_lz4);
TEST_OFF(decompress_lz4_split);
TEST(decompress_zlib);
TEST(decompress_zlib_split);
TEST(decompress_zstd);
TEST(decompress_zstd_split);
DEFINE_END
DECLARE_TESTS
TEST(decompress_lzma)
NO_TEST(decompress_lzma_split)
TEST(decompress_xz)
TEST(decompress_xz_split)
TEST(decompress_lz4)
NO_TEST(decompress_lz4_split)
TEST(decompress_zlib)
TEST(decompress_zlib_split)
TEST(decompress_zstd)
TEST(decompress_zstd_split)
END_TESTS
10 changes: 5 additions & 5 deletions test/extract/extract_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

#include "../common.h"
#include "../test.h"
#include <testlib.h>

#include "../../include/sqsh_archive_private.h"
#include "../../include/sqsh_data_private.h"
Expand Down Expand Up @@ -114,7 +114,7 @@ decompress_and_cached(void) {
sqsh__archive_cleanup(&archive);
}

DEFINE
TEST(decompress);
TEST(decompress_and_cached);
DEFINE_END
DECLARE_TESTS
TEST(decompress)
TEST(decompress_and_cached)
END_TESTS
16 changes: 8 additions & 8 deletions test/file/file_iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

#include "../common.h"
#include "../test.h"
#include <testlib.h>

#include "../../include/sqsh_archive_private.h"
#include "../../include/sqsh_data_private.h"
Expand Down Expand Up @@ -359,10 +359,10 @@ load_zero_big_padding(void) {
sqsh__archive_cleanup(&archive);
}

DEFINE
TEST(load_two_segments_from_uncompressed_data_block);
TEST(load_segment_from_uncompressed_data_block);
TEST(load_segment_from_compressed_data_block);
TEST(load_zero_padding);
TEST(load_zero_big_padding);
DEFINE_END
DECLARE_TESTS
TEST(load_two_segments_from_uncompressed_data_block)
TEST(load_segment_from_uncompressed_data_block)
TEST(load_segment_from_compressed_data_block)
TEST(load_zero_padding)
TEST(load_zero_big_padding)
END_TESTS
12 changes: 6 additions & 6 deletions test/file/file_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

#include "../common.h"
#include "../test.h"
#include <testlib.h>

#include "../../include/sqsh_archive_private.h"
#include "../../include/sqsh_data_private.h"
Expand Down Expand Up @@ -177,8 +177,8 @@ load_file_from_uncompressed_data_block(void) {
sqsh__archive_cleanup(&archive);
}

DEFINE
TEST(load_file_from_uncompressed_data_block);
TEST(load_file_from_compressed_data_block);
TEST(load_file_from_compressed_data_block_with_offset);
DEFINE_END
DECLARE_TESTS
TEST(load_file_from_uncompressed_data_block)
TEST(load_file_from_compressed_data_block)
TEST(load_file_from_compressed_data_block_with_offset)
END_TESTS
42 changes: 21 additions & 21 deletions test/fuzzer_repro.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include "common.h"
#include "sqsh_tree.h"
#include "test.h"
#include <testlib.h>
#include <pthread.h>
#include <sqsh_archive_private.h>
#include <sqsh_chrome.h>
Expand Down Expand Up @@ -902,23 +902,23 @@ fuzz_oom_1(void) {
sqsh_archive_free(archive);
}

DEFINE
TEST_OFF(fuzz_crash_1); // Fails since the library sets up tables
TEST_OFF(fuzz_crash_2); // Fails since the library sets up tables
TEST_OFF(fuzz_crash_3); // Fails since the library sets up tables
TEST_OFF(fuzz_crash_4);
TEST_OFF(fuzz_crash_5);
TEST_OFF(fuzz_crash_6);
TEST_OFF(fuzz_crash_7);
TEST(fuzz_crash_8);
TEST(fuzz_crash_9);
TEST(fuzz_crash_10);
TEST(fuzz_crash_11);
TEST(fuzz_crash_12);
TEST(fuzz_crash_13);
TEST(fuzz_crash_14);
TEST(fuzz_crash_15);
TEST(fuzz_crash_16);
TEST(fuzz_crash_17);
TEST(fuzz_oom_1);
DEFINE_END
DECLARE_TESTS
NO_TEST(fuzz_crash_1) // Fails since the library sets up tables
NO_TEST(fuzz_crash_2) // Fails since the library sets up tables
NO_TEST(fuzz_crash_3) // Fails since the library sets up tables
NO_TEST(fuzz_crash_4)
NO_TEST(fuzz_crash_5)
NO_TEST(fuzz_crash_6)
NO_TEST(fuzz_crash_7)
TEST(fuzz_crash_8)
TEST(fuzz_crash_9)
TEST(fuzz_crash_10)
TEST(fuzz_crash_11)
TEST(fuzz_crash_12)
TEST(fuzz_crash_13)
TEST(fuzz_crash_14)
TEST(fuzz_crash_15)
TEST(fuzz_crash_16)
TEST(fuzz_crash_17)
TEST(fuzz_oom_1)
END_TESTS
8 changes: 4 additions & 4 deletions test/inode/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

#include "../common.h"
#include "../test.h"
#include <testlib.h>

#include "../../include/sqsh_archive_private.h"
#include "../../include/sqsh_data_private.h"
Expand Down Expand Up @@ -76,6 +76,6 @@ load_inode(void) {
sqsh__archive_cleanup(&archive);
}

DEFINE
TEST(load_inode);
DEFINE_END
DECLARE_TESTS
TEST(load_inode)
END_TESTS
28 changes: 14 additions & 14 deletions test/integration.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include "common.h"
#include "sqsh_tree.h"
#include "test.h"
#include <testlib.h>
#include <pthread.h>
#include <sqsh_archive_private.h>
#include <sqsh_chrome.h>
Expand Down Expand Up @@ -565,17 +565,17 @@ multithreaded(void) {
assert(rv == 0);
}

DEFINE
TEST(sqsh_empty);
TEST(sqsh_ls);
TEST(tree_walker);
TEST(sqsh_get_nonexistant);
TEST(sqsh_read_content);
TEST(sqsh_cat_fragment);
TEST(sqsh_cat_datablock_and_fragment);
TEST(sqsh_cat_size_overflow);
TEST(sqsh_test_uid_and_gid);
TEST(sqsh_test_extended_dir);
DECLARE_TESTS
TEST(sqsh_empty)
TEST(sqsh_ls)
TEST(tree_walker)
TEST(sqsh_get_nonexistant)
TEST(sqsh_read_content)
TEST(sqsh_cat_fragment)
TEST(sqsh_cat_datablock_and_fragment)
TEST(sqsh_cat_size_overflow)
TEST(sqsh_test_uid_and_gid)
TEST(sqsh_test_extended_dir)
// TEST(sqsh_test_xattr);
TEST(multithreaded);
DEFINE_END
TEST(multithreaded)
END_TESTS
16 changes: 8 additions & 8 deletions test/mapper/map_iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

#include "../common.h"
#include "../test.h"
#include <testlib.h>

#include <sqsh_mapper_private.h>
#include <stdint.h>
Expand Down Expand Up @@ -168,10 +168,10 @@ map_iterator_out_of_bounds_outside_blocksize(void) {
sqsh__map_manager_cleanup(&mapper);
}

DEFINE
TEST(init_cursor);
TEST(next_once);
TEST(next_twice);
TEST(map_iterator_out_of_bounds_inside_blocksize);
TEST(map_iterator_out_of_bounds_outside_blocksize);
DEFINE_END
DECLARE_TESTS
TEST(init_cursor)
TEST(next_once)
TEST(next_twice)
TEST(map_iterator_out_of_bounds_inside_blocksize)
TEST(map_iterator_out_of_bounds_outside_blocksize)
END_TESTS
24 changes: 12 additions & 12 deletions test/mapper/map_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

#include "../common.h"
#include "../test.h"
#include <testlib.h>

#include <sqsh_mapper_private.h>
#include <stdint.h>
Expand Down Expand Up @@ -295,14 +295,14 @@ error_2(void) {
sqsh__map_manager_cleanup(&mapper);
}

DEFINE
TEST(init_cursor);
TEST(advance_once);
TEST(advance_once_with_offset);
TEST(advance_twice_with_offset);
TEST(initial_advance);
TEST(advance_to_out_of_bounds);
TEST(initial_advance_2);
TEST(error_1);
TEST(error_2);
DEFINE_END
DECLARE_TESTS
TEST(init_cursor)
TEST(advance_once)
TEST(advance_once_with_offset)
TEST(advance_twice_with_offset)
TEST(initial_advance)
TEST(advance_to_out_of_bounds)
TEST(initial_advance_2)
TEST(error_1)
TEST(error_2)
END_TESTS
3 changes: 2 additions & 1 deletion test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ read_chunk = executable(
dependencies: libsqsh_dep,
)

testlib_dep = subproject('cextras').get_variable('testlib_dep')
foreach p : sqsh_test
sources = [p, sqsh_test_util]
if sqsh_extra_source.has_key(p)
Expand All @@ -101,7 +102,7 @@ foreach p : sqsh_test
sources,
install: false,
c_args: this_c_args,
dependencies: [libsqsh_dep, threads_dep],
dependencies: [libsqsh_dep, threads_dep, testlib_dep],
)
test(p, t)
endforeach
Expand Down
Loading

0 comments on commit 104d286

Please sign in to comment.