Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

86 рядки
4.3KB

  1. # E02-S04: run the diagnostics test in x128, then check the result block, the
  2. # 40-column screen, and the ERR files left on the disk image.
  3. [CmdletBinding()]
  4. param([int]$Port = 6534, [int]$TimeoutSeconds = 180)
  5. $ErrorActionPreference = "Stop"
  6. $project = Split-Path $PSScriptRoot -Parent
  7. Import-Module (Join-Path $PSScriptRoot "lib\Nova128Test.psm1") -Force
  8. & (Join-Path $PSScriptRoot "build-diag-test.ps1")
  9. $out = Join-Path $project "build\diag-test"
  10. $disk = Join-Path $out "diag-test.d81"
  11. $expected = Get-Content -Raw (Join-Path $out "expected.json") | ConvertFrom-Json
  12. $failures = @()
  13. $session = Start-Nova128X128 -Autostart $disk -Drive8Image $disk -Port $Port `
  14. -Screenshot (Join-Path $out "diag-test-vicii.png")
  15. try {
  16. $mb = Wait-Nova128Mailbox $session -TimeoutSeconds $TimeoutSeconds
  17. $results = Read-Nova128Memory $session ($mb[8] + 256 * $mb[9]) 34
  18. Invoke-Nova128Monitor $session "x" | Out-Null
  19. Start-Sleep -Seconds 2 # let the OK line print
  20. $screenRam = Read-Nova128Memory $session 0x0400 1000
  21. } finally {
  22. Stop-Nova128X128 $session -SettleSeconds 0
  23. }
  24. # ------------------------------------------------------------ results
  25. $want = [ordered]@{ "phase A count" = @(0, 6); "phase D count" = @(1, 2); "phase D file state (2=failed)" = @(2, 2)
  26. "phase B count" = @(3, 20); "phase C count" = @(4, 0) }
  27. foreach ($k in $want.Keys) {
  28. if ($results[$want[$k][0]] -ne $want[$k][1]) { $failures += "${k}: $($results[$want[$k][0]]) expected $($want[$k][1])" }
  29. }
  30. for ($i = 5; $i -le 8; $i++) { if ($results[$i] -ne 0) { $failures += "files left open after phase $($i - 4): $($results[$i])" } }
  31. $carries = $results[9..33]
  32. $wantCarries = @(0) * 20 + @(1) * 5
  33. if (($carries -join ',') -ne ($wantCarries -join ',')) {
  34. $failures += "phase B carries $($carries -join '') expected $($wantCarries -join '')"
  35. }
  36. # ------------------------------------------------------------- screen
  37. $rows = for ($r = 0; $r -lt 25; $r++) {
  38. $chars = for ($c = 0; $c -lt 40; $c++) {
  39. $code = $screenRam[$r * 40 + $c]
  40. if ($code -le 0x1F) { [char]($code + 0x40) } elseif ($code -le 0x3F) { [char]$code } else { '?' }
  41. }
  42. (-join $chars).TrimEnd()
  43. }
  44. for ($r = 0; $r -lt $expected.screen.Count; $r++) {
  45. $pattern = '^' + [regex]::Escape($expected.screen[$r]).Replace('\#\#', '\d\d').Replace('##', '\d\d') + '$'
  46. if ($rows[$r] -notmatch $pattern) { $failures += "screen row ${r}: '$($rows[$r])' expected '$($expected.screen[$r])'" }
  47. }
  48. $wide = @($rows | Where-Object { $_.Length -gt 39 })
  49. if ($wide) { $failures += "screen rows longer than 39: $($wide -join ' | ')" }
  50. # ---------------------------------------------------------- ERR files
  51. $c1541 = Get-ViceTool "c1541"
  52. $listing = (& $c1541 -attach $disk -list 2>&1) | Out-String
  53. function Read-SeqText([string]$name) {
  54. $dest = Join-Path $out ($name.Replace('*', '_') + ".bin")
  55. if (Test-Path $dest) { Remove-Item $dest -Force }
  56. & $c1541 -attach $disk -read "$name,s" $dest 2>&1 | Out-Null # SEQ needs ,s
  57. if (-not (Test-Path $dest)) { return $null }
  58. $bytes = [IO.File]::ReadAllBytes($dest)
  59. return @(([Text.Encoding]::ASCII.GetString($bytes).TrimEnd("`r")) -split "`r")
  60. }
  61. $diagLines = Read-SeqText "diag.err"
  62. if ($null -eq $diagLines) { $failures += "diag.err missing" }
  63. elseif (($diagLines -join "`n") -cne ($expected.diag -join "`n")) {
  64. $failures += "diag.err differs:`n got: " + ($diagLines -join "`n ") + "`n want: " + ($expected.diag -join "`n ")
  65. }
  66. $limitLines = Read-SeqText "limit.err"
  67. if ($null -eq $limitLines) { $failures += "limit.err missing" }
  68. elseif (($limitLines -join "`n") -cne ($expected.limit -join "`n")) {
  69. $failures += "limit.err differs ($($limitLines.Count) lines): first '$($limitLines[0])', last '$($limitLines[-1])'"
  70. }
  71. if ($listing -match '"clean\.err"') { $failures += "stale clean.err was not scratched" }
  72. if ($listing -match '"bad') { $failures += "a bad*.err file was created" }
  73. if ($failures) { throw ("diagnostics verification failed:`n " + ($failures -join "`n ")) }
  74. Write-Host "screen (rows 0-$($expected.screen.Count - 1)):"
  75. $rows[0..($expected.screen.Count - 1)] | ForEach-Object { Write-Host " |$_" }
  76. Write-Host ("diag.err: {0} lines, limit.err: {1} lines (20 + limit), clean.err scratched, no bad*.err" -f
  77. $diagLines.Count, $limitLines.Count)
  78. Write-Host "verified diagnostics: results, screen, and ERR files match"

Powered by TurnKey Linux.