Skip to content

Commit

Permalink
Accept paths with spaces, add link to OMS commit (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnHeuermann committed Oct 22, 2020
1 parent f13b1bb commit d45cfb0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 32 deletions.
4 changes: 2 additions & 2 deletions testsuite/fmi-cross-check/fmi-cross-check.html.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

<p>Total time taken: #totalTime# min:sec</p>
<p>System info: #sysInfo#</p>
<p>OMSimulator Version: #omsVersion#</p>
<p>OMSimulator Version: #omsVersion#, commit <a href="https://github.com/OpenModelica/OMSimulator/commit/#omscommitshort#">#omscommitshort#</a></p>
<p>Test started: #timeStart#</p>
<p>Tested Library: <a href="https://github.com/modelica/fmi-cross-check">fmi-cross-check</a> commit <a href="https://github.com/modelica/fmi-cross-check/commit/#commitfull#">#commitshort#</a></p>
<p>Tested Library: <a href="https://github.com/modelica/fmi-cross-check">fmi-cross-check</a>, commit <a href="https://github.com/modelica/fmi-cross-check/commit/#commitfull#">#commitshort#</a></p>
<p>Simulate FMU time limit: #ulimitOMSimulator#s</p>
<p>Default tolerance: #default_tolerance#</p>
Verified using: #referenceTool#
Expand Down
4 changes: 4 additions & 0 deletions testsuite/fmi-cross-check/generateHTML.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import subprocess
import time
import shutil
import re
import pandas as pd
from OMPython import OMCSessionZMQ

Expand Down Expand Up @@ -98,6 +99,8 @@ def generateOverviewHTML(crossCheckDir, platform, omsVersion, omsVersionShort, t
commitshort = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], cwd=crossCheckDir).decode('utf-8')
commitfull = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=crossCheckDir).decode('utf-8')

omscommitshort = re.search(r"-g.+-",omsVersion).group()[2:9]

htmltpl=open("fmi-cross-check.html.tpl").read()

# Replace keywords from HTML template
Expand All @@ -107,6 +110,7 @@ def generateOverviewHTML(crossCheckDir, platform, omsVersion, omsVersionShort, t

htmltpl = htmltpl.replace("#commitshort#", str(commitshort))
htmltpl = htmltpl.replace("#commitfull#", str(commitfull))
htmltpl = htmltpl.replace("#omscommitshort#", str(omscommitshort))

htmltpl = htmltpl.replace("#totalTime#", time.strftime("%M:%S", time.gmtime(totalTime)))
htmltpl = htmltpl.replace("#sysInfo#", sysInfo)
Expand Down
48 changes: 18 additions & 30 deletions testsuite/fmi-cross-check/importFMUs.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,32 +122,18 @@ def simulateFMU(omsimulator, testFMUDir, resultDir, modelName, fmiType, luaFile)
intervals = "500"

# Run lua file with OMSimulator via shell
if sys.platform == "win32":
cmd = [omsimulator,
"--stripRoot=true",
"--skipCSVHeader=true",
"--addParametersToCSV=true",
"--intervals=" + intervals,
"--suppressPath=true",
"--timeout=" + str(ulimitOMSimulator),
os.path.relpath(luaFile, resultDir)]
else:
cmd = omsimulator + " \\\n" \
+ " --stripRoot=true \\\n" \
+ " --skipCSVHeader=true \\\n" \
+ " --addParametersToCSV=true \\\n" \
+ " --intervals=" + intervals + " \\\n" \
+ " --suppressPath=true \\\n" \
+ " --timeout=" + str(ulimitOMSimulator) + " \\\n" \
+ " " + os.path.relpath(luaFile, resultDir)
cmd = ["--stripRoot=true",
"--skipCSVHeader=true",
"--addParametersToCSV=true",
"--intervals=" + intervals,
"--suppressPath=true",
"--timeout=" + str(ulimitOMSimulator),
os.path.relpath(luaFile, resultDir)]

# Call OMSimulator and measure time
simTimeStart = time.time()
if sys.platform == "win32":
proc = subprocess.Popen(cmd, cwd=resultDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
cmd = ' \\\n '.join(cmd)
else:
proc = subprocess.Popen([cmd], cwd=resultDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
proc = subprocess.Popen(omsimulator+cmd, cwd=resultDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
cmd = ' '.join(omsimulator+cmd)
simTime = time.time() - simTimeStart
(out, err) = proc.communicate()
exitCode = proc.returncode
Expand Down Expand Up @@ -273,24 +259,26 @@ def simulateWithOMSimulator(crossCheckDir, platform, omsimulator, omsVersion):
# Get OMSimulator and version
omsimulator = str(sys.argv[3])
if "wine" in omsimulator:
(tmp1, tmp2) = omsimulator.split(" ")
(tmp1, tmp2) = omsimulator.split(" ",1)
if shutil.which(tmp1) is None:
raise Exception("Can't find \""+ tmp1 + "\"")
tmp2 = tmp2.replace('\\ ', " ")
if shutil.which(tmp2) is None:
raise Exception("Can't find \""+ tmp2 + "\"")
tmp2 = os.path.abspath(shutil.which(tmp2))
omsimulator = tmp1 + " " + tmp2
raise Exception("Can't find \""+ tmp1 + "\"")
print(tmp2)
tmp2 = os.path.abspath(tmp2)
omsimulator = [tmp1, tmp2]
else:
if shutil.which(omsimulator) is None:
raise Exception("Can't find \""+ omsimulator + "\"")
omsimulator = os.path.abspath(shutil.which(omsimulator))
omsimulator = [os.path.abspath(shutil.which(omsimulator))]

tmpCall = omsimulator.split()
tmpCall = omsimulator.copy()
tmpCall.append('--version')
omsVersion = subprocess.run(tmpCall, stdout=subprocess.PIPE).stdout.decode()
omsVersion = omsVersion.replace("OMSimulator ", "").replace("\n", "")

print("Using OMSimulator from \"" + omsimulator + "\" with version \"" + omsVersion + "\"")
print("Using OMSimulator from \"" + ' '.join(omsimulator) + "\" with version \"" + omsVersion + "\"")

# Change working dir to fmi-cross-check repo
crossCheckDir = os.path.abspath(str(sys.argv[1]))
Expand Down

0 comments on commit d45cfb0

Please sign in to comment.