25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

125 satır
5.1KB

  1. # E04-S01: run the PRG/MAP writer test in x128, inspect the disk artifacts,
  2. # and autostart the generated PRG to prove the startup path and termination.
  3. [CmdletBinding()]
  4. param(
  5. [int]$Port = 6530,
  6. [int]$RunPort = 6531,
  7. [int]$TimeoutSeconds = 90
  8. )
  9. $ErrorActionPreference = "Stop"
  10. $project = Split-Path $PSScriptRoot -Parent
  11. Import-Module (Join-Path $PSScriptRoot "lib\Nova128Test.psm1") -Force
  12. & (Join-Path $PSScriptRoot "build-output-test.ps1")
  13. $out = Join-Path $project "build\output-test"
  14. $disk = Join-Path $out "output-test.d81"
  15. $c1541 = Get-ViceTool "c1541"
  16. $session = Start-Nova128X128 -Autostart $disk -Drive8Image $disk -Port $Port `
  17. -Screenshot (Join-Path $out "output-test-vicii.png")
  18. try {
  19. $mb = Wait-Nova128Mailbox $session -TimeoutSeconds $TimeoutSeconds
  20. } finally {
  21. Stop-Nova128X128 $session
  22. }
  23. Write-Host ('mailbox: ' + (($mb | ForEach-Object { $_.ToString('X2') }) -join ' '))
  24. Write-Host ('results: finish={0} collision={1} order={2} abort={3}' -f $mb[8], $mb[9], $mb[10], $mb[11])
  25. $failures = @()
  26. if ($mb[2] -ne 0x01) { $failures += "producer $($mb[2]) is not the platform test" }
  27. if ($mb[3] -ne 0xA5) { $failures += "fixture status is not PASS" }
  28. $want = @(0, 1, 2, 0)
  29. for ($i = 0; $i -lt $want.Count; $i++) {
  30. if ($mb[8 + $i] -ne $want[$i]) {
  31. $failures += "result $i is $($mb[8 + $i]), expected $($want[$i])"
  32. }
  33. }
  34. if ($mb[4] -ne 0 -or $mb[5] -ne 0) {
  35. $failures += "code is $($mb[4] + 256 * $mb[5])"
  36. }
  37. function Read-DiskFile([string]$Name, [string]$Dest, [bool]$Seq) {
  38. if (Test-Path -LiteralPath $Dest) { Remove-Item -LiteralPath $Dest -Force }
  39. $spec = if ($Seq) { "$Name,s" } else { $Name }
  40. & $c1541 -attach $disk -read $spec $Dest 2>&1 | Out-Null
  41. if (-not (Test-Path -LiteralPath $Dest)) { throw "could not read $Name from the test disk" }
  42. }
  43. $prgPath = Join-Path $out "generate.prg"
  44. $mapPath = Join-Path $out "generate.map"
  45. $collidePrg = Join-Path $out "collide-check.prg"
  46. $collideMap = Join-Path $out "collide-check.map"
  47. Read-DiskFile "generate.prg" $prgPath $false
  48. Read-DiskFile "generate.map" $mapPath $true
  49. Read-DiskFile "collide.prg" $collidePrg $false
  50. Read-DiskFile "collide.map" $collideMap $true
  51. $bytes = [IO.File]::ReadAllBytes($prgPath)
  52. if ($bytes.Length -ne 133) { $failures += "GENERATE.PRG is $($bytes.Length) bytes, expected 133" }
  53. if ($bytes[0] -ne 0x01 -or $bytes[1] -ne 0x1C) {
  54. $failures += ("load address is ${0:X2}{1:X2}, expected 011C" -f $bytes[1], $bytes[0])
  55. }
  56. $stub = [byte[]](0x0B, 0x1C, 0x0A, 0x00, 0x9E, 0x37, 0x31, 0x38, 0x31, 0x00, 0x00, 0x00)
  57. for ($i = 0; $i -lt $stub.Length; $i++) {
  58. if ($bytes[2 + $i] -ne $stub[$i]) {
  59. $failures += ("BASIC stub byte {0} is {1:X2}, expected {2:X2}" -f $i, $bytes[2 + $i], $stub[$i])
  60. }
  61. }
  62. $padOffset = 2 + (0x1C80 - 0x1C01)
  63. $pad = @(0xDE, 0xAD, 0xBE, 0xEF)
  64. for ($i = 0; $i -lt $pad.Count; $i++) {
  65. if ($bytes[$padOffset + $i] -ne $pad[$i]) {
  66. $failures += ("PAD byte {0} is {1:X2}, expected {2:X2}" -f $i, $bytes[$padOffset + $i], $pad[$i])
  67. }
  68. }
  69. for ($i = 2 + 12 + 80; $i -lt $padOffset; $i++) {
  70. if ($bytes[$i] -ne 0) { $failures += "gap byte at $i is not zero"; break }
  71. }
  72. $mapLines = ([IO.File]::ReadAllText($mapPath)).TrimEnd("`r", "`n") -split "`r`n|`r|`n"
  73. $expectedMap = @(
  74. "NOVA128 MAP 1",
  75. "ENTRY 1C0D",
  76. "SECTION STUB 1C01 000C",
  77. "SECTION START 1C0D 004A",
  78. "SECTION PAD 1C80 0004")
  79. if (($mapLines -join "`n") -ne ($expectedMap -join "`n")) {
  80. $failures += ("GENERATE.MAP differs:`n got: " + ($mapLines -join "`n ") +
  81. "`n want: " + ($expectedMap -join "`n "))
  82. }
  83. $keep = [Text.Encoding]::ASCII.GetString([IO.File]::ReadAllBytes($collidePrg))
  84. if ($keep -cne "KEEP") { $failures += "COLLIDE.PRG changed to '$keep'" }
  85. $keepMap = [Text.Encoding]::ASCII.GetString([IO.File]::ReadAllBytes($collideMap)).TrimEnd("`r", "`n")
  86. if ($keepMap -cne "KEEPMAP") { $failures += "COLLIDE.MAP changed to '$keepMap'" }
  87. $listing = (& $c1541 -attach $disk -list 2>&1) -join "`n"
  88. foreach ($absent in @("abort.prg", "abort.map", "order.prg", "order.map")) {
  89. if ($listing -match ('"' + [regex]::Escape($absent) + '"')) {
  90. $failures += "$absent exists after abort/failure"
  91. }
  92. }
  93. if ($failures) { throw ("output verification failed:`n " + ($failures -join "`n ")) }
  94. # ---------------------------------------------------------- generated run
  95. $run = Start-Nova128X128 -Autostart $prgPath -Port $RunPort
  96. try {
  97. $gmb = Wait-Nova128Mailbox $run -TimeoutSeconds $TimeoutSeconds
  98. } finally {
  99. Stop-Nova128X128 $run
  100. }
  101. if ($gmb[2] -ne 0x03) { throw "generated producer is $($gmb[2]), expected 3" }
  102. if ($gmb[3] -ne 0xA5) { throw "generated program did not report PASS" }
  103. if ($gmb[4] -ne 0 -or $gmb[5] -ne 0) { throw "generated code is $($gmb[4] + 256 * $gmb[5])" }
  104. for ($i = 8; $i -lt 16; $i++) {
  105. if ($gmb[$i] -ne 0) { throw "generated data byte $i is not zero" }
  106. }
  107. Write-Host "verified PRG header, BASIC stub, PAD section, and MAP:"
  108. $expectedMap | ForEach-Object { Write-Host " |$_" }
  109. Write-Host "COLLIDE.PRG/MAP unchanged; ABORT/ORDER left no output"
  110. Write-Host "generated PRG autostarted: producer 3, PASS, code 0"
  111. Write-Host "PRG bytes: $($bytes.Length); screenshots not requested"

Powered by TurnKey Linux.