-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ltl): First stab at an LTL checker
- Loading branch information
1 parent
805b575
commit 8f83625
Showing
20 changed files
with
3,562 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package lib | ||
|
||
import ( | ||
"encoding/json" | ||
"log" | ||
"os" | ||
"os/exec" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
func LtlChecker(testId TestId, runId RunId, formula string) bool { | ||
start := time.Now() | ||
cmd := exec.Command("detsys-ltl", "check", "--testId", strconv.Itoa(testId.TestId), "--runId", strconv.Itoa(runId.RunId), "--formula", formula) | ||
cmd.Stderr = os.Stderr | ||
|
||
out, err := cmd.Output() | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
var result struct { | ||
Result bool `json:"result"` | ||
} | ||
err = json.Unmarshal(out, &result) | ||
elapsed := time.Since(start) | ||
log.Printf("LTL Checker time: %v\n", elapsed) | ||
|
||
return result.Result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Revision history for | ||
|
||
## 0.1.0.0 -- YYYY-mm-dd | ||
|
||
* First version. Released on an unsuspecting world. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Copyright (c) 2021 Symbiont Inc. | ||
|
||
All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
module Main where | ||
|
||
import qualified Data.Aeson as Aeson | ||
import qualified Data.Aeson.Text as AesonText | ||
import qualified Data.Text.Lazy.IO as TextIO | ||
import Options.Generic | ||
|
||
import Ltl | ||
import Ltl.Json | ||
import qualified Ltl.Storage as Storage | ||
import Ltl.Prop.Parser (parse) | ||
|
||
data Config | ||
= Check | ||
{ testId :: Int <?> "Which TestId to test", | ||
runId :: Int <?> "Which RunId to test", | ||
formula :: Text <?> "LTL Formula to check" | ||
} | ||
| Version | ||
deriving (Generic) | ||
|
||
instance ParseRecord Config | ||
|
||
main :: IO () | ||
main = do | ||
(cfg, help) <- getWithHelp "LTL checker" | ||
case cfg of | ||
Version -> putStrLn "<GIT VERSION NOT IMPLEMENTED>" | ||
Check{..} -> do | ||
trace <- Storage.sqliteLoad (unHelpful testId) (unHelpful runId) | ||
testFormula <- case parse (unHelpful formula) of | ||
Left s -> error s | ||
Right x -> pure x | ||
let r = Result $ check testFormula trace | ||
TextIO.putStrLn $ AesonText.encodeToLazyText r | ||
|
||
|
||
data Result = Result | ||
{ result :: Bool | ||
} deriving (Generic) | ||
|
||
instance Aeson.FromJSON Result | ||
instance Aeson.ToJSON Result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
packages: . | ||
|
||
with-compiler: ghc-8.10.3 | ||
|
||
reject-unconstrained-dependencies: all | ||
|
||
constraints: QuickCheck +old-random | ||
|
||
package ldfi | ||
ghc-options: -Wall | ||
|
||
allow-older: * | ||
allow-newer: * |
Oops, something went wrong.