Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scenario verifier test #413

Merged
merged 13 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,12 @@ __pycache__/
*$py.class
/external_tester/venv/

*.ci-friendly-pom.xml
*.ci-friendly-pom.xml
.metals/metals.mv.db
.bloop/ast-test.json
.bloop/ast.json
.bloop/bloop.settings.json
.bloop/core-test.json
.bloop/core.json
.bloop/root-test.json
.bloop/root.json
10 changes: 5 additions & 5 deletions external_tester/maestro_cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def cliGenerateAlgorithmFromMultiModel():

with open(multiModelPath, "w+") as jsonFile:
json.dump(multiModel, jsonFile)

cmd = "java -jar {0} sigver generate-algorithm {1} -output {2}".format(path, multiModelPath, temporary)
func = lambda: print("Succesfully generated algorithm from multi model") if(os.path.exists(os.path.join(temporary, "algorithm.conf"))) else lambda: (Exception("Algorithm was not returned"))
testutils.testCliCommandWithFunc(cmd, func)
Expand Down Expand Up @@ -188,10 +188,10 @@ def cliExecuteAlgorithmFromMasterModel():
SCR_path = "scenario_controller_resources"

print("Testing CLI of: " + path)
cliRaw()
cliSpecGen()
cliExpansion()
cliExportCpp(args.includeSlowTests)
# cliRaw()
# cliSpecGen()
# cliExpansion()
# cliExportCpp(args.includeSlowTests)
cliGenerateAlgorithmFromScenario()
cliGenerateAlgorithmFromMultiModel()
cliExecuteAlgorithmFromExtendedMultiModel()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
name = generatedFromMultiModel\nscenario = {\nfmus = {\nFMU_roller = { \n can-reject-step = true,\n inputs = {\nvalve = {reactivity=delayed}},\n outputs = {\nlevel = {dependencies-init=[valve], dependencies=[valve]}}\n }\nController_cont = { \n can-reject-step = true,\n inputs = {\nlevel = {reactivity=delayed}},\n outputs = {\n}\n }}\nconnections = [\n"FMU_roller.level" -> "Controller_cont.level"]\n}\ninitialization = [\n\n{set: "FMU_roller.valve"}\n\n{get: "FMU_roller.level"}\n\n{set: "Controller_cont.level"}\n\n\n]\ncosim-step = {conf1 = [{save-state: Controller_cont}\n\n{save-state: FMU_roller}\n\n{loop: { \n until-step-accept: [Controller_cont,FMU_roller] \n iterate: [{step: Controller_cont }\n\n{step: FMU_roller }\n] \n if-retry-needed: [{restore-state: Controller_cont}\n\n{restore-state: FMU_roller}\n]} \n }\n\n{set: "FMU_roller.valve"}\n\n{get: "FMU_roller.level"}\n\n{set: "Controller_cont.level"}\n]\n}
name = generatedFromMultiModel\nscenario = {\n \n fmus = {\n FMU_roller = \n {\n can-reject-step = true,\n inputs = {\n \n },\n outputs = {\n level = {dependencies-init=[], dependencies=[]}\n }\n }\nController_cont = \n {\n can-reject-step = true,\n inputs = {\n level = {reactivity=delayed}\n },\n outputs = {\n \n }\n }\n }\n connections = [ \"FMU_roller.level\" -> \"Controller_cont.level\"]\n\n}\ninitialization = [ {get: \"FMU_roller.level\"}\n {set: \"Controller_cont.level\"}]\ncosim-step = { conf1 =\n [ {save-state: Controller_cont}\n {save-state: FMU_roller}\n {\n loop: {\n until-step-accept: [Controller_cont,FMU_roller]\n iterate: [ {step: Controller_cont }\n {step: FMU_roller }]\n if-retry-needed: [ {restore-state: Controller_cont}, {restore-state: FMU_roller}]\n }\n }\n \n {get: \"FMU_roller.level\"}\n {set: \"Controller_cont.level\"}]\n }\n
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"sigver": {
"reactivity": {
"{Controller}.cont.level": "Delayed"
},
"verification": false
}
}
}
Original file line number Diff line number Diff line change
@@ -1,114 +1,106 @@
name = Example master that has a loop within a loop
scenario = {
fmus = {
msd3 = {
can-reject-step = true,
inputs = {
z = {reactivity=delayed}},
outputs = {
G = {dependencies-init=[z], dependencies=[z]}}
}
msd2 = {
can-reject-step = true,
inputs = {
v1 = {reactivity=reactive}
x1 = {reactivity=delayed}
G = {reactivity=reactive}},
outputs = {
fk = {dependencies-init=[x1,v1], dependencies=[x1,v1]}
z = {dependencies-init=[], dependencies=[]}}
}
msd1 = {
can-reject-step = true,
inputs = {
fk = {reactivity=reactive}},
outputs = {
x1 = {dependencies-init=[], dependencies=[]}
v1 = {dependencies-init=[], dependencies=[]}}
}}
connections = [
"msd1.x1" -> "msd2.x1"
"msd1.v1" -> "msd2.v1"
"msd2.fk" -> "msd1.fk"
"msd2.z" -> "msd3.z"
"msd3.G" -> "msd2.G"]
fmus = {
msd3 =
{
can-reject-step = true,
inputs = {
z = {reactivity=delayed}
},
outputs = {
G = {dependencies-init=[z], dependencies=[z]}
}
}
msd2 =
{
can-reject-step = true,
inputs = {
v1 = {reactivity=reactive}
x1 = {reactivity=delayed}
G = {reactivity=reactive}
},
outputs = {
fk = {dependencies-init=[x1,v1], dependencies=[x1,v1]}
z = {dependencies-init=[], dependencies=[]}
}
}
msd1 =
{
can-reject-step = true,
inputs = {
fk = {reactivity=reactive}
},
outputs = {
x1 = {dependencies-init=[], dependencies=[]}
v1 = {dependencies-init=[], dependencies=[]}
}
}
}
connections = [
"msd1.x1" -> "msd2.x1",
"msd1.v1" -> "msd2.v1",
"msd2.fk" -> "msd1.fk",
"msd2.z" -> "msd3.z",
"msd3.G" -> "msd2.G"
]
}
initialization = [


{get: "msd1.x1"}

{set: "msd2.x1"}

{get: "msd2.z"}

{set: "msd3.z"}

{get: "msd1.v1"}

{set: "msd2.v1"}

{get: "msd2.fk"}

{set: "msd1.fk"}

{get: "msd3.G"}

{set: "msd2.G"}



]
cosim-step = {conf1 = [{save-state: msd2}

{save-state: msd1}

{save-state: msd3}

{loop: {
until-step-accept: [msd2,msd1,msd3]
iterate: [{loop: {
until-converged: ["msd3.G","msd2.fk","msd2.z","msd1.x1","msd1.v1"]
iterate: [{set: "msd2.G"}

{step: msd3 }

{set: "msd3.z"}

{get-tentative: "msd3.G"}

{set: "msd1.fk"}

{step: msd1 }

{get-tentative: "msd1.v1"}

{get-tentative: "msd1.x1"}

{set: "msd2.v1"}

{step: msd2 }

{set: "msd2.x1"}

{get-tentative: "msd2.fk"}

{get-tentative: "msd2.z"}
]
if-retry-needed: [{restore-state: msd3}

{restore-state: msd2}

{restore-state: msd1}
]}
}
]
if-retry-needed: [{restore-state: msd2}

{restore-state: msd1}

{restore-state: msd3}
]}
}
]
initialization = [
{get: "msd2.z"}
{set: "msd3.z"}
{get: "msd3.G"}
{set: "msd2.G"}
{get: "msd1.v1"}
{set: "msd2.v1"}
{get: "msd1.x1"}
{set: "msd2.x1"}
{get: "msd2.fk"}
{set: "msd1.fk"}
]
cosim-step =
{
conf1 =
[
{save-state: msd2}
{save-state: msd1}
{save-state: msd3}
{
loop: {
until-step-accept: [msd2,msd1,msd3]
iterate: [
{
loop: {
until-converged: ["msd3.G","msd2.fk","msd2.z","msd1.x1","msd1.v1"]
iterate: [
{step: msd3 }
{set: "msd2.G"}
{set: "msd1.fk"}
{step: msd1 }
{get-tentative: "msd1.v1"}
{set: "msd2.v1"}
{step: msd2 }
{get-tentative: "msd1.x1"}
{set-tentative: "msd2.x1"}
{get-tentative: "msd2.fk"}
{get-tentative: "msd2.z"}
{set-tentative: "msd3.z"}
{get-tentative: "msd3.G"}
]
if-retry-needed:
[
{restore-state: msd3},
{restore-state: msd2},
{restore-state: msd1}
]
}
}
]
if-retry-needed:
[
{restore-state: msd2},
{restore-state: msd1},
{restore-state: msd3}
]
}
}
]
}
23 changes: 21 additions & 2 deletions external_tester/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import subprocess
from threading import Thread
import time
import string

TempDirectoryData = namedtuple('TempDirectoryData', 'dirPath initializationPath resultPath mablSpecPath')

Expand Down Expand Up @@ -69,15 +70,33 @@ def compareCSV(expected, actual):
else:
print(f"ERROR: {expected} doest not exist!")
return False

def comparText(file1, file2):
expectedFile = open(file1, 'r')
actualFile = open(file2, 'r')
remove = str.maketrans('', '', string.whitespace)
expectedLines = expectedFile.readlines()
actualLines = actualFile.readlines()
expectedLines = "".join(expectedLines).translate(remove)
actualLines = "".join(actualLines).translate(remove)
expectedFile.close()
actualFile.close()

return expectedLines == actualLines

def compare(strPrefix, expected, actual):
if os.path.exists(expected):
convert(expected)

compareResult = filecmp.cmp(expected, actual)
if not compareResult:
print("ERROR: {}: Files {} and {} do not match".format(strPrefix, expected, actual))
return False
compareRes = comparText(expected, actual)
if not compareRes:
print("ERROR: {}: Files {} and {} do not match".format(strPrefix, expected, actual))
return False
else:
print("%s: Files match" % strPrefix)
return True
else:
print("%s: Files match" % strPrefix)
return True
Expand Down
2 changes: 2 additions & 0 deletions external_tester/webapi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ def testScenarioController(basicUrl):
f.write(response.text)

if(not testutils.compare("Generate from scenario", expectedResult, actualResult)):
print("ERROR: actual and expected algorithm do not match")
print("Actual:" + response.text)
raise Exception("Expected algorithm does not match the actual algorithm.")

#Test generate algorithm from multi model
Expand Down
2 changes: 1 addition & 1 deletion frameworks/fmi2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<dependency>
<groupId>org.into-cps.vdmcheck.fmi2</groupId>
<artifactId>vdmcheck2</artifactId>
<version>1.1.1</version>
<version>1.1.3-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
Expand Down
4 changes: 2 additions & 2 deletions maestro-webapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<version>3.11</version>
</dependency>
<dependency>
<groupId>INTO-CPS-Association</groupId>
<artifactId>scenario_verifier_2.13</artifactId>
<groupId>org.into-cps.verification</groupId>
<artifactId>scenario_verifier</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.spencerwi.either.Either;
import core.MasterModel;
import core.ScenarioLoader;
import org.intocps.verification.scenarioverifier.core.MasterModel;
import org.intocps.verification.scenarioverifier.core.ScenarioLoader;
import org.apache.commons.lang3.tuple.Pair;
import org.intocps.maestro.Mabl;
import org.intocps.maestro.ast.LexIdentifier;
Expand Down
Loading
Loading