Skip to content

Commit

Permalink
Rename Args to TestContext
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnbastiaan committed Feb 19, 2025
1 parent e5ece96 commit 6a17a3d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions clash-vexriscv-sim/tests/Tests/JtagChain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ getSimulateExecPath = cabalListBin "clash-vexriscv-sim:clash-vexriscv-chain-bin"
getProjectRoot :: IO FilePath
getProjectRoot = findParentContaining cabalProject

data Args = Args
data TestContext = TestContext
{ vexRiscvProc :: CreateProcess
, openOcdProc :: CreateProcess
, gdbProcA :: CreateProcess
Expand All @@ -42,8 +42,8 @@ data Args = Args
, logPathB :: FilePath
}

createArgs :: IO Args
createArgs = do
createTestContext :: IO TestContext
createTestContext = do
simulateExecPath <- getSimulateExecPath
projectRoot <- getProjectRoot
gdb <- getGdb
Expand Down Expand Up @@ -90,7 +90,7 @@ createArgs = do
ensureExists logPathB

pure $
Args
TestContext
{ vexRiscvProc
, openOcdProc
, gdbProcA
Expand All @@ -114,7 +114,7 @@ testBoth debug = do
waitForLine :: (HasCallStack) => Bool -> Handle -> String -> Assertion
waitForLine = waitForLineOrTimeout 120_000_000

Args{vexRiscvProc, openOcdProc, gdbProcA, gdbProcB, logPathA, logPathB} <- createArgs
TestContext{vexRiscvProc, openOcdProc, gdbProcA, gdbProcB, logPathA, logPathB} <- createTestContext

withStreamingFiles (logPathA :> logPathB :> Nil) $ \(vecToTuple -> (logA, logB)) -> do
withCreateProcess vexRiscvProc $ \_ (fromJust -> simStdOut) _ _ -> do
Expand Down Expand Up @@ -153,10 +153,10 @@ withStreamingFiles paths f = go (toList paths) []
go (p : ps) hs = withStreamingFile p (\h -> go ps (h : hs))

addArgs :: CreateProcess -> [String] -> CreateProcess
addArgs cp newArgs = cp{cmdspec = addArgsCmdSpec (cmdspec cp)}
addArgs cp newTestContext = cp{cmdspec = addArgsCmdSpec (cmdspec cp)}
where
addArgsCmdSpec (RawCommand cmd args) = RawCommand cmd (args <> newArgs)
addArgsCmdSpec (ShellCommand cmd) = ShellCommand (cmd <> " " <> unwords newArgs)
addArgsCmdSpec (RawCommand cmd args) = RawCommand cmd (args <> newTestContext)
addArgsCmdSpec (ShellCommand cmd) = ShellCommand (cmd <> " " <> unwords newTestContext)

-- | Test that we can communicate with CPU B when CPU A is held in reset.
testInResetA ::
Expand All @@ -165,7 +165,7 @@ testInResetA ::
Bool ->
Assertion
testInResetA debug = do
Args{vexRiscvProc, openOcdProc, gdbProcB, logPathB} <- createArgs
TestContext{vexRiscvProc, openOcdProc, gdbProcB, logPathB} <- createTestContext

let
-- Timeout after 240 seconds. These tests are extremely slow, because a lot
Expand Down Expand Up @@ -208,7 +208,7 @@ testResetDeassertion ::
Bool ->
Assertion
testResetDeassertion debug = do
Args{vexRiscvProc, openOcdProc, gdbProcB, gdbProcA, logPathA, logPathB} <- createArgs
TestContext{vexRiscvProc, openOcdProc, gdbProcB, gdbProcA, logPathA, logPathB} <- createTestContext

let
-- Timeout after 120 seconds. Warning: removing the type signature breaks
Expand Down Expand Up @@ -256,7 +256,7 @@ testResetAssertion ::
Bool ->
Assertion
testResetAssertion debug = do
Args{vexRiscvProc, openOcdProc, gdbProcA, gdbProcB, logPathA, logPathB} <- createArgs
TestContext{vexRiscvProc, openOcdProc, gdbProcA, gdbProcB, logPathA, logPathB} <- createTestContext

let
-- Timeout after 120 seconds. Warning: removing the type signature breaks
Expand Down

0 comments on commit 6a17a3d

Please sign in to comment.