Skip to content
Merged
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
39 changes: 31 additions & 8 deletions scripts/config_test_vm.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -711,21 +711,44 @@ function Initialize-NetworkInterfaces {
[Parameter(Mandatory=$false)][bool] $ExecuteOnVM = $false,
[Parameter(Mandatory=$false)] $VMList = @(),
[Parameter(Mandatory=$true)][string] $TestWorkingDirectory,
[Parameter(Mandatory=$false)][bool] $VMIsRemote = $false
[Parameter(Mandatory=$false)][bool] $VMIsRemote = $false,
[Parameter(Mandatory=$false)][bool] $KmTracing = $false,
[Parameter(Mandatory=$false)][string] $KmTraceType = "file"
Comment thread
lakshk98 marked this conversation as resolved.
)

$commandScriptBlock = {
param([Parameter(Mandatory=$true)] [string] $WorkingDirectory,
[Parameter(Mandatory=$true)][string] $LogFileName)
[Parameter(Mandatory=$true)][string] $LogFileName,
[Parameter(Mandatory=$true)][bool] $KmTracing,
[Parameter(Mandatory=$true)][string] $KmTraceType)
$traceStarted = $false
Push-Location $WorkingDirectory
Import-Module .\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue
Write-Log "Installing DuoNic driver"
.\duonic.ps1 -Install -NumNicPairs 2
Set-NetAdapterAdvancedProperty duo? -DisplayName Checksum -RegistryValue 0
Pop-Location
try {
Import-Module .\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue
if ($KmTracing) {
Import-Module .\tracing_utils.psm1 -ArgumentList ($LogFileName, $WorkingDirectory) -Force -WarningAction SilentlyContinue
Start-WPRTrace -TraceType $KmTraceType -FailOnError
$traceStarted = $true
}
Write-Log "Installing DuoNic driver"
$LASTEXITCODE = 0
.\duonic.ps1 -Install -NumNicPairs 2
if ($LASTEXITCODE -ne 0) {
throw "DuoNic installation failed with exit code $LASTEXITCODE."
}
Set-NetAdapterAdvancedProperty duo? -DisplayName Checksum -RegistryValue 0
} finally {
try {
if ($traceStarted) {
Stop-WPRTrace -FileName "initialize_network_interfaces"
}
} finally {
Pop-Location
}
}
}

$argumentList = @($TestWorkingDirectory, $LogFileName)
$argumentList = @($TestWorkingDirectory, $LogFileName, $KmTracing, $KmTraceType)

if ($ExecuteOnVM) {
# Execute on VMs.
Expand Down
2 changes: 2 additions & 0 deletions scripts/setup_ebpf_cicd_tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ $Job = Start-Job -ScriptBlock {
-VMList $VMList `
-TestWorkingDirectory $(if ($ExecuteOnVM) { "C:\ebpf" } else { $WorkingDirectory }) `
-VMIsRemote:$VMIsRemote `
-KmTracing $KmTracing `
-KmTraceType $KmTraceType `
-ErrorAction Stop

Write-Log "Network interfaces initialized"
Expand Down
9 changes: 8 additions & 1 deletion scripts/tracing_utils.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ function Start-WPRTrace {
[Parameter(Mandatory=$false)] [string] $TraceType = "file",
[Parameter(Mandatory=$false)] [string] $WprpFileName = "ebpfforwindows.wprp",
[Parameter(Mandatory=$false)] [string] $TracingProfileName = "EbpfForWindows-Networking",
[Parameter(Mandatory=$false)] [int] $TimeoutSeconds = 60
[Parameter(Mandatory=$false)] [int] $TimeoutSeconds = 60,
[Parameter(Mandatory=$false)] [switch] $FailOnError
)

try {
Expand Down Expand Up @@ -58,9 +59,15 @@ function Start-WPRTrace {
Write-Log "Successfully started trace"
} else {
Write-Log "Failed to start trace with exit code $exitCode"
if ($FailOnError) {
throw "Failed to start WPR trace with exit code $exitCode."
}
}
} catch {
Write-Log "Exception starting WPR trace: $_" -ForegroundColor Red
if ($FailOnError) {
throw
}
}
}

Expand Down
Loading