Skip to content

Commit 057d45e

Browse files
committed
Merge pull request #8 from lochel/testing
Add test scripts for OpenModelica
2 parents 57999d5 + da28e35 commit 057d45e

23 files changed

+1576
-0
lines changed

Testing/OpenModelica/Makefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
TEST = rtest -v
2+
3+
TESTFILES = \
4+
PNlib.Examples.ConTest.LoopAndArcweight.mos \
5+
PNlib.Examples.ConTest.PCtoTC.mos \
6+
PNlib.Examples.ConTest.SinglePC.mos \
7+
PNlib.Examples.ConTest.SingleTC.mos \
8+
PNlib.Examples.ConTest.Speed.mos \
9+
PNlib.Examples.ConTest.TCtoPC.mos \
10+
PNlib.Examples.ConTest.ZeroPlace.mos \
11+
PNlib.Examples.DisTest.ConflictPrio.mos \
12+
PNlib.Examples.DisTest.DisLoopAndArcweight.mos \
13+
PNlib.Examples.DisTest.InputConflictPrio.mos \
14+
PNlib.Examples.DisTest.OutputConflictPrio.mos \
15+
PNlib.Examples.DisTest.PDtoTD.mos \
16+
PNlib.Examples.DisTest.SinglePD.mos \
17+
PNlib.Examples.DisTest.SingleTD.mos \
18+
PNlib.Examples.DisTest.TDtoPD.mos \
19+
20+
# test that currently fail. Move up when fixed.
21+
# Run make failingtest
22+
FAILINGTESTFILES = \
23+
PNlib.Examples.ConTest.Conflict.mos \
24+
PNlib.Examples.ConTest.ConflictLoop.mos \
25+
PNlib.Examples.DisTest.ConflictProb.mos \
26+
PNlib.Examples.DisTest.InputConflictProb.mos \
27+
PNlib.Examples.DisTest.OutputConflictProb.mos \
28+
PNlib.Examples.DisTest.SixConflictProb.mos \
29+
30+
# Dependency files that are not .mo .mos or Makefile
31+
# Add them here or they will be cleaned.
32+
DEPENDENCIES = \
33+
*.mos \
34+
Makefile \
35+
rtest \
36+
37+
CLEAN = `ls | grep -w -v -f deps.tmp`
38+
39+
.PHONY : test clean getdeps failingtest
40+
41+
test:
42+
@echo
43+
@echo Running tests...
44+
@echo
45+
@echo OPENMODELICAHOME=" $(OPENMODELICAHOME) "
46+
@$(TEST) $(TESTFILES)
47+
48+
# Cleans all files that are not listed as dependencies
49+
clean:
50+
@echo $(DEPENDENCIES) | sed 's/ /\\|/g' > deps.tmp
51+
@rm -f $(CLEAN)
52+
53+
# Run this if you want to list out the files (dependencies).
54+
# do it after cleaning and updating the folder
55+
# then you can get a list of file names (which must be dependencies
56+
# since you got them from repository + your own new files)
57+
# then add them to the DEPENDENCIES. You can find the
58+
# list in deps.txt
59+
getdeps:
60+
@echo $(DEPENDENCIES) | sed 's/ /\\|/g' > deps.tmp
61+
@echo $(CLEAN) | sed -r 's/deps.txt|deps.tmp//g' | sed 's/ / \\\n/g' > deps.txt
62+
@echo Dependency list saved in deps.txt.
63+
@echo Copy the list from deps.txt and add it to the Makefile @DEPENDENCIES
64+
65+
failingtest:
66+
@echo
67+
@echo Running failing tests...
68+
@echo
69+
@$(TEST) $(FAILINGTESTFILES)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// name: PNlib.Examples.ConTest.Conflict
2+
// keywords: PNlib, continuous
3+
// status: correct
4+
5+
loadFile("../../PNlib/package.mo"); getErrorString();
6+
simulate(PNlib.Examples.ConTest.Conflict); getErrorString();
7+
res := OpenModelica.Scripting.compareSimulationResults("PNlib.Examples.ConTest.Conflict_res.mat",
8+
"../../ReferenceFiles/PNlib.Examples.ConTest.Conflict.mat",
9+
"PNlib.Examples.ConTest.Conflict_diff.csv", 0.01, 0.0001,
10+
{
11+
"P1.t",
12+
"P2.t",
13+
"P3.t",
14+
"T1.fire",
15+
"T1.instantaneousSpeed",
16+
"T1.maximumSpeed",
17+
"T2.fire",
18+
"T2.instantaneousSpeed",
19+
"T2.maximumSpeed",
20+
"T3.fire",
21+
"T3.instantaneousSpeed",
22+
"T3.maximumSpeed"
23+
}); getErrorString();
24+
25+
// Result:
26+
// true
27+
// "Notification: Automatically loaded package Modelica 3.2.1 due to uses annotation.
28+
// Notification: Automatically loaded package Complex 3.2.1 due to uses annotation.
29+
// Notification: Automatically loaded package ModelicaServices 3.2.1 due to uses annotation.
30+
// "
31+
// record SimulationResult
32+
// resultFile = "",
33+
// simulationOptions = "startTime = 0.0, stopTime = 10.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'PNlib.Examples.ConTest.Conflict', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
34+
// messages = "Simulation execution failed for model: PNlib.Examples.ConTest.Conflict
35+
// assert | debug | No system for the symbolic initialization was generated.
36+
// assert | info | simulation terminated by an assertion at initialization
37+
// "
38+
// end SimulationResult;
39+
// "[PNlib/PNlib/Blocks/enablingInCon.mo:34:7-98:13:writable] Warning: In component P1.enableIn, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
40+
// [PNlib/PNlib/Blocks/enablingInCon.mo:41:13-44:19:writable] Warning: In component P1.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
41+
// [PNlib/PNlib/Blocks/enablingInCon.mo:78:13-81:19:writable] Warning: In component P1.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
42+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:37:5-101:13:writable] Warning: In component P1.enableOut, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
43+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:44:11-47:17:writable] Warning: In component P1.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
44+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:81:11-84:17:writable] Warning: In component P1.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
45+
// [PNlib/PNlib/Blocks/enablingInCon.mo:34:7-98:13:writable] Warning: In component P2.enableIn, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
46+
// [PNlib/PNlib/Blocks/enablingInCon.mo:41:13-44:19:writable] Warning: In component P2.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
47+
// [PNlib/PNlib/Blocks/enablingInCon.mo:78:13-81:19:writable] Warning: In component P2.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
48+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:37:5-101:13:writable] Warning: In component P2.enableOut, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
49+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:81:11-84:17:writable] Warning: In component P2.enableOut, in relation {}[i] == 0.0, == on Real numbers is only allowed inside functions.
50+
// [PNlib/PNlib/Blocks/enablingInCon.mo:34:7-98:13:writable] Warning: In component P3.enableIn, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
51+
// [PNlib/PNlib/Blocks/enablingInCon.mo:41:13-44:19:writable] Warning: In component P3.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
52+
// [PNlib/PNlib/Blocks/enablingInCon.mo:78:13-81:19:writable] Warning: In component P3.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
53+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:37:5-101:13:writable] Warning: In component P3.enableOut, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
54+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:81:11-84:17:writable] Warning: In component P3.enableOut, in relation {}[i] == 0.0, == on Real numbers is only allowed inside functions.
55+
// Notification: The given system is mixed-determined. [index > 0]
56+
// Notification: The given system is mixed-determined. [index > 1]
57+
// Notification: The given system is mixed-determined. [index > 2]
58+
// Notification: The given system is mixed-determined. [index > 3]
59+
// Error: No system for the symbolic initialization was generated.
60+
// "
61+
// {"Error get time!"}
62+
// ""
63+
// endResult
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// name: PNlib.Examples.ConTest.ConflictLoop
2+
// keywords: PNlib, continuous
3+
// status: correct
4+
5+
loadFile("../../PNlib/package.mo"); getErrorString();
6+
simulate(PNlib.Examples.ConTest.ConflictLoop); getErrorString();
7+
res := OpenModelica.Scripting.compareSimulationResults("PNlib.Examples.ConTest.ConflictLoop_res.mat",
8+
"../../ReferenceFiles/PNlib.Examples.ConTest.ConflictLoop.mat",
9+
"PNlib.Examples.ConTest.ConflictLoop_diff.csv", 0.01, 0.0001,
10+
{
11+
"P1.t",
12+
"P2.t",
13+
"P3.t",
14+
"T1.fire",
15+
"T1.instantaneousSpeed",
16+
"T1.maximumSpeed",
17+
"T2.fire",
18+
"T2.instantaneousSpeed",
19+
"T2.maximumSpeed",
20+
"T3.fire",
21+
"T3.instantaneousSpeed",
22+
"T3.maximumSpeed"
23+
}); getErrorString();
24+
25+
// Result:
26+
// true
27+
// "Notification: Automatically loaded package Modelica 3.2.1 due to uses annotation.
28+
// Notification: Automatically loaded package Complex 3.2.1 due to uses annotation.
29+
// Notification: Automatically loaded package ModelicaServices 3.2.1 due to uses annotation.
30+
// "
31+
// record SimulationResult
32+
// resultFile = "",
33+
// simulationOptions = "startTime = 0.0, stopTime = 10.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'PNlib.Examples.ConTest.ConflictLoop', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
34+
// messages = "Simulation execution failed for model: PNlib.Examples.ConTest.ConflictLoop
35+
// assert | debug | No system for the symbolic initialization was generated.
36+
// assert | info | simulation terminated by an assertion at initialization
37+
// "
38+
// end SimulationResult;
39+
// "[PNlib/PNlib/Blocks/enablingInCon.mo:34:7-98:13:writable] Warning: In component P1.enableIn, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
40+
// [PNlib/PNlib/Blocks/enablingInCon.mo:41:13-44:19:writable] Warning: In component P1.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
41+
// [PNlib/PNlib/Blocks/enablingInCon.mo:78:13-81:19:writable] Warning: In component P1.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
42+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:37:5-101:13:writable] Warning: In component P1.enableOut, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
43+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:44:11-47:17:writable] Warning: In component P1.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
44+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:81:11-84:17:writable] Warning: In component P1.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
45+
// [PNlib/PNlib/Blocks/enablingInCon.mo:34:7-98:13:writable] Warning: In component P2.enableIn, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
46+
// [PNlib/PNlib/Blocks/enablingInCon.mo:41:13-44:19:writable] Warning: In component P2.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
47+
// [PNlib/PNlib/Blocks/enablingInCon.mo:78:13-81:19:writable] Warning: In component P2.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
48+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:37:5-101:13:writable] Warning: In component P2.enableOut, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
49+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:44:11-47:17:writable] Warning: In component P2.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
50+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:81:11-84:17:writable] Warning: In component P2.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
51+
// [PNlib/PNlib/Blocks/enablingInCon.mo:34:7-98:13:writable] Warning: In component P3.enableIn, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
52+
// [PNlib/PNlib/Blocks/enablingInCon.mo:41:13-44:19:writable] Warning: In component P3.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
53+
// [PNlib/PNlib/Blocks/enablingInCon.mo:78:13-81:19:writable] Warning: In component P3.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
54+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:37:5-101:13:writable] Warning: In component P3.enableOut, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
55+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:44:11-47:17:writable] Warning: In component P3.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
56+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:81:11-84:17:writable] Warning: In component P3.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
57+
// Notification: The given system is mixed-determined. [index > 0]
58+
// Notification: The given system is mixed-determined. [index > 1]
59+
// Notification: The given system is mixed-determined. [index > 2]
60+
// Notification: The given system is mixed-determined. [index > 3]
61+
// Error: No system for the symbolic initialization was generated.
62+
// "
63+
// {"Error get time!"}
64+
// ""
65+
// endResult
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// name: PNlib.Examples.ConTest.LoopAndArcweight
2+
// keywords: PNlib, continuous
3+
// status: correct
4+
5+
loadFile("../../PNlib/package.mo"); getErrorString();
6+
simulate(PNlib.Examples.ConTest.LoopAndArcweight); getErrorString();
7+
res := OpenModelica.Scripting.compareSimulationResults("PNlib.Examples.ConTest.LoopAndArcweight_res.mat",
8+
"../../ReferenceFiles/PNlib.Examples.ConTest.LoopAndArcweight.mat",
9+
"PNlib.Examples.ConTest.LoopAndArcweight_diff.csv", 0.01, 0.0001,
10+
{
11+
"P1.t",
12+
"P2.t",
13+
"T1.fire",
14+
"T1.instantaneousSpeed",
15+
"T1.maximumSpeed"
16+
}); getErrorString();
17+
18+
// Result:
19+
// true
20+
// "Notification: Automatically loaded package Modelica 3.2.1 due to uses annotation.
21+
// Notification: Automatically loaded package Complex 3.2.1 due to uses annotation.
22+
// Notification: Automatically loaded package ModelicaServices 3.2.1 due to uses annotation.
23+
// "
24+
// record SimulationResult
25+
// resultFile = "PNlib.Examples.ConTest.LoopAndArcweight_res.mat",
26+
// simulationOptions = "startTime = 0.0, stopTime = 10.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'PNlib.Examples.ConTest.LoopAndArcweight', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
27+
// messages = ""
28+
// end SimulationResult;
29+
// "[PNlib/PNlib/Blocks/enablingInCon.mo:34:7-98:13:writable] Warning: In component P1.enableIn, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
30+
// [PNlib/PNlib/Blocks/enablingInCon.mo:41:13-44:19:writable] Warning: In component P1.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
31+
// [PNlib/PNlib/Blocks/enablingInCon.mo:78:13-81:19:writable] Warning: In component P1.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
32+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:37:5-101:13:writable] Warning: In component P1.enableOut, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
33+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:44:11-47:17:writable] Warning: In component P1.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
34+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:81:11-84:17:writable] Warning: In component P1.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
35+
// [PNlib/PNlib/Blocks/enablingInCon.mo:34:7-98:13:writable] Warning: In component P2.enableIn, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
36+
// [PNlib/PNlib/Blocks/enablingInCon.mo:41:13-44:19:writable] Warning: In component P2.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
37+
// [PNlib/PNlib/Blocks/enablingInCon.mo:78:13-81:19:writable] Warning: In component P2.enableIn, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
38+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:37:5-101:13:writable] Warning: In component P2.enableOut, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
39+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:81:11-84:17:writable] Warning: In component P2.enableOut, in relation {}[i] == 0.0, == on Real numbers is only allowed inside functions.
40+
// Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
41+
// Warning: There are iteration variables with default zero start attribute. Use +d=initialization for more information.
42+
// "
43+
// {"Files Equal!"}
44+
// ""
45+
// endResult
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// name: PNlib.Examples.ConTest.PCtoTC
2+
// keywords: PNlib, continuous
3+
// status: correct
4+
5+
loadFile("../../PNlib/package.mo"); getErrorString();
6+
simulate(PNlib.Examples.ConTest.PCtoTC); getErrorString();
7+
res := OpenModelica.Scripting.compareSimulationResults("PNlib.Examples.ConTest.PCtoTC_res.mat",
8+
"../../ReferenceFiles/PNlib.Examples.ConTest.PCtoTC.mat",
9+
"PNlib.Examples.ConTest.PCtoTC_diff.csv", 0.01, 0.0001,
10+
{
11+
"P1.t",
12+
"T1.fire",
13+
"T1.instantaneousSpeed",
14+
"T1.maximumSpeed"
15+
}); getErrorString();
16+
17+
// Result:
18+
// true
19+
// "Notification: Automatically loaded package Modelica 3.2.1 due to uses annotation.
20+
// Notification: Automatically loaded package Complex 3.2.1 due to uses annotation.
21+
// Notification: Automatically loaded package ModelicaServices 3.2.1 due to uses annotation.
22+
// "
23+
// record SimulationResult
24+
// resultFile = "PNlib.Examples.ConTest.PCtoTC_res.mat",
25+
// simulationOptions = "startTime = 0.0, stopTime = 10.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'PNlib.Examples.ConTest.PCtoTC', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
26+
// messages = ""
27+
// end SimulationResult;
28+
// "[PNlib/PNlib/Blocks/enablingInCon.mo:34:7-98:13:writable] Warning: In component P1.enableIn, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
29+
// [PNlib/PNlib/Blocks/enablingInCon.mo:78:13-81:19:writable] Warning: In component P1.enableIn, in relation {}[i] == 0.0, == on Real numbers is only allowed inside functions.
30+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:37:5-101:13:writable] Warning: In component P1.enableOut, in relation arcWeightSum == 0.0, == on Real numbers is only allowed inside functions.
31+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:44:11-47:17:writable] Warning: In component P1.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
32+
// [PNlib/PNlib/Blocks/enablingOutCon.mo:81:11-84:17:writable] Warning: In component P1.enableOut, in relation arcWeight[i] == 0.0, == on Real numbers is only allowed inside functions.
33+
// Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
34+
// Warning: There are iteration variables with default zero start attribute. Use +d=initialization for more information.
35+
// "
36+
// {"Files Equal!"}
37+
// ""
38+
// endResult

0 commit comments

Comments
 (0)