Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

91 Zeilen
3.7KB

  1. # E04-S07: compile COUNTER.N8, check deterministic PRG/MAP output, and run the
  2. # generated PRG in x128.
  3. [CmdletBinding()]
  4. param([int]$Port = 6558, [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-counter-test.ps1")
  9. $out = Join-Path $project "build\counter-test"
  10. $disk = Join-Path $out "counter-test.d81"
  11. $failures = @()
  12. $session = Start-Nova128X128 -Autostart $disk -Drive8Image $disk -Port $Port `
  13. -Screenshot (Join-Path $out "counter-compile-vicii.png")
  14. try {
  15. $mb = Wait-Nova128Mailbox $session -TimeoutSeconds $TimeoutSeconds
  16. } finally {
  17. Stop-Nova128X128 $session
  18. }
  19. Write-Host ("mailbox: " + (($mb | ForEach-Object { $_.ToString('X2') }) -join ' '))
  20. if ($mb[2] -ne 0x02) { $failures += ("producer $($mb[2]) expected 2 (compiler)") }
  21. if ($mb[3] -ne 0xA5) {
  22. $failures += ("compiler status {0:X2} failed at stage {1}" -f $mb[3], $mb[4])
  23. }
  24. if ($mb[8] -ne 0) { $failures += "diagnostics present: $($mb[8])" }
  25. if ($mb[9] -ne 0) { $failures += "emitter bad: $($mb[9])" }
  26. if ($mb[10] -eq 0) { $failures += "no generated code" }
  27. if ($mb[11] -ne 0) { $failures += "codegen error: $($mb[11])" }
  28. if ($mb[12] -ne 0) { $failures += "flow error: $($mb[12])" }
  29. if ($mb[13] -ne 0) { $failures += "output error: $($mb[13])" }
  30. if ($mb[14] -ne 0) { $failures += "sizing mismatch count: $($mb[14])" }
  31. $c1541 = Get-ViceTool "c1541"
  32. $prg = Join-Path $out "counter.prg"
  33. $prg2 = Join-Path $out "countb.prg"
  34. $map = Join-Path $out "counter.map"
  35. foreach ($path in @($prg, $prg2, $map)) {
  36. if (Test-Path -LiteralPath $path) { Remove-Item -LiteralPath $path -Force }
  37. }
  38. & $c1541 -attach $disk -read "counter.prg" $prg 2>&1 | Out-Null
  39. & $c1541 -attach $disk -read "countb.prg" $prg2 2>&1 | Out-Null
  40. & $c1541 -attach $disk -read "counter.map,s" $map 2>&1 | Out-Null
  41. foreach ($path in @($prg, $prg2, $map)) {
  42. if (-not (Test-Path -LiteralPath $path)) { $failures += "missing $(Split-Path $path -Leaf)" }
  43. }
  44. if (-not (Test-Path -LiteralPath $prg) -or -not (Test-Path -LiteralPath $prg2)) {
  45. $failures += "cannot check deterministic output"
  46. } else {
  47. $a = [IO.File]::ReadAllBytes($prg)
  48. $b = [IO.File]::ReadAllBytes($prg2)
  49. if ($a.Length -ne $b.Length -or (Compare-Object $a $b)) {
  50. $failures += "two compilations are not byte-identical"
  51. }
  52. if ($a.Length -lt 14 -or $a[0] -ne 0x01 -or $a[1] -ne 0x1C) {
  53. $failures += "COUNTER.PRG does not load at `$1C01"
  54. }
  55. }
  56. $codeSize = ('{0:X4}' -f $mb[10])
  57. $codeStart = '1C4F'
  58. if (Test-Path -LiteralPath $map) {
  59. $text = Get-Content -Raw -LiteralPath $map
  60. foreach ($want in @("ENTRY 1C0D", "SECTION STUB 1C01 000C", "SECTION START 1C0D 0042",
  61. "SECTION CODE $codeStart $codeSize")) {
  62. if ($text -notmatch [regex]::Escape($want)) { $failures += "MAP missing '$want'" }
  63. }
  64. }
  65. $result = -1
  66. if (-not $failures) {
  67. $session = Start-Nova128X128 -Autostart $prg -Port ($Port + 1) `
  68. -Screenshot (Join-Path $out "counter-run-vicii.png")
  69. try {
  70. $rmb = Wait-Nova128Mailbox $session -TimeoutSeconds 60
  71. } finally {
  72. Stop-Nova128X128 $session
  73. }
  74. if ($rmb[2] -ne 0x03) { $failures += ("program producer $($rmb[2]) expected 3") }
  75. if ($rmb[3] -ne 0xA5) { $failures += ("program status {0:X2}" -f $rmb[3]) }
  76. $result = $rmb[8]
  77. if ($result -ne 15) { $failures += "program total $result, expected 15" }
  78. }
  79. if ($failures) { throw ("counter verification failed:`n " + ($failures -join "`n ")) }
  80. Write-Host ("compile: {0} code bytes, deterministic PRG, MAP ENTRY 1C0D / CODE {1}" -f $mb[10], $codeStart)
  81. Write-Host "run: generated COUNTER.PRG reported total=$result"
  82. Write-Host "verified counter.n8 compiles from source and runs in x128"

Powered by TurnKey Linux.