From 1f6c19ceb49c3f512e5bfecb592f43409d16b721 Mon Sep 17 00:00:00 2001 From: Ji Mao Cai <44921326+jinghero@users.noreply.github.com> Date: Mon, 23 Nov 2026 12:14:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=89=A7=E8=A1=8C=E6=A1=A5?= =?UTF-8?q?=E5=9B=9E=E5=BD=92=E6=AF=8F=E4=B8=80=E6=AD=A5=E7=9A=84=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E5=92=8C=E9=80=80=E5=87=BA=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重启后核对失败时,从当前回归的 bridge 日志查看具体失败项。对应 ModAVD/ModAVD#248。 --- items/bridge.ps1 | 36 +++++++++++++++++++++++++----------- suites/release.psd1 | 2 +- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/items/bridge.ps1 b/items/bridge.ps1 index bef9d13..0232d6c 100644 --- a/items/bridge.ps1 +++ b/items/bridge.ps1 @@ -13,25 +13,39 @@ param( [int]$Index = 6, # 默认取 common.ps1 的随包脚本目录 [string]$BridgeScript, - [switch]$Keep + [switch]$Keep, + # 每次调用的完整输出和退出码;套件传入本项的结果目录 + [string]$Out ) $ErrorActionPreference = 'Stop' [cultureinfo]::CurrentCulture = [cultureinfo]::InvariantCulture . "$PSScriptRoot\common.ps1" $Root = Resolve-TestRoot (Use-Local TestRoot $Root '-Root') if (-not $BridgeScript) { $BridgeScript = Join-Path (Get-PackageScripts) 'modavd-bridge.ps1' } +if (-not $Out) { + $tempRoot = Use-Local TempRoot $null '-Out' -Optional + if (-not $tempRoot) { $tempRoot = [IO.Path]::GetTempPath() } + $Out = Join-Path $tempRoot "regress-bridge-$(Get-Date -Format 'yyyyMMdd-HHmmss')-$PID" +} +$Out = [IO.Path]::GetFullPath($Out) +Assert-NotProduction $Out '输出目录' +New-Item -ItemType Directory -Force $Out | Out-Null +Say " modavd-bridge 分步日志:$Out" $payload = Join-Path $Sdk 'emulator\resources\modavd' -function Bridge([string]$action, [switch]$Reboot) { +function Bridge([string]$Step, [string]$Action, [switch]$Reboot) { $cfg = Get-RootConfig $Root # 不传 -AdbPort:脚本自己从测试根的 mas-avd.json 读,和用户照「怎么更新」敲命令时一样 - $argv = @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', (Resolve-Path $BridgeScript).Path, $action, '-Root', $Root, + $argv = @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', (Resolve-Path $BridgeScript).Path, $Action, '-Root', $Root, '-Adb', (Join-Path $cfg.sdkRoot 'platform-tools\adb.exe'), '-Payload', $payload, '-Serial', (Get-InstancePorts $Index).Serial) if ($Reboot) { $argv += '-Reboot' } - $out = & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" @argv 2>&1 | ForEach-Object { "$_" } + # 退出码 3 是正常的步骤结果,其他非零退出也要先落盘。 + $PSNativeCommandUseErrorActionPreference = $false + $output = & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" @argv 2>&1 | ForEach-Object { "$_" } $code = $LASTEXITCODE - Say " modavd-bridge $action$(if ($Reboot) { ' -Reboot' }) -> 退出码 $code:$(($out | Where-Object { $_.Trim() } | Select-Object -Last 1))" - [pscustomobject]@{ Code = $code; Text = ($out -join "`n") } + Set-Content -LiteralPath (Join-Path $Out "$Step.txt") -Encoding utf8 -Value (@("ExitCode: $code", '') + @($output)) + Say " modavd-bridge $Action$(if ($Reboot) { ' -Reboot' }) -> 退出码 $code:$(($output | Where-Object { $_.Trim() } | Select-Object -Last 1))" + [pscustomobject]@{ Code = $code; Text = ($output -join "`n") } } function Uptime { [double](((A shell 'cat /proc/uptime') -join '') -split '\s+')[0] } function Stock { @@ -56,20 +70,20 @@ try { if ($s.Prop -ne 'libndk_translation.so' -or $s.Files -ne '0' -or $s.NbLog -ne '0') { $problems += "没装桥的实例不干净:属性 $($s.Prop)、文件 $($s.Files)、ModAvdNB $($s.NbLog)" } else { $notes += '没装桥时零影响' } - $r = Bridge install + $r = Bridge '02-install-stock' install if ($r.Code -ne 3 -or -not (Test-Path $marker)) { $problems += "照常开机时 install 应退出码 3 并放标记(实际 $($r.Code),标记 $(Test-Path $marker))" } elseif ((Stock).Prop -ne 'libndk_translation.so') { $problems += '照常开机时 install 改了属性' } else { $notes += '照常开机时 install 不动客体、放标记、退出码 3' } M stop $Index | Out-Null M start $Index --no-bridge | Select-Object -Last 1 | ForEach-Object { Say " $_" } - $r = Bridge install -Reboot + $r = Bridge '03-install-reboot' install -Reboot if ($r.Code -ne 0 -or $r.Text -notmatch '装好了,核对全过') { $problems += "install -Reboot 没成(退出码 $($r.Code))" } else { $notes += 'install -Reboot 核对全过' } $cfgIni = Join-Path $Root "avd\mas_$Index.avd\config.ini" if (-not (Select-String -LiteralPath $cfgIni -Pattern '^hw\.gltransport=asg$' -Quiet)) { $problems += '装桥后 config.ini 没有 hw.gltransport=asg' } else { $notes += 'GL 传输设成 asg' } $u0 = Uptime - $r = Bridge install + $r = Bridge '04-install-repeat' install $u1 = Uptime if ($r.Code -ne 0 -or $r.Text -notmatch '已安装且是当前版本' -or $u1 -lt $u0) { $problems += "重复 install 不是「已安装且是当前版本」或重启了(退出码 $($r.Code),uptime $u0 -> $u1)" } else { $notes += '重复 install 不动' } @@ -77,12 +91,12 @@ try { M stop $Index | Out-Null M start $Index --no-bridge | Select-Object -Last 1 | ForEach-Object { Say " $_" } $zram = ((Su "grep -c '^/dev/block/zram0 ' /proc/swaps") -join '').Trim() - $r = Bridge verify + $r = Bridge '05-verify-cold-boot' verify $asgOn = ((A shell 'getprop ro.boot.hardware.gltransport') -join '').Trim() if ($r.Code -ne 0 -or $zram -ne '1') { $problems += "冷启动后 verify 退出码 $($r.Code)、zram $zram" } else { $notes += '冷启动后桥在、zram 在' } if ($asgOn -ne 'asg') { $problems += "冷启动后实际 GL 传输是「$asgOn」,不是 asg" } else { $notes += '冷启动后实际走 asg' } - $r = Bridge uninstall -Reboot + $r = Bridge '06-uninstall-reboot' uninstall -Reboot $s = Stock if (Select-String -LiteralPath $cfgIni -Pattern '^hw\.gltransport=' -Quiet) { $problems += '卸桥后 config.ini 还留着 hw.gltransport' } if ($r.Code -ne 0 -or $s.Prop -ne 'libndk_translation.so' -or $s.Files -ne '0' -or (Test-Path $marker)) { diff --git a/suites/release.psd1 b/suites/release.psd1 index c6ee4d7..8b259fc 100644 --- a/suites/release.psd1 +++ b/suites/release.psd1 @@ -95,7 +95,7 @@ Id = 'bridge'; Title = 'arm64 执行桥装 / 卸全流程(PowerShell 5.1)'; Criterion = '不装桥零影响;照常开机时 install 退出码 3 只放标记;install -Reboot 核对全过;重复 install 不动;冷启动后桥和 zram 在;uninstall 卸干净' Scopes = @('emulator', 'bridge', 'scripts') Script = '{Repo}\items\bridge.ps1' - Args = @('-Sdk', '{Sdk}') + Args = @('-Sdk', '{Sdk}', '-Out', '{ItemOut}') TimeoutMin = 30 } @{