Skip to content

Commit 58e841c

Browse files
committed
- added cpp synchronous coverage tests for windows
1 parent 63ce1c7 commit 58e841c

File tree

4 files changed

+96
-2
lines changed

4 files changed

+96
-2
lines changed

simulation/libraries/3rdParty/Modelica_Synchronous/simulateAll.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
cls
33

44
rem get path to omc
5-
SET OMC=%OPENMODELICAHOME%\bin\omc.exe +locale=C +running-testsuite=dummy.out
5+
SET OMC=%OPENMODELICAHOME%\bin\omc.exe +simCodeTarget=Cpp +locale=C +running-testsuite=dummy.out
66

77
rem try to simulate all *.mos files in current folder
88
for %%f in (*.mos) do (
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@echo off
2+
cls
3+
rem script written according to http://superuser.com/questions/232225/multithreaded-windows-for-batch-command
4+
5+
rem try to simulate all *.mos files in current folder
6+
for %%f in (*.mos) do call :loop %%f
7+
8+
rem wait for all processes to finish
9+
call :waitForAllFinished
10+
11+
rem sortresults
12+
python sortResults.py > results.txt
13+
14+
rem finish program
15+
goto :eof
16+
17+
18+
:loop
19+
rem getFreeInstance returns the result in %FreeProcess%, if it is <1, then all are busy
20+
call :getFreeInstance
21+
if %FreeProcess% GEQ 1 (
22+
rem we have a free process, so start it
23+
call :simulate %FreeProcess% %1
24+
goto :eof
25+
)
26+
rem if no free process is available, just wait a second
27+
echo Waiting for instances to close ...
28+
ping -n 2 ::1 >nul 2>&1
29+
rem jump back to see whether we can spawn a new process now
30+
goto loop
31+
goto :eof
32+
33+
34+
:simulate
35+
rem runs the test %2
36+
rem %2 is mos file and %1 is number of tmp directory %3 are additional options to omc
37+
time /t
38+
echo Instance %1: %2
39+
40+
mkdir ..\tmp%1 2>nul
41+
echo 1 > ..\tmp%1\running
42+
start /min simulate_parallel.cmd %1 %2
43+
rem ping, so that there is enough time to create the lock-file
44+
ping -n 2 ::1 >nul 2>&1
45+
goto :eof
46+
47+
48+
:getFreeInstance
49+
for /l %%i in (1,1,%NUMBER_OF_PROCESSORS%) do (
50+
set FreeProcess=%%i
51+
if not exist ..\tmp%%i\running goto :eof
52+
)
53+
set FreeProcess=-1
54+
goto :eof
55+
56+
57+
:waitForAllFinished
58+
for /l %%i in (1,1,%NUMBER_OF_PROCESSORS%) do (
59+
call :waitForFinished %%i
60+
)
61+
goto :eof
62+
63+
64+
:waitForFinished
65+
:finishLoop
66+
if exist ..\tmp%1\running (
67+
echo Waiting for process %1 to finish
68+
ping -n 2 ::1 >nul 2>&1
69+
goto :finishLoop
70+
)
71+
goto :eof
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@echo off
2+
rem runs the test %2
3+
rem %2 is mos file and %1 is number of tmp directory %3 are additional options to omc
4+
5+
mkdir ..\tmp%1 2>nul
6+
mkdir ..\tmp%1\ReferenceFiles 2>nul
7+
del ..\tmp%1\*.* /Q
8+
del ..\tmp%1\ReferenceFiles\*.* /Q
9+
copy %2 ..\tmp%1
10+
copy ReferenceFiles\%~n2.mat ..\tmp%1\ReferenceFiles
11+
if exist common.mos copy common.mos ..\tmp%1
12+
cd ..\tmp%1
13+
echo 1 > running
14+
15+
rem get path to omc
16+
SET OMC=%OPENMODELICAHOME%\bin\omc.exe +simCodeTarget=Cpp +locale=C +running-testsuite=dummy.out
17+
18+
%OMC% %2 %3 > ..\Modelica_Synchronous\%2.txt 2>&1
19+
20+
del running
21+
cd ..\Modelica_Synchronous
22+
23+
exit

simulation/libraries/3rdParty/Modelica_Synchronous/sortResults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
('_TableBug', ['n Table: NoName from File: NoName with Size', 'try to get', 'out of range!'], None), \
3838
('_SimExecFailed', 'Simulation execution failed for model', None), \
3939
('_UnknownVar', ['Get Data of Var', 'from file', 'failed'], None), \
40-
('_NotEqual', 'Files not Equal!', None), \
40+
('_NotEqual', 'Files not Equal', None), \
4141
('_OK', 'Files Equal!', 'failed')]
4242

4343
def checkFile(fileName, groups):

0 commit comments

Comments
 (0)