@samitouri / QOSAMI-WSL / commits / da25b437

make script run as standalone

Catalin-Emil Fetoiu committed Oct 31, 2023 at 11:23 UTC da25b437563c0ff4bfc0ad6d56746e6fcadc209b
2 files changed +15 -9
CONTRIBUTING.md
+3 -6
@@ -132,12 +132,9 @@ Install [WPR](https://learn.microsoft.com/en-us/windows-hardware/test/wpt/window
132 To collect WSL networking logs, do the following steps in an administrative powershell prompt:
133
134 ```
135 -$ Invoke-WebRequest 'https://github.com/microsoft/WSL/archive/refs/heads/master.zip' -OutFile .\wsl.zip
136 -$ Expand-Archive .\wsl.zip .\
137 -$ Remove-Item .\wsl.zip
138 -$ cd .\WSL-master\diagnostics
139 -$ Set-ExecutionPolicy Bypass -Scope Process -Force
140 -$ .\collect-networking-logs.ps1
135 +Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-networking-logs.ps1" -OutFile collect-networking-logs.ps1
136 +Set-ExecutionPolicy Bypass -Scope Process -Force
137 +.\collect-networking-logs.ps1
138 ```
139 The script will output when log collection starts. Reproduce the problem, then press any key to stop the log collection.
140 The script will output the path of the log file once done.
diagnostics/collect-networking-logs.ps1
+12 -3
@@ -8,6 +8,13 @@ Param (
8 $folder = "WslNetworkingLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
9 mkdir -p $folder
10
11 +$logProfile = "$folder/wsl_networking.wprp"
12 +$networkingBashScript = "$folder/networking.sh"
13 +
14 +# Download supporting files
15 +Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_networking.wprp" -OutFile $logProfile
16 +Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/networking.sh" -OutFile $networkingBashScript
17 +
18 # Retrieve WSL version and wslconfig file
19 get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux > $folder/appxpackage.txt
20
@@ -18,7 +25,7 @@ if (Test-Path $wslconfig)
25 }
26
27 # Collect Linux network state before the repro
21 -& wsl.exe -e ./networking.sh 2>&1 > $folder/linux_network_configuration_before.log
28 +& wsl.exe -e $networkingBashScript 2>&1 > $folder/linux_network_configuration_before.log
29
30 if ($RestartWslReproMode)
31 {
@@ -34,7 +41,6 @@ if ($RestartWslReproMode)
41 }
42
43 # Start logging.
37 -$logProfile = ".\wsl_networking.wprp"
44 $wprOutputLog = "$folder/wpr.txt"
45
46 wpr.exe -start $logProfile -filemode 2>&1 >> $wprOutputLog
@@ -123,7 +129,7 @@ finally
129 }
130
131 # Collect Linux network state after the repro
126 -& wsl.exe -e ./networking.sh 2>&1 > $folder/linux_network_configuration_after.log
132 +& wsl.exe -e $networkingBashScript 2>&1 > $folder/linux_network_configuration_after.log
133
134 # Collect host networking state relevant for WSL
135 # Using a try/catch for commands below, as some of them do not exist on all OS versions
@@ -216,6 +222,9 @@ try
222 }
223 catch {}
224
225 +Remove-Item $logProfile
226 +Remove-Item $networkingBashScript
227 +
228 $logArchive = "$(Resolve-Path $folder).zip"
229 Compress-Archive -Path $folder -DestinationPath $logArchive
230 Remove-Item $folder -Recurse