File: Roundtrip.hs

package info (click to toggle)
haskell-ghc-events 0.19.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,396 kB
  • sloc: haskell: 3,552; ansic: 146; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 599 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import Control.Monad
import System.Exit

import GHC.RTS.Events
import GHC.RTS.Events.Incremental
import Utils (files)

-- | Check that an event log round-trips through encoding/decoding.
checkRoundtrip :: FilePath -> IO Bool
checkRoundtrip logFile = do
  putStrLn logFile
  Right eventlog <- readEventLogFromFile logFile
  let Right (roundtripped, _) = readEventLog $ serialiseEventLog eventlog
  if show roundtripped == show eventlog
    then return True
    else putStrLn "bad" >> return False

main :: IO ()
main = do
  successes <- mapM checkRoundtrip files
  unless (and successes) exitFailure