Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

56 rindas
2.3KB

  1. # E05-S01: run the free-list heap fixture and check its phase flags, R005
  2. # exhaustion fault, and screen output.
  3. [CmdletBinding()]
  4. param([int]$Port = 6547, [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-heap-test.ps1")
  9. $out = Join-Path $project "build\heap-test"
  10. $disk = Join-Path $out "heap-test.d81"
  11. $expected = @(
  12. "NOVA128 HEAP TEST",
  13. "HEAP OK",
  14. "RUNTIME FAULT R005")
  15. $failures = @()
  16. $session = Start-Nova128X128 -Autostart $disk -Drive8Image $disk -Port $Port `
  17. -Screenshot (Join-Path $out "heap-test-vicii.png")
  18. try {
  19. $mb = Wait-Nova128Mailbox $session -TimeoutSeconds $TimeoutSeconds
  20. Start-Sleep -Seconds 1
  21. $screenRam = Read-Nova128Memory $session 0x0400 1000
  22. } finally {
  23. Stop-Nova128X128 $session -SettleSeconds 0
  24. }
  25. if ($mb[2] -ne 0x03) { $failures += ("producer $($mb[2]) expected 3 (generated program)") }
  26. if ($mb[3] -ne 0xFA) { $failures += ("status ${0:X2} expected FA (failure)" -f $mb[3]) }
  27. if ($mb[4] -ne 5 -or $mb[5] -ne 0) { $failures += ("code {0} expected 5 (heap)" -f ($mb[4] + 256 * $mb[5])) }
  28. $addr = $mb[6] + 256 * $mb[7]
  29. if ($addr -ne 0x4000) { $failures += ("address ${0:X4} expected 4000" -f $addr) }
  30. for ($i = 0; $i -lt 8; $i++) {
  31. if ($mb[8 + $i] -ne 1) { $failures += ("heap phase {0} flag is {1}, expected 1" -f ($i + 1), $mb[8 + $i]) }
  32. }
  33. $rows = for ($r = 0; $r -lt 25; $r++) {
  34. $chars = for ($c = 0; $c -lt 40; $c++) {
  35. $code = $screenRam[$r * 40 + $c]
  36. if ($code -le 0x1F) { [char]($code + 0x40) } elseif ($code -le 0x3F) { [char]$code } else { '?' }
  37. }
  38. (-join $chars).TrimEnd()
  39. }
  40. for ($r = 0; $r -lt $expected.Count; $r++) {
  41. if ($rows[$r] -cne $expected[$r]) {
  42. $failures += "screen row ${r}: '$($rows[$r])' expected '$($expected[$r])'"
  43. }
  44. }
  45. if ($failures) { throw ("heap verification failed:`n " + ($failures -join "`n ")) }
  46. Write-Host "screen:"
  47. $rows[0..($expected.Count - 1)] | ForEach-Object { Write-Host " |$_" }
  48. Write-Host ("mailbox: producer 3, status FA, code 5, address {0:X4}, flags 01 01 01 01 01 01 01 01" -f $addr)
  49. Write-Host "verified allocation, zeroing, splitting, coalescing, stress, double-free, corrupt-header detection, and R005 exhaustion"

Powered by TurnKey Linux.