You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
3.1KB

  1. # E02-S01: run the source-reader test in x128 (1581 true drive) and compare
  2. # every result record with the host-computed expectations.
  3. [CmdletBinding()]
  4. param([int]$Port = 6531, [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-source-test.ps1")
  9. $out = Join-Path $project "build\source-test"
  10. $disk = Join-Path $out "source-test.d81"
  11. $screenshot = Join-Path $out "source-test-vicii.png"
  12. $expected = Get-Content -Raw (Join-Path $out "expected.json") | ConvertFrom-Json
  13. $session = Start-Nova128X128 -Autostart $disk -Drive8Image $disk -Port $Port -Screenshot $screenshot
  14. try {
  15. $mb = Wait-Nova128Mailbox $session -TimeoutSeconds $TimeoutSeconds
  16. $count = $mb[8]
  17. $table = $mb[9] + 256 * $mb[10]
  18. if ($count -ne $expected.Count) { throw "program ran $count fixtures, host expects $($expected.Count)" }
  19. $raw = Read-Nova128Memory $session $table (16 * $count)
  20. } finally {
  21. Stop-Nova128X128 $session
  22. }
  23. $failures = @()
  24. for ($i = 0; $i -lt $count; $i++) {
  25. $r = $raw[(16 * $i)..(16 * $i + 15)]
  26. $e = $expected[$i]
  27. $got = [ordered]@{
  28. code = $r[0]; dos = $r[1]; kernal = $r[2]; line = $r[3] + 256 * $r[4]; col = $r[5]
  29. ldtnd = $r[6]; lines = $r[7] + 256 * $r[8]; len = $r[9] + 256 * $r[10]
  30. s1 = $r[11]; s2 = $r[12]; flag = $r[13]; lastline = $r[14] + 256 * $r[15]
  31. }
  32. $problems = @()
  33. if ($got.code -ne $e.code) { $problems += "code $($got.code) expected $($e.code)" }
  34. if ($got.ldtnd -ne 0) { $problems += "$($got.ldtnd) file(s) left open" }
  35. if ($got.flag -ne 1) {
  36. $problems += $(if ($e.code -eq 0) { "passes differ" } else { "source delivered after failure" })
  37. }
  38. if ($e.code -eq 0) {
  39. foreach ($k in "lines", "len", "s1", "s2") {
  40. if ($got[$k] -ne $e.$k) { $problems += "$k $($got[$k]) expected $($e.$k)" }
  41. }
  42. if ($got.lastline -ne $e.lines) { $problems += "src_line_no $($got.lastline) expected $($e.lines)" }
  43. $detail = "{0} lines, {1} bytes, fletcher {2:X2}{3:X2}" -f $got.lines, $got.len, $got.s1, $got.s2
  44. } else {
  45. if ($got.len -ne 0) { $problems += "src_len $($got.len) after failure" }
  46. if ($null -ne $e.line -and ($got.line -ne $e.line -or $got.col -ne $e.col)) {
  47. $problems += "position $($got.line):$($got.col) expected $($e.line):$($e.col)"
  48. }
  49. if ($null -ne $e.dos -and $got.dos -ne $e.dos) { $problems += "DOS $($got.dos) expected $($e.dos)" }
  50. $detail = if ($e.code -eq 1) { "DOS {0}" -f $got.dos } else { "at {0}:{1}" -f $got.line, $got.col }
  51. }
  52. $status = if ($problems) { "FAIL" } else { "ok" }
  53. Write-Host (" {0,-11} code {1} {2,-36} {3}" -f $e.name, $got.code, $detail, $status)
  54. if ($problems) { $failures += "$($e.name): " + ($problems -join "; ") }
  55. }
  56. if ($mb[3] -ne 0xA5) { $failures += ("C128 reported FAIL ({0} fixture(s))" -f $mb[4]) }
  57. if ($failures) { throw ("source-reader verification failed:`n " + ($failures -join "`n ")) }
  58. Write-Host "verified source reader: $count fixtures match host expectations"
  59. Write-Host "screenshot: $screenshot"

Powered by TurnKey Linux.