Skip to content

Commit

Permalink
test: add integration test that uses mmap
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed May 30, 2024
1 parent d2b8de2 commit bd44242
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
29 changes: 29 additions & 0 deletions test/libsqsh/integration.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,4 +667,33 @@ UTEST(integration, test_easy_traversal) {
ASSERT_EQ(0, rv);
}

UTEST(integration, mmap) {
int rv;
struct SqshArchive sqsh = {0};
struct SqshFile *file = NULL;
char **traversal = NULL;

struct SqshConfig config = {
.source_mapper = sqsh_mapper_impl_mmap,
.archive_offset = 1010,
};
rv = sqsh__archive_init(&sqsh, (char *)INTEGRATION_PATH, &config);
ASSERT_EQ(0, rv);

traversal = sqsh_easy_tree_traversal(&sqsh, "/", &rv);
ASSERT_EQ(0, rv);

ASSERT_STREQ("a", traversal[0]);
ASSERT_STREQ("b", traversal[1]);
ASSERT_STREQ("large_dir", traversal[2]);
ASSERT_STREQ("large_dir/1", traversal[3]);
ASSERT_STREQ("large_dir/10", traversal[4]);

free(traversal);
rv = sqsh_close(file);

rv = sqsh__archive_cleanup(&sqsh);
ASSERT_EQ(0, rv);
}

UTEST_MAIN()
7 changes: 5 additions & 2 deletions test/libsqsh/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ foreach p : sqsh_test
if sqsh_extra_source.has_key(p)
sources += sqsh_extra_source[p]
endif
this_c_args = ['-Wno-deprecated-declarations']
this_c_args = [
'-Wno-deprecated-declarations',
'-DINTEGRATION_PATH="' + squashfs.full_path() + '"',
]
this_c_args += test_c_args
this_cpp_args = []
this_cpp_args += test_cpp_args
Expand All @@ -101,5 +104,5 @@ foreach p : sqsh_test
link_with: [libsqsh.get_static_lib(), libmksqsh.get_static_lib()],
dependencies: [threads_dep, utest_dep, cextras_dep],
)
test(p, t)
test(p, t, env: {})
endforeach

0 comments on commit bd44242

Please sign in to comment.