From 6a17a3d05108f3bb444770c41d920165ff3d9472 Mon Sep 17 00:00:00 2001 From: Martijn Bastiaan Date: Wed, 19 Feb 2025 13:56:10 +0100 Subject: [PATCH] Rename `Args` to `TestContext` --- clash-vexriscv-sim/tests/Tests/JtagChain.hs | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/clash-vexriscv-sim/tests/Tests/JtagChain.hs b/clash-vexriscv-sim/tests/Tests/JtagChain.hs index 03b9586..f298206 100644 --- a/clash-vexriscv-sim/tests/Tests/JtagChain.hs +++ b/clash-vexriscv-sim/tests/Tests/JtagChain.hs @@ -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 @@ -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 @@ -90,7 +90,7 @@ createArgs = do ensureExists logPathB pure $ - Args + TestContext { vexRiscvProc , openOcdProc , gdbProcA @@ -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 @@ -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 :: @@ -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 @@ -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 @@ -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