From 2e4d933a81b5b2ae6b0b10d91d03768652cdaed5 Mon Sep 17 00:00:00 2001 From: Hans-Peter Deifel <hpd@hpdeifel.de> Date: Fri, 9 Dec 2016 23:59:08 +0100 Subject: [PATCH] Add one more test for preIdleHook with interrupts --- test/CFG/CSpec.hs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/test/CFG/CSpec.hs b/test/CFG/CSpec.hs index bdf17c6..d9d6305 100644 --- a/test/CFG/CSpec.hs +++ b/test/CFG/CSpec.hs @@ -17,6 +17,7 @@ import CFG.Types spec :: Spec spec = do instrsToCTest + interruptsSpec compileToCTest compileToCAllTest externDecls @@ -127,8 +128,6 @@ instrsToCTest = describe "instrsToC" $ do it "works for a given example" $ runDecision (instrsToC Nothing KindFunction example1Input) `shouldBe` example1Output 0 - interruptsSpec - compileToCTest :: Spec compileToCTest = describe "compileToC" $ do it "works with a function" $ @@ -236,19 +235,25 @@ extern void bar(); interruptsSpec :: Spec -interruptsSpec = - context "with interrupts" $ do +interruptsSpec = do + describe "instrsToC" $ + context "with interrupts" $ do + + it "doesn't trigger interrupts before kickoff" $ + runDecision (instrsToC (Just $ S.fromList [42]) KindFunction [Call "foobar" TypeSyscall True]) + `shouldNotContain'` "interrupt" - it "doesn't trigger interrupts before kickoff" $ - runDecision (instrsToC (Just $ S.fromList [42]) KindFunction [Call "foobar" TypeSyscall True]) - `shouldNotContain'` "interrupt" + it "doesn't trigger interrupts in ISRs" $ + runDecision (instrsToC (Just $ S.fromList [23]) KindISR [Call "foo" TypeSyscall False]) + `shouldNotContain'` "interrupt" - it "doesn't trigger interrupts in ISRs" $ - runDecision (instrsToC (Just $ S.fromList [23]) KindISR [Call "foo" TypeSyscall False]) - `shouldNotContain'` "interrupt" + it "triggers all available interrupts" $ + runDecision (instrsToC (Just $ S.fromList [23, 42]) KindSubtask [Call "foo" TypeSyscall False]) + `shouldSatisfy` (\x -> "23" `T.isInfixOf` x && "42" `T.isInfixOf` x) - it "triggers all available interrupts" $ - runDecision (instrsToC (Just $ S.fromList [23, 42]) KindSubtask [Call "foo" TypeSyscall False]) + describe "preIdleHook" $ + it "triggers all interrupts" $ + runDecision (preIdleHook (Just $ S.fromList [23, 42])) `shouldSatisfy` (\x -> "23" `T.isInfixOf` x && "42" `T.isInfixOf` x) -- GitLab