| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- param([string]$ReleaseRoot = 'C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.12')
- $ErrorActionPreference = 'Stop'
- $ProgressPreference = 'SilentlyContinue'
- $appRoot = Join-Path $ReleaseRoot 'app'
- $evidence = Join-Path $ReleaseRoot 'evidence'
- $utf8 = New-Object System.Text.UTF8Encoding($false)
- $env:PATH = "$env:SystemRoot\System32;$env:SystemRoot"
- $env:QT_QPA_PLATFORM = 'windows'
- $env:STL_QT_DISABLE_SERIAL = '1'
- $env:STL_QT_CONFIG_DIR = $appRoot
- $env:STL_QT_PLANS_FILE = Join-Path $appRoot 'qt-plans.json'
- Remove-Item Env:\QT_PLUGIN_PATH,Env:\QT_QPA_PLATFORM_PLUGIN_PATH,Env:\QTDIR,Env:\STL_QT_BACKEND_URL -ErrorAction SilentlyContinue
- $start = Get-Date
- $result = @{ passed=$false; started_utc=$start.ToUniversalTime().ToString('o');
- wrapper_session_id=(Get-Process -Id $PID).SessionId; platform='windows';
- uses_bundled_runtime_without_sdk_path=$true }
- try {
- $report = Join-Path $evidence 'windows-qt-live-host-on.json'
- $arguments = @('--mode','start','--url','ws://192.168.2.79:8080/ws?view=qt-clean',
- '--report',$report,'--screenshot',(Join-Path $evidence 'windows-qt-live-host-on.png'),
- '--expect-phase','mt','--timeout','900')
- # Own the Process handle directly: PowerShell 5.1 Start-Process can return a
- # Process object whose ExitCode is null after asynchronous redirection.
- $info = New-Object System.Diagnostics.ProcessStartInfo
- $info.FileName = Join-Path $appRoot 'QtCleanProbe.exe'
- $info.Arguments = ($arguments | ForEach-Object { '"' + $_ + '"' }) -join ' '
- $info.WorkingDirectory = $appRoot
- $info.UseShellExecute = $false
- $info.CreateNoWindow = $true
- $info.RedirectStandardOutput = $true
- $info.RedirectStandardError = $true
- $process = New-Object System.Diagnostics.Process
- $process.StartInfo = $info
- if (!$process.Start()) { throw 'Could not start the native Qt process.' }
- $stdoutTask = $process.StandardOutput.ReadToEndAsync()
- $stderrTask = $process.StandardError.ReadToEndAsync()
- $result.process_id = $process.Id
- $result.process_session_id = $process.SessionId
- [IO.File]::WriteAllText((Join-Path $evidence 'windows-live-process-start.json'), ($result | ConvertTo-Json -Depth 8), $utf8)
- if (!$process.WaitForExit(960000)) {
- Stop-Process -Id $process.Id -ErrorAction SilentlyContinue
- throw 'The Qt verification process exceeded its timeout.'
- }
- $result.exit_code = $process.ExitCode
- [IO.File]::WriteAllText((Join-Path $evidence 'windows-qt-live-host-on.stdout.log'), $stdoutTask.GetAwaiter().GetResult(), $utf8)
- [IO.File]::WriteAllText((Join-Path $evidence 'windows-qt-live-host-on.stderr.log'), $stderrTask.GetAwaiter().GetResult(), $utf8)
- if (!(Test-Path -LiteralPath $report)) { throw 'Qt verification did not produce its report.' }
- $verification = Get-Content -LiteralPath $report -Raw -Encoding utf8 | ConvertFrom-Json
- $result.qt_report_passed = $verification.pass
- $result.elapsed_ms = $verification.elapsed_ms
- $result.checks = @($verification.checks.PSObject.Properties).Count
- $result.command_boot_id = $verification.command_boot_id
- $result.passed = $process.ExitCode -eq 0 -and $verification.pass -eq $true -and $result.process_session_id -eq 1
- } catch {
- $result.error = $_.Exception.Message
- } finally {
- $result.completed_utc = (Get-Date).ToUniversalTime().ToString('o')
- [IO.File]::WriteAllText((Join-Path $evidence 'windows-live-process-result.json'), ($result | ConvertTo-Json -Depth 8), $utf8)
- }
- if (!$result.passed) { exit 1 }
- exit 0
|