Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

112 wiersze
3.6KB

  1. # E01-S01: execute the platform proof and verify entry, completion, and result.
  2. [CmdletBinding()]
  3. param(
  4. [int]$RemotePort = 6510
  5. )
  6. $ErrorActionPreference = "Stop"
  7. $project = Split-Path $PSScriptRoot -Parent
  8. $build = Join-Path $project "build"
  9. $program = Join-Path $build "minimal.prg"
  10. $traceCommands = Join-Path $project "monitor\minimal-trace.txt"
  11. $monitorLog = Join-Path $build "minimal-monitor.log"
  12. $x128 = "C:\Program Files\GTK3VICE-3.10-win64\bin\x128.exe"
  13. & (Join-Path $PSScriptRoot "build-minimal.ps1")
  14. if ($LASTEXITCODE -ne 0) { throw "minimal build failed" }
  15. if (-not (Test-Path -LiteralPath $x128)) { throw "x128.exe not found at $x128" }
  16. if (Test-Path -LiteralPath $monitorLog) {
  17. Remove-Item -LiteralPath $monitorLog -Force
  18. }
  19. $arguments = @(
  20. "-autostart", ('"' + $program + '"'),
  21. "-autostart-warp", "-warp",
  22. "-sounddev", "dummy",
  23. "-moncommands", ('"' + $traceCommands + '"'),
  24. "-monlog", "-monlogname", ('"' + $monitorLog + '"'),
  25. "-remotemonitor",
  26. "-remotemonitoraddress", ("ip4://127.0.0.1:{0}" -f $RemotePort)
  27. ) -join ' '
  28. $psi = [Diagnostics.ProcessStartInfo]::new()
  29. $psi.FileName = $x128
  30. $psi.Arguments = $arguments
  31. $psi.UseShellExecute = $true
  32. $psi.WindowStyle = [Diagnostics.ProcessWindowStyle]::Hidden
  33. $process = [Diagnostics.Process]::Start($psi)
  34. $client = $null
  35. try {
  36. $deadline = [DateTime]::UtcNow.AddSeconds(10)
  37. while ([DateTime]::UtcNow -lt $deadline) {
  38. if ($process.HasExited) { throw "x128 exited before remote verification" }
  39. try {
  40. $client = [Net.Sockets.TcpClient]::new()
  41. $client.Connect("127.0.0.1", $RemotePort)
  42. break
  43. } catch {
  44. if ($client) { $client.Dispose(); $client = $null }
  45. Start-Sleep -Milliseconds 200
  46. }
  47. }
  48. if (-not $client -or -not $client.Connected) {
  49. throw "could not connect to the VICE remote monitor"
  50. }
  51. # Autostart runs in warp. Give BASIC enough wall time to load, RUN, execute
  52. # the message loop, and return before inspecting the result byte.
  53. Start-Sleep -Seconds 3
  54. $stream = $client.GetStream()
  55. $stream.ReadTimeout = 2000
  56. $writer = [IO.StreamWriter]::new($stream, [Text.Encoding]::ASCII, 1024, $true)
  57. $writer.NewLine = "`n"
  58. $writer.AutoFlush = $true
  59. $writer.WriteLine('m $1c3e $1c3e')
  60. Start-Sleep -Milliseconds 300
  61. $buffer = New-Object byte[] 8192
  62. $response = ""
  63. while ($stream.DataAvailable) {
  64. $count = $stream.Read($buffer, 0, $buffer.Length)
  65. if ($count -le 0) { break }
  66. $response += [Text.Encoding]::ASCII.GetString($buffer, 0, $count)
  67. Start-Sleep -Milliseconds 50
  68. }
  69. if ($response -notmatch '(?i)C:1c3e\s+a5\b') {
  70. throw "minimal_result was not `$A5; monitor response: $response"
  71. }
  72. $writer.WriteLine("q")
  73. $writer.Dispose()
  74. $client.Dispose()
  75. $client = $null
  76. if (-not $process.WaitForExit(5000)) {
  77. throw "x128 did not exit after remote-monitor quit"
  78. }
  79. if (-not (Test-Path -LiteralPath $monitorLog)) {
  80. throw "VICE did not create the monitor trace log"
  81. }
  82. $trace = Get-Content -Raw -LiteralPath $monitorLog
  83. if ($trace -notmatch '(?i)1c0d') {
  84. throw "monitor trace did not record minimal_entry at `$1C0D"
  85. }
  86. if ($trace -notmatch '(?i)1c24') {
  87. throw "monitor trace did not record minimal_done at `$1C24"
  88. }
  89. Write-Host "verified x128 entry `$1C0D, done `$1C24, result `$A5"
  90. Write-Host ("monitor log: {0}" -f $monitorLog)
  91. } finally {
  92. if ($client) { $client.Dispose() }
  93. if ($process -and -not $process.HasExited) {
  94. $process.Kill()
  95. $process.WaitForExit()
  96. }
  97. }

Powered by TurnKey Linux.