From be30c49a40c485b430455fe3bd5f0aa82cda3281 Mon Sep 17 00:00:00 2001 From: Shankar Seal <74580197+shankarseal@users.noreply.github.com> Date: Fri, 8 Jul 2022 16:42:58 -0700 Subject: [PATCH] Tracing for troubleshooting. (#1270) * Tracing for troubleshooting. * fixes. --- docs/SelfHostedRunnerSetup.md | 7 +++++-- scripts/config_test_vm.psm1 | 2 +- scripts/run_driver_tests.psm1 | 16 +++++++++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/docs/SelfHostedRunnerSetup.md b/docs/SelfHostedRunnerSetup.md index 9bf84831f..4d127615d 100644 --- a/docs/SelfHostedRunnerSetup.md +++ b/docs/SelfHostedRunnerSetup.md @@ -32,5 +32,8 @@ This document discusses the steps to set up such a selfhosted actions-runner tha 9) Store the VM administrator credential: 1) `Install-Module CredentialManager -force` 2) `New-StoredCredential -Target `**`TEST_VM`**` -Username -Password -Persist LocalMachine` -10) Set up Windows Error Reporting [Local Dump Collection](https://docs.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps). -11) Reboot the runner. +10) Set up Windows Error Reporting [Local Dump Collection](https://docs.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps) on the VMs with the following commands. + ```New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -ErrorAction SilentlyContinue``` + ```New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value 2 -PropertyType DWord -ErrorAction SilentlyContinue``` + ```New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "c:\dumps" -PropertyType ExpandString -ErrorAction SilentlyContinue -Force``` +12) Reboot the runner. diff --git a/scripts/config_test_vm.psm1 b/scripts/config_test_vm.psm1 index b47d72228..1fcd6fb48 100644 --- a/scripts/config_test_vm.psm1 +++ b/scripts/config_test_vm.psm1 @@ -243,7 +243,7 @@ function Import-ResultsFromVM Copy-Item -FromSession $VMSession "$VMSystemDrive\KernelDumps" -Destination ".\TestLogs\$VMName" -Recurse -Force -ErrorAction Ignore 2>&1 | Write-Log # Copy user mode crash dumps if any. - Copy-Item -FromSession $VMSession "$VMSystemDrive\dumps\x64" -Destination ".\TestLogs\$VMName" -Recurse -Force -ErrorAction Ignore 2>&1 | Write-Log + Copy-Item -FromSession $VMSession "$VMSystemDrive\dumps" -Destination ".\TestLogs\$VMName" -Recurse -Force -ErrorAction Ignore 2>&1 | Write-Log # Copy logs from Test VM. if (!(Test-Path ".\TestLogs\$VMName\Logs")) { diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index 4ad52ec16..aa7e6a8fd 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -59,7 +59,6 @@ function Invoke-Test $ArgumentsList = @() if ($Coverage) { - $Env:EBPF_ENABLE_WER_REPORT="yes" $ArgumentsList += @('-q', '--modules=C:\eBPF', '--export_type', ('binary:' + $TestName + '.cov'), '--', $TestName) $TestName = $CodeCoverage } @@ -71,11 +70,22 @@ function Invoke-Test Write-Log "$TestName $ArgumentsList" $Output = &$TestName $ArgumentsList $TestName = $OriginalTestName + if ($LASTEXITCODE -ne 0) { + throw ("$TestName Failed with $LASTEXITCODE.") + } - # Check for errors. + # Parse output to check for errors. + if ($null -eq $Output) { + throw ("No output generated by $TestName.") + } Out-String -InputObject $Output | Write-Log $ParsedOutput = $Output.Split(" ") - if (($LASTEXITCODE -ne 0) -or ($ParsedOutput[$ParsedOutput.Length -2] -eq "failed")) { throw ("$TestName Test Failed.") } + if (-not (($null -ne $ParsedOutput) -and ($ParsedOutput.Length -ge 2))) { + throw ("Failed to parse output generated by $TestName.") + } + if ($ParsedOutput[$ParsedOutput.Length -2] -eq "failed") { + throw ("$TestName Test Failed.") + } Write-Log "$TestName Passed" -ForegroundColor Green }