Skip to content

Commit

Permalink
fixup! Add reset assertion test
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnbastiaan committed Feb 19, 2025
1 parent de525d0 commit 87db7aa
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion clash-vexriscv-sim/tests/Tests/JtagChain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Test.Tasty.HUnit (Assertion, testCase, (@=?))
import Test.Tasty.Options (OptionDescription (Option))
import Prelude

import Control.Concurrent (threadDelay)
import Tests.Jtag (JtagDebug (JtagDebug), cabalListBin, expectLineOrTimeout, getGdb, waitForLineOrTimeout)
import Utils.FilePath (BuildType (Debug), cabalProject, findParentContaining, rustBinsDir)

Expand Down Expand Up @@ -309,13 +310,22 @@ testResetAssertion debug = do
waitForLine debug openOcdStdErr "Info : dropped 'gdb' connection"
waitForLine debug openOcdStdErr "Info : dropped 'gdb' connection"

-- Give processes some time to think about what they've done.
threadDelay 10_000_000

withCreateProcess gdbProcA $ \_ _ _ gdbProcHandleA -> do
waitForLine debug openOcdStdErr "riscv.cpu0 halted due to debug-request."

-- XXX: This _might_ still get residue from the previous GDB session. To
-- make this test more trustworthy, we should add a way to "flush"
-- the log. Alternatively, we can load a different binary.
waitForLine debug logA "[CPU] a" -- first load

-- XXX: We don't wait for the first "a" to appear, because we might have
-- interrupted a write line with the reset. This may have caused
-- partial lines to have been written, in turn making us read something
-- like "[CP[CPU] a" instead of "[CPU] a".
-- waitForLine debug logA "[CPU] a" -- first load

waitForLine debug logA "[CPU] a" -- breakpoint
waitForLine debug logA "[CPU] b" -- new binary loaded
gdbAExitCode <- waitForProcess gdbProcHandleA
Expand Down

0 comments on commit 87db7aa

Please sign in to comment.