Add more verbose output to bsdtar to help root cause 'ImportExportStdout' test failures (#13555)

Blue committed Oct 3, 2025 at 17:37 UTC d4e64b658fb9b7f489bf7edcd7a851d0be12b56b
3 files changed +15 -6
src/linux/init/main.cpp
+10 -4
@@ -857,10 +857,10 @@ Return Value:
857
858 if (WI_IsFlagSet(Flags, LxMiniInitMessageFlagVerbose))
859 {
860 - compressionArguments += "v";
860 + compressionArguments += "vv";
861 }
862
863 - const char* arguments[] = {
863 + std::vector<const char*> arguments{
864 BSDTAR_PATH,
865 "-C",
866 Source,
@@ -872,7 +872,13 @@ Return Value:
872 "-",
873 ".",
874 nullptr};
875 - execv(BSDTAR_PATH, const_cast<char**>(arguments));
875 +
876 + if (WI_IsFlagSet(Flags, LxMiniInitMessageFlagVerbose))
877 + {
878 + arguments.emplace(arguments.begin() + 3, "--totals");
879 + }
880 +
881 + execv(BSDTAR_PATH, const_cast<char**>(arguments.data()));
882 LOG_ERROR("execl failed, {}", errno);
883 });
884
@@ -1158,7 +1164,7 @@ Return Value:
1164 "-C",
1165 Destination,
1166 "-x",
1161 - WI_IsFlagSet(Flags, LxMiniInitMessageFlagVerbose) ? "-vp" : "-p",
1167 + WI_IsFlagSet(Flags, LxMiniInitMessageFlagVerbose) ? "-vvp" : "-p",
1168 "--xattrs",
1169 "--numeric-owner",
1170 "-f",
src/windows/service/exe/LxssUserSession.cpp
+2 -2
@@ -1926,7 +1926,7 @@ HRESULT LxssUserSessionImpl::SetVersion(_In_ LPCGUID DistroGuid, _In_ ULONG Vers
1926
1927 if (m_utilityVm->GetConfig().SetVersionDebug)
1928 {
1929 - commandLine += " -v";
1929 + commandLine += " -vv --totals";
1930 }
1931
1932 // Run the bsdtar elf binary expand the tar file using the socket as stdin.
@@ -1991,7 +1991,7 @@ HRESULT LxssUserSessionImpl::SetVersion(_In_ LPCGUID DistroGuid, _In_ ULONG Vers
1991
1992 if (m_utilityVm->GetConfig().SetVersionDebug)
1993 {
1994 - commandLine += " -v";
1994 + commandLine += " -vv --totals";
1995 }
1996
1997 // Run the bsdtar elf binary to create the tar file using the socket as stdout.
test/windows/UnitTests.cpp
+3
@@ -6080,6 +6080,9 @@ Error code: Wsl/InstallDistro/WSL_E_INVALID_JSON\r\n",
6080 auto cleanup =
6081 wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() { LxsstuLaunchWsl(std::format(L"--unregister {}", test_distro)); });
6082
6083 + // The below logline makes it easier to find the bsdtar output when debugging this test case.
6084 + fprintf(stderr, "Starting ImportExportStdout test case\n");
6085 +
6086 auto commandLine = std::format(L"cmd.exe /c wsl --export {} - | wsl --import {} . -", LXSS_DISTRO_NAME_TEST_L, test_distro);
6087
6088 VERIFY_ARE_EQUAL(LxsstuRunCommand(commandLine.data()), 0L);