Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions items/bridge.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -56,33 +70,33 @@ 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 不动' }

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)) {
Expand Down
2 changes: 1 addition & 1 deletion suites/release.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
@{
Expand Down