mirror of
https://github.com/GaloisInc/macaw.git
synced 2024-11-26 09:22:20 +03:00
37 lines
1.2 KiB
Haskell
37 lines
1.2 KiB
Haskell
module MismatchTests where
|
|
|
|
|
|
import Control.Monad.Catch
|
|
import qualified Data.ElfEdit as E
|
|
import Data.Monoid
|
|
import Shared
|
|
import Test.Tasty
|
|
import Test.Tasty.HUnit
|
|
|
|
import Prelude
|
|
|
|
|
|
armMismatchTests :: [FilePath] -> TestTree
|
|
armMismatchTests badBinList =
|
|
testGroup "ARM Mismatch Tests"
|
|
[ testGroup "BAD binaries" $ map testCorruptElf badBinList
|
|
]
|
|
|
|
testCorruptElf :: FilePath -> TestTree
|
|
testCorruptElf fpath =
|
|
testCase fpath $
|
|
catch (withELF fpath
|
|
(\e -> do let (warn, _el) = E.getElf e
|
|
flip assertBool (not (null warn)) $
|
|
"ELF read of " ++ fpath ++ " should have failed."))
|
|
(\e -> case e of
|
|
ElfHeaderParseError _ _ _ -> return () -- tr '\0' '8' test-just-exit.exe
|
|
ElfParseError _ _ -> return () -- tr '\05' '8' test-just-exit.exe
|
|
other -> assertFailure $ "Unexpected exception: " <> show other)
|
|
|
|
|
|
{-
|
|
$ cat test-just-exit.exe | tr '\034' '8' > test-just-exit8.exe=bad
|
|
== Result throws "error" instead of returning an parse failure.
|
|
-}
|