Skip to content

Commit

Permalink
🐛 Trying to fix CI build failure that cannot be reproduced locally
Browse files Browse the repository at this point in the history
  • Loading branch information
lsrcz committed Sep 5, 2024
1 parent 59396ba commit a29816b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Grisette/Internal/SymPrim/Prim/Internal/Term.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2151,9 +2151,10 @@ instance (SupportedPrim t) => Eq (Term t) where
if threadId a == threadId b
then identity a == identity b
else unsafePerformIO $ do
a' <- fullReconstructTerm a
b' <- fullReconstructTerm b
return $ identity a' == identity b'
tid <- myWeakThreadId
a' <- toCurThreadImpl tid a
b' <- toCurThreadImpl tid b
return $ a' == b'

instance (SupportedPrim t) => Hashable (Term t) where
hashWithSalt s t = hashWithSalt s $ baseHash t
Expand Down
21 changes: 19 additions & 2 deletions test/Grisette/SymPrim/Prim/ConcurrentTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Control.DeepSeq (force)
import Control.Exception (evaluate)
import Data.Hashable (Hashable (hash))
import Data.String (IsString (fromString))
import Grisette (SymInteger (SymInteger))
import Grisette (SymEq ((.==)), SymInteger (SymInteger), evalSymToCon, solve, z3)
import Test.Framework (Test, testGroup)
import Test.Framework.Providers.HUnit (testCase)
import Test.HUnit ((@?=))
Expand All @@ -31,5 +31,22 @@ concurrentTests =
putMVar bref p
br <- takeMVar bref
ar @?= br
hash ar @?= hash br
hash ar @?= hash br,
testCase "Eval" $ do
aref <- newEmptyMVar
bref <- newEmptyMVar
_ <- forkIO $ do
a <- evaluate $ force ("a" :: SymInteger)
putMVar aref a
_ <- forkIO $ do
b <- evaluate $ force ("b" :: SymInteger)
putMVar bref b
a@(SymInteger ta) <- takeMVar aref
b@(SymInteger tb) <- takeMVar bref
r <- solve z3 $ a .== b
print ta
print tb
case r of
Left err -> error $ show err
Right m -> evalSymToCon m a @?= (evalSymToCon m b :: Integer)
]

0 comments on commit a29816b

Please sign in to comment.