25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
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. $c1541 = Get-ViceTool "c1541"
  31. $prg = Join-Path $out "counter.prg"
  32. $prg2 = Join-Path $out "countb.prg"
  33. $map = Join-Path $out "counter.map"
  34. foreach ($path in @($prg, $prg2, $map)) {
  35. if (Test-Path -LiteralPath $path) { Remove-Item -LiteralPath $path -Force }
  36. }
  37. & $c1541 -attach $disk -read "counter.prg" $prg 2>&1 | Out-Null
  38. & $c1541 -attach $disk -read "countb.prg" $prg2 2>&1 | Out-Null
  39. & $c1541 -attach $disk -read "counter.map,s" $map 2>&1 | Out-Null
  40. foreach ($path in @($prg, $prg2, $map)) {
  41. if (-not (Test-Path -LiteralPath $path)) { $failures += "missing $(Split-Path $path -Leaf)" }
  42. }
  43. if (-not (Test-Path -LiteralPath $prg) -or -not (Test-Path -LiteralPath $prg2)) {
  44. $failures += "cannot check deterministic output"
  45. } else {
  46. $a = [IO.File]::ReadAllBytes($prg)
  47. $b = [IO.File]::ReadAllBytes($prg2)
  48. if ($a.Length -ne $b.Length -or (Compare-Object $a $b)) {
  49. $failures += "two compilations are not byte-identical"
  50. }
  51. if ($a.Length -lt 14 -or $a[0] -ne 0x01 -or $a[1] -ne 0x1C) {
  52. $failures += "COUNTER.PRG does not load at `$1C01"
  53. }
  54. }
  55. $codeSize = ('{0:X4}' -f $mb[10])
  56. $codeStart = '1C4F'
  57. if (Test-Path -LiteralPath $map) {
  58. $text = Get-Content -Raw -LiteralPath $map
  59. foreach ($want in @("ENTRY 1C0D", "SECTION STUB 1C01 000C", "SECTION START 1C0D 0042",
  60. "SECTION CODE $codeStart $codeSize")) {
  61. if ($text -notmatch [regex]::Escape($want)) { $failures += "MAP missing '$want'" }
  62. }
  63. }
  64. $result = -1
  65. if (-not $failures) {
  66. $session = Start-Nova128X128 -Autostart $prg -Port ($Port + 1) `
  67. -Screenshot (Join-Path $out "counter-run-vicii.png")
  68. try {
  69. $rmb = Wait-Nova128Mailbox $session -TimeoutSeconds 60
  70. } finally {
  71. Stop-Nova128X128 $session
  72. }
  73. if ($rmb[2] -ne 0x03) { $failures += ("program producer $($rmb[2]) expected 3") }
  74. if ($rmb[3] -ne 0xA5) { $failures += ("program status {0:X2}" -f $rmb[3]) }
  75. $result = $rmb[8]
  76. if ($result -ne 15) { $failures += "program total $result, expected 15" }
  77. }
  78. if ($failures) { throw ("counter verification failed:`n " + ($failures -join "`n ")) }
  79. Write-Host ("compile: {0} code bytes, deterministic PRG, MAP ENTRY 1C0D / CODE {1}" -f $mb[10], $codeStart)
  80. Write-Host "run: generated COUNTER.PRG reported total=$result"
  81. Write-Host "verified counter.n8 compiles from source and runs in x128"

Powered by TurnKey Linux.