Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloudtest/TestGroup.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
</Setup>

<TestJob Name="CloudTest.Taef" TimeoutMins="240">
<Execution Type="TAEF" Path="[WorkingDirectory]\wsltests.dll" Args="/p:bugReportDirectory=[LoggingDirectory]\BugReportOutput /errorOnCrash /testmode:etwlogger /EtwLogger:WPRProfileFile=[WorkingDirectory]\wsl.wprp /EtwLogger:WPRProfile=WSL /EtwLogger:SavePoint=ExecutionComplete /EtwLogger:RecordingScope=Execution /p:SetupScript=.\test-setup.ps1 /p:Package=[WorkingDirectory]\Microsoft.WSL_${PACKAGE_VERSION}_x64_ARM64.msixbundle /p:Version=${version} /p:AllowUnsigned=${ALLOW_UNSIGNED_PACKAGE} /p:UnitTestsPath=[WorkingDirectory]\unit_tests /p:DistroPath=[WorkingDirectory]\test_distro.tar.xz /p:DistroName=test_distro /logOutput:High /p:RedirectStdout=[LoggingDirectory]\stdout.txt /p:RedirectStderr=[LoggingDirectory]\stderr.txt /p:KernelLogs=[LoggingDirectory]\dmesg.txt /p:DumpFolder=[LoggingDirectory] /p:WerReport /p:LogDmesg /p:PipelineBuildId=${PIPELINE_BUILD_ID} /p:DumpTool=DumpTool.exe" />
<Execution Type="TAEF" Path="[WorkingDirectory]\wsltests.dll" Args="/p:bugReportDirectory=[LoggingDirectory]\BugReportOutput /errorOnCrash /testmode:etwlogger /EtwLogger:WPRProfileFile=[WorkingDirectory]\wsl.wprp /EtwLogger:WPRProfile=WSL /EtwLogger:SavePoint=ExecutionComplete /EtwLogger:RecordingScope=Execution /p:SetupScript=.\test-setup.ps1 /p:Package=[WorkingDirectory]\Microsoft.WSL_${PACKAGE_VERSION}_x64_ARM64.msixbundle /p:Version=${version} /p:AllowUnsigned=${ALLOW_UNSIGNED_PACKAGE} /p:UnitTestsPath=[WorkingDirectory]\unit_tests /p:DistroPath=[WorkingDirectory]\test_distro.tar.xz /p:DistroName=test_distro /logOutput:High /p:RedirectStdout=[LoggingDirectory]\stdout.txt /p:RedirectStderr=[LoggingDirectory]\stderr.txt /p:KernelLogs=[LoggingDirectory]\dmesg.txt /p:DumpFolder=[LoggingDirectory] /p:WerReport /p:LogDmesg /p:PipelineBuildId=${PIPELINE_BUILD_ID} /p:DumpTool=DumpTool.exe /p:CollectCrashDumps=true" />
</TestJob>
</TestJobGroup>
2 changes: 2 additions & 0 deletions src/windows/common/WslClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,8 @@ int RunDebugShell()

int WslMain(_In_ std::wstring_view commandLine)
{
__fastfail(1);

// Call the MSI package if we're in an MSIX context
if (wsl::windows::common::wslutil::IsRunningInMsix())
{
Expand Down
37 changes: 36 additions & 1 deletion test/windows/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ static bool g_enableWerReport = false;
static std::wstring g_pipelineBuildId;
std::wstring g_testDistroPath;

static std::vector<RegistryKeyChange<std::wstring>> g_registryChangesSz;
static std::vector<RegistryKeyChange<DWORD>> g_registryChangesDword;

std::pair<wil::unique_handle, wil::unique_handle> CreateSubprocessPipe(bool inheritRead, bool inheritWrite, DWORD bufferSize, _In_opt_ SECURITY_ATTRIBUTES* sa)
{
wil::unique_handle read;
Expand Down Expand Up @@ -1997,7 +2000,7 @@ Return Value:
g_OriginalStderr = LxssRedirectOutput(STD_ERROR_HANDLE, redirectStderr.value());
}

g_dumpFolder = getOptionalTestParam(L"DumpFolder").value_or(L".");
g_dumpFolder = std::filesystem::weakly_canonical(getOptionalTestParam(L"DumpFolder").value_or(L".")).wstring();
g_dumpToolPath = getOptionalTestParam(L"DumpTool");
g_pipelineBuildId = getOptionalTestParam(L"PipelineBuildId").value_or(L"");

Expand All @@ -2007,6 +2010,38 @@ Return Value:
}

WEX::TestExecution::RuntimeParameters::TryGetValue(L"WerReport", g_enableWerReport);

bool enableCrashDumpCollection = false;
WEX::TestExecution::RuntimeParameters::TryGetValue(L"CollectCrashDumps", enableCrashDumpCollection);

if (enableCrashDumpCollection)
{
LogInfo("Enabling crash dump collection. Target: %ls", g_dumpFolder.c_str());
auto key = L"SOFTWARE\\Microsoft\\Windows\\Windows Error Reporting\\LocalDumps";
g_registryChangesSz.emplace_back(RegistryKeyChange<std::wstring>(HKEY_LOCAL_MACHINE, key, L"DumpFolder", g_dumpFolder));
g_registryChangesDword.emplace_back(RegistryKeyChange<DWORD>(HKEY_LOCAL_MACHINE, key, L"DumpType", 2));
g_registryChangesDword.emplace_back(RegistryKeyChange<DWORD>(HKEY_LOCAL_MACHINE, key, L"DumpCount", 10));
g_registryChangesDword.emplace_back(RegistryKeyChange<DWORD>(HKEY_LOCAL_MACHINE, key, L"Disabled", 0));
g_registryChangesDword.emplace_back(RegistryKeyChange<DWORD>(HKEY_LOCAL_MACHINE, key, L"ForceQueue", 1));
g_registryChangesDword.emplace_back(RegistryKeyChange<DWORD>(HKEY_LOCAL_MACHINE, key, L"DebugApplications", 0));

for (auto flags : {KEY_WOW64_32KEY, KEY_WOW64_64KEY})
{
auto currentVersion = wsl::windows::common::registry::OpenKey(
HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", KEY_ALL_ACCESS | flags);

auto result = wsl::windows::common::registry::DeleteKey(currentVersion.get(), L"AeDebug");

LogInfo("AeDebug deletion result (flags %lu): %lu", flags, result);
}

auto cmd = std::format(L"icacls \"{}\" /grant \"Everyone:(OI)(CI)F\"", g_dumpFolder);

LxsstuLaunchCommandAndCaptureOutput(cmd.data());
}

auto wait = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [&]() { std::this_thread::sleep_for(std::chrono::seconds(300)); });

WEX::TestExecution::RuntimeParameters::TryGetValue(L"LogDmesg", g_LogDmesgAfterEachTest);

g_WatchdogTimer = CreateThreadpoolTimer(LxsstuWatchdogTimer, nullptr, nullptr);
Expand Down
2 changes: 2 additions & 0 deletions test/windows/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ template <typename T>
class RegistryKeyChange
{
public:
RegistryKeyChange() = default;

RegistryKeyChange(HKEY Hive, LPCWSTR Key, LPCWSTR Name, const T& Value) : m_value(Name)
{
m_key = wsl::windows::common::registry::CreateKey(Hive, Key, KEY_ALL_ACCESS);
Expand Down
Loading