Files

38 lines
2.3 KiB
PowerShell
Raw Permalink Normal View History

#requires -Version 7.0
# Real production NSIS template, real gate/pipe/process checks; TEMP-only apply
# sentinel. Does not load or stop any installed client, sample its network, or
# open/write production registration. The fixture must not be distributed.
param()
$ErrorActionPreference='Stop'
Set-StrictMode -Version Latest
$identity=[Security.Principal.WindowsIdentity]::GetCurrent()
try {
if(-not ([Security.Principal.WindowsPrincipal]::new($identity)).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
throw 'An already-elevated fixture runner is required; this test will not prompt for UAC.'
}
} finally { $identity.Dispose() }
$project=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
$dotnet=Join-Path $project '.tools/dotnet/dotnet.exe'
$job=Join-Path ([IO.Path]::GetTempPath()) ('ucvl-guardian-runner-'+[guid]::NewGuid().ToString('N'))
$output=Join-Path $job 'runner'
New-Item -ItemType Directory -Path $output | Out-Null
& $dotnet build (Join-Path $PSScriptRoot 'GuardianGateFixture.csproj') -c Release -o $output "-p:BaseIntermediateOutputPath=$job\obj\" "-p:IntermediateOutputPath=$job\obj\Release\" "-p:MSBuildProjectExtensionsPath=$job\obj\"
if($LASTEXITCODE -ne 0){throw 'Guardian fixture build failed'}
$start=[Diagnostics.ProcessStartInfo]::new((Join-Path $output 'VPNPlus.exe'))
$start.UseShellExecute=$false;$start.CreateNoWindow=$true;$start.WindowStyle=[Diagnostics.ProcessWindowStyle]::Hidden
$start.RedirectStandardOutput=$true;$start.RedirectStandardError=$true
$start.Environment['DOTNET_ROOT']=[IO.Path]::GetDirectoryName($dotnet)
$start.ArgumentList.Add('--test');$start.ArgumentList.Add($project)
$process=[Diagnostics.Process]::Start($start)
$stdout=$process.StandardOutput.ReadToEndAsync();$stderr=$process.StandardError.ReadToEndAsync()
$watch=[Diagnostics.Stopwatch]::StartNew()
try {
while(-not $process.WaitForExit(500)) {
if($watch.Elapsed.TotalSeconds -gt 90){$process.Kill($true);throw 'Owned fixture test tree exceeded its 90-second limit'}
}
$stdout.GetAwaiter().GetResult() | Write-Output
$errorText=$stderr.GetAwaiter().GetResult()
if($errorText){$errorText | Write-Output}
if($process.ExitCode -ne 0){throw ('Guardian fixture checks failed: '+$process.ExitCode)}
} finally { $process.Dispose() }