2026-08-29 21:56:51 +08:00
|
|
|
[CmdletBinding()]
|
2026-09-06 17:04:11 +08:00
|
|
|
param(
|
|
|
|
|
[switch]$RealE2E,
|
|
|
|
|
[string]$ResultPath = (Join-Path $env:TEMP "hardware-agent-real-e2e.json")
|
|
|
|
|
)
|
2026-08-29 21:56:51 +08:00
|
|
|
|
|
|
|
|
$ErrorActionPreference = "Stop"
|
2026-09-06 17:04:11 +08:00
|
|
|
$secretPath = Join-Path $env:LOCALAPPDATA "DataTerminalHardwareAgent\server-device-secret"
|
|
|
|
|
$executablePath = Join-Path $PSScriptRoot "hardware-agent-tester-0.3.5-windows-x64.exe"
|
|
|
|
|
if (-not (Test-Path -LiteralPath $executablePath -PathType Leaf)) {
|
|
|
|
|
$executablePath = Join-Path $PSScriptRoot "release\hardware-agent-tester-0.3.5-windows-x64.exe"
|
|
|
|
|
}
|
2026-08-29 21:56:51 +08:00
|
|
|
|
|
|
|
|
if (-not (Test-Path -LiteralPath $secretPath -PathType Leaf)) {
|
|
|
|
|
throw "Cloud device credential is missing: $secretPath"
|
|
|
|
|
}
|
|
|
|
|
if (-not (Test-Path -LiteralPath $executablePath -PathType Leaf)) {
|
2026-09-06 17:04:11 +08:00
|
|
|
throw "Hardware agent tester is missing: $executablePath"
|
2026-08-29 21:56:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$env:SIMULATOR_DEFAULT_API_URL = "https://121.41.46.238"
|
2026-09-06 17:04:11 +08:00
|
|
|
$env:SIMULATOR_DEFAULT_DEVICE_ID = "10000000-0000-0000-0000-000000000512"
|
2026-08-29 21:56:51 +08:00
|
|
|
$env:SIMULATOR_DEFAULT_DEVICE_SECRET = [IO.File]::ReadAllText($secretPath).Trim()
|
|
|
|
|
try {
|
2026-09-06 17:04:11 +08:00
|
|
|
if ($RealE2E) {
|
|
|
|
|
$env:SIMULATOR_REAL_E2E = "1"
|
|
|
|
|
$env:SIMULATOR_AUTO_RESULT_PATH = $ResultPath
|
|
|
|
|
$env:SIMULATOR_VOLC_MODEL_MODE = "llm"
|
|
|
|
|
$env:SIMULATOR_REAL_E2E_QUESTION = "Please introduce yourself in one short sentence."
|
|
|
|
|
$process = Start-Process -FilePath $executablePath -WindowStyle Hidden -PassThru -Wait
|
|
|
|
|
if ($process.ExitCode -ne 0) { throw "Hardware agent tester exited with code $($process.ExitCode)" }
|
|
|
|
|
if (-not (Test-Path -LiteralPath $ResultPath -PathType Leaf)) { throw "Real E2E report was not created: $ResultPath" }
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Start-Process -FilePath $executablePath
|
|
|
|
|
}
|
2026-08-29 21:56:51 +08:00
|
|
|
}
|
|
|
|
|
finally {
|
|
|
|
|
Remove-Item Env:SIMULATOR_DEFAULT_API_URL -ErrorAction SilentlyContinue
|
|
|
|
|
Remove-Item Env:SIMULATOR_DEFAULT_DEVICE_ID -ErrorAction SilentlyContinue
|
|
|
|
|
Remove-Item Env:SIMULATOR_DEFAULT_DEVICE_SECRET -ErrorAction SilentlyContinue
|
2026-09-06 17:04:11 +08:00
|
|
|
Remove-Item Env:SIMULATOR_REAL_E2E -ErrorAction SilentlyContinue
|
|
|
|
|
Remove-Item Env:SIMULATOR_AUTO_RESULT_PATH -ErrorAction SilentlyContinue
|
|
|
|
|
Remove-Item Env:SIMULATOR_VOLC_MODEL_MODE -ErrorAction SilentlyContinue
|
|
|
|
|
Remove-Item Env:SIMULATOR_REAL_E2E_QUESTION -ErrorAction SilentlyContinue
|
2026-08-29 21:56:51 +08:00
|
|
|
}
|