From 2aa96dfa3fa1b11f03a4eacd8610231af95d09d9 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Mon, 1 Jan 2024 23:33:55 +0100 Subject: [PATCH] test: more tools tests --- test/tools_test.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/tools_test.cpp b/test/tools_test.cpp index 207ca554..e72a08d3 100644 --- a/test/tools_test.cpp +++ b/test/tools_test.cpp @@ -42,6 +42,7 @@ #endif #include +#include #include #include @@ -648,6 +649,7 @@ TEST_P(tools_test, end_to_end) { auto universal_symlink_mkdwarfs_bin = td / "mkdwarfs" EXE_EXT; auto universal_symlink_dwarfsck_bin = td / "dwarfsck" EXE_EXT; auto universal_symlink_dwarfsextract_bin = td / "dwarfsextract" EXE_EXT; + std::vector dwarfs_tool_arg; std::vector mkdwarfs_tool_arg; std::vector dwarfsck_tool_arg; std::vector dwarfsextract_tool_arg; @@ -666,6 +668,7 @@ TEST_P(tools_test, end_to_end) { mkdwarfs_test_bin = &universal_bin; dwarfsck_test_bin = &universal_bin; dwarfsextract_test_bin = &universal_bin; + dwarfs_tool_arg.push_back("--tool=dwarfs"); mkdwarfs_tool_arg.push_back("--tool=mkdwarfs"); dwarfsck_tool_arg.push_back("--tool=dwarfsck"); dwarfsextract_tool_arg.push_back("--tool=dwarfsextract"); @@ -773,6 +776,18 @@ TEST_P(tools_test, end_to_end) { for (auto const& driver : drivers) { { +#if defined(__has_feature) +#if __has_feature(address_sanitizer) + ::setenv("ASAN_OPTIONS", "detect_leaks=0", 1); + SCOPE_EXIT { ::unsetenv("ASAN_OPTIONS"); }; +#endif +#endif + auto const [out, err, ec] = + subprocess::run(driver, dwarfs_tool_arg, "--help"); + EXPECT_THAT(out, ::testing::HasSubstr("Usage:")); + } + + { driver_runner runner(driver_runner::foreground, driver, mode == binary_mode::universal_tool, image, mountpoint); @@ -1173,6 +1188,14 @@ TEST_P(tools_test, mutating_and_error_ops) { EXPECT_EC_UNIX_WIN(ec, ENOTDIR, ERROR_DIRECTORY); } + // try open non-existing symlink + + { + std::error_code ec; + auto tmp = fs::read_symlink(mountpoint / "doesnotexist", ec); + EXPECT_EC_UNIX_WIN(ec, ENOENT, ERROR_FILE_NOT_FOUND); + } + EXPECT_TRUE(runner.unmount()) << runner.cmdline(); } }