diff options
Diffstat (limited to 'scripts/test_windows/service-test.ps1')
| -rw-r--r-- | scripts/test_windows/service-test.ps1 | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/scripts/test_windows/service-test.ps1 b/scripts/test_windows/service-test.ps1 index 4c484c63f..a2723681e 100644 --- a/scripts/test_windows/service-test.ps1 +++ b/scripts/test_windows/service-test.ps1 @@ -22,6 +22,8 @@ if (-not $ZenBinary) { $ZenBinary = Join-Path $RepoRoot "build\windows\x64\debug\zen.exe" } $ZenServerBinary = Join-Path (Split-Path -Parent $ZenBinary) "zenserver.exe" + +function Zen { & $ZenBinary --enable-execution-history=false @args } $ServiceName = "ZenServerTest-$PID" $Script:Passed = 0 @@ -106,7 +108,7 @@ try { Write-Host "--- Test: status before install ---" -$Output = & $ZenBinary service status $ServiceName 2>&1 | Out-String +$Output = Zen service status $ServiceName 2>&1 | Out-String if ($Output -match "not installed") { Pass "status reports 'not installed' for non-existent service" } else { @@ -117,7 +119,7 @@ if ($Output -match "not installed") { Write-Host "--- Test: install ---" -$Output = & $ZenBinary service install $ZenServerBinary $ServiceName --allow-elevation 2>&1 | Out-String +$Output = Zen service install $ZenServerBinary $ServiceName --allow-elevation 2>&1 | Out-String $ExitCode = $LASTEXITCODE if ($ExitCode -eq 0) { @@ -153,7 +155,7 @@ if ($svc) { Write-Host "--- Test: install again (idempotent) ---" -$Output = & $ZenBinary service install $ZenServerBinary $ServiceName --allow-elevation 2>&1 | Out-String +$Output = Zen service install $ZenServerBinary $ServiceName --allow-elevation 2>&1 | Out-String $ExitCode = $LASTEXITCODE if ($ExitCode -eq 0) { @@ -172,7 +174,7 @@ if ($Output -match "already installed") { Write-Host "--- Test: status after install (stopped) ---" -$Output = & $ZenBinary service status $ServiceName 2>&1 | Out-String +$Output = Zen service status $ServiceName 2>&1 | Out-String if ($Output -match "not running") { Pass "status reports 'not running' for stopped service" } else { @@ -183,7 +185,7 @@ if ($Output -match "not running") { Write-Host "--- Test: start ---" -$Output = & $ZenBinary service start $ServiceName --allow-elevation 2>&1 | Out-String +$Output = Zen service start $ServiceName --allow-elevation 2>&1 | Out-String $ExitCode = $LASTEXITCODE if ($ExitCode -eq 0) { @@ -202,7 +204,7 @@ if ($svc -and $svc.Status -eq "Running") { Write-Host "--- Test: status (running) ---" - $Output = & $ZenBinary service status $ServiceName 2>&1 | Out-String + $Output = Zen service status $ServiceName 2>&1 | Out-String if ($Output -match "Running") { Pass "status reports 'Running'" } else { @@ -219,7 +221,7 @@ if ($svc -and $svc.Status -eq "Running") { Write-Host "--- Test: start again (already running) ---" - $Output = & $ZenBinary service start $ServiceName --allow-elevation 2>&1 | Out-String + $Output = Zen service start $ServiceName --allow-elevation 2>&1 | Out-String if ($Output -match "already running") { Pass "start reports service already running" } else { @@ -230,7 +232,7 @@ if ($svc -and $svc.Status -eq "Running") { Write-Host "--- Test: stop ---" - $Output = & $ZenBinary service stop $ServiceName --allow-elevation 2>&1 | Out-String + $Output = Zen service stop $ServiceName --allow-elevation 2>&1 | Out-String $ExitCode = $LASTEXITCODE if ($ExitCode -eq 0) { @@ -258,7 +260,7 @@ Write-Host "--- Test: stop when already stopped ---" Stop-Service -Name $ServiceName -Force -ErrorAction SilentlyContinue Start-Sleep -Seconds 1 -$Output = & $ZenBinary service stop $ServiceName --allow-elevation 2>&1 | Out-String +$Output = Zen service stop $ServiceName --allow-elevation 2>&1 | Out-String if ($Output -match "not running") { Pass "stop reports 'not running' when already stopped" } else { @@ -269,12 +271,12 @@ if ($Output -match "not running") { Write-Host "--- Test: uninstall while running (should fail) ---" -& $ZenBinary service start $ServiceName --allow-elevation 2>&1 | Out-Null +Zen service start $ServiceName --allow-elevation 2>&1 | Out-Null Start-Sleep -Seconds 2 $svc = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue if ($svc -and $svc.Status -eq "Running") { - $Output = & $ZenBinary service uninstall $ServiceName --allow-elevation 2>&1 | Out-String + $Output = Zen service uninstall $ServiceName --allow-elevation 2>&1 | Out-String $ExitCode = $LASTEXITCODE if ($ExitCode -ne 0 -or $Output -match "running.*stop") { @@ -284,7 +286,7 @@ if ($svc -and $svc.Status -eq "Running") { } # Stop it for the real uninstall test - & $ZenBinary service stop $ServiceName --allow-elevation 2>&1 | Out-Null + Zen service stop $ServiceName --allow-elevation 2>&1 | Out-Null Stop-Service -Name $ServiceName -Force -ErrorAction SilentlyContinue Start-Sleep -Seconds 2 } else { @@ -298,7 +300,7 @@ Write-Host "--- Test: uninstall ---" Stop-Service -Name $ServiceName -Force -ErrorAction SilentlyContinue Start-Sleep -Seconds 1 -$Output = & $ZenBinary service uninstall $ServiceName --allow-elevation 2>&1 | Out-String +$Output = Zen service uninstall $ServiceName --allow-elevation 2>&1 | Out-String $ExitCode = $LASTEXITCODE if ($ExitCode -eq 0) { @@ -318,7 +320,7 @@ if (-not $svc) { Write-Host "--- Test: status after uninstall ---" -$Output = & $ZenBinary service status $ServiceName 2>&1 | Out-String +$Output = Zen service status $ServiceName 2>&1 | Out-String if ($Output -match "not installed") { Pass "status reports 'not installed' after uninstall" } else { @@ -329,7 +331,7 @@ if ($Output -match "not installed") { Write-Host "--- Test: uninstall when not installed ---" -$Output = & $ZenBinary service uninstall $ServiceName --allow-elevation 2>&1 | Out-String +$Output = Zen service uninstall $ServiceName --allow-elevation 2>&1 | Out-String $ExitCode = $LASTEXITCODE if ($ExitCode -eq 0) { |