Skip to content

Commit 2854981

Browse files
authored
Add verbose mode to test.py (#42)
- Dump model name when test is started - Add verbose flag to test
1 parent 7b47871 commit 2854981

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
4545
- name: Run library test
4646
shell: bash
47-
run: python test.py --branch="${{ matrix.omc-version }}" --noclean configs/sanityCheck.json
47+
run: python test.py --branch="${{ matrix.omc-version }}" --noclean --verbose configs/sanityCheck.json
4848

4949
- name: Generate HTML results
5050
shell: bash

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,15 @@ The scripts from this repository can be used to run regression tests for public,
3737
```bash
3838
pip install -r requirements.txt
3939
```
40-
- Install libraries you want to test
41-
- (Optional) Remove already installed libraries
42-
```bash
43-
rm -rf ~/.openmodelica/libraries/
44-
rm -rf /path/to/OpenModelica/build/lib/omlibraries
40+
- OMC will search for libraries in the location provided with test.py argument `--libraries`.
41+
The default value is `/home/username/.openmodelica/libraries/`.
42+
- Install your libraries into the location specified with `--libraries`
43+
or use `loadFile` command inside `loadFileCommands` in the config JSON:
44+
```yml
45+
"loadFileCommands": [
46+
"loadFile(\"/path/to/package.mo\")"
47+
]
4548
```
46-
- Install all available libraries.
47-
```bash
48-
/path/to/omc .CI/installLibraries.mos
49-
```
50-
51-
*or*
52-
- Install your libraries.
5349
- Create configs/myConf.json to specify what libraries to test.
5450
```json
5551
[

test.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def target():
9292
parser.add_argument('--fmi', default=False)
9393
parser.add_argument('--output', default='')
9494
parser.add_argument('--docker', default='')
95-
parser.add_argument('--libraries', default=os.path.expanduser('~/.openmodelica/libraries/'))
95+
parser.add_argument('--libraries', help="Directory omc will search in to load system libraries/libraries to test.", default=os.path.expanduser('~/.openmodelica/libraries/'))
9696
parser.add_argument('--extraflags', default='')
9797
parser.add_argument('--extrasimflags', default='')
9898
parser.add_argument('--ompython_omhome', default='')
@@ -101,13 +101,15 @@ def target():
101101
parser.add_argument('--ulimitvmem', help="Virtual memory limit (in kB)", type=int, default=8*1024*1024)
102102
parser.add_argument('--default', action='append', help="Add a default value for some configuration key, such as --default=ulimitExe=60. The equals sign is mandatory.", default=[])
103103
parser.add_argument('-j', '--jobs', default=0)
104+
parser.add_argument('-v', '--verbose', action="store_true", help="Verbose mode.", default=False)
104105

105106
args = parser.parse_args()
106107
configs = args.configs
107108
branch = args.branch
108109
result_location = args.output
109110
n_jobs = int(args.jobs)
110111
clean = not args.noclean
112+
verbose = args.verbose
111113
extraflags = args.extraflags
112114
extrasimflags = args.extrasimflags
113115
ompython_omhome = args.ompython_omhome
@@ -613,14 +615,18 @@ def hashReferenceFiles(s):
613615
print("Created .conf.json files")
614616
sys.stdout.flush()
615617

616-
def runScript(c, timeout, memoryLimit):
618+
def runScript(c, timeout, memoryLimit, verbose):
617619
j = "files/%s.stat.json" % c
618620
try:
619621
os.remove(j)
620622
except:
621623
pass
622624
start=monotonic()
623625
# runCommand("%s %s %s.mos" % (omc_exe, single_thread, c), prefix=c, timeout=timeout)
626+
if verbose:
627+
print("Starting test: %s" % c)
628+
sys.stdout.flush()
629+
624630
if 0 != runCommand("ulimit -v %d; ./testmodel.py --libraries=%s %s --ompython_omhome=%s %s.conf.json > files/%s.cmdout 2>&1" % (memoryLimit, librariespath, ("--docker %s --dockerExtraArgs '%s'" % (docker, " ".join(dockerExtraArgs))) if docker else "", ompython_omhome, c, c), prefix=c, timeout=timeout):
625631
print("files/%s.err" % c)
626632
with open("files/%s.err" % c, "a+") as errfile:
@@ -646,6 +652,9 @@ def runScript(c, timeout, memoryLimit):
646652
data = {"phase":0}
647653
data["exectime"] = execTime
648654
json.dump(data, open(j,"w"))
655+
if verbose:
656+
print("Finished test: %s - %d[s]" % (c, execTime))
657+
sys.stdout.flush()
649658

650659
def expectedExec(c):
651660
(model,lib,libName,name,data) = c
@@ -688,7 +697,7 @@ def expectedExec(c):
688697
start_as_time=time.localtime()
689698
testRunStartTimeAsEpoch = int(time.time())
690699
# Need translateModel + make + exe...
691-
cmd_res=Parallel(n_jobs=n_jobs)(delayed(runScript)(name, 2*data["ulimitOmc"]+data["ulimitExe"]+25, data["ulimitMemory"]) for (model,lib,libName,name,data) in tests)
700+
cmd_res=Parallel(n_jobs=n_jobs)(delayed(runScript)(name, 2*data["ulimitOmc"]+data["ulimitExe"]+25, data["ulimitMemory"], verbose) for (model,lib,libName,name,data) in tests)
692701
stop=monotonic()
693702
print("Execution time: %s" % friendlyStr(stop-start))
694703
assert(stop-start >= 0.0)

0 commit comments

Comments
 (0)