Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/devel/checkTests.py
169673 views
1
#!/usr/bin/env python
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2010-2025 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file checkTests.py
15
# @author Jakob Erdmann
16
# @date 2022-12-16
17
18
"""
19
apply runSeeds to a list of tests and compute statistics
20
use case: tweaking the lane change model and then seeing the result of a
21
gazillion tests with reduced noise
22
"""
23
24
import os
25
import sys
26
import glob
27
from subprocess import call
28
29
tests, prefix, apps = sys.argv[1:]
30
SEEDS = "0:100"
31
THREADS = "16"
32
33
EXTRACT = os.path.join(os.environ['SUMO_HOME'], 'tools', 'extractTest.py')
34
RUNSEEDS = os.path.join(os.environ['SUMO_HOME'], 'tools', 'runSeeds.py')
35
ASTATS = os.path.join(os.environ['SUMO_HOME'], 'tools', 'output', 'attributeStats.py')
36
ADIFF = os.path.join(os.environ['SUMO_HOME'], 'tools', 'output', 'attributeDiff.py')
37
38
applist = apps.split(',')
39
appdirs = [a + "_0" for a in applist]
40
tDirs = []
41
42
for test in open(tests).readlines()[1:]:
43
test = test.strip()
44
fullpath = os.path.join(prefix, test)
45
call([EXTRACT, fullpath])
46
tdir = '_' + test.replace('/', '_')
47
tDirs.append(tdir)
48
os.chdir(tdir)
49
rsargs = [RUNSEEDS,
50
'-k', 'test.sumocfg',
51
'-a', apps,
52
'--seeds', SEEDS,
53
'--threads', THREADS,
54
'--no-warnings',
55
'--statistic-output', 'stats.xml']
56
call(rsargs)
57
58
# clean file
59
outf = open('compare.txt', 'w')
60
outf.close()
61
outf = open('compare.txt', 'a')
62
statFiles = []
63
for app, ad in zip(applist, appdirs):
64
files = glob.glob(os.path.join(ad, '*.stats.xml'))
65
sFile = '%s_allStats.xml' % app
66
statFiles.append(sFile)
67
args = [ASTATS, '-x', sFile, '-b', '0'] + files
68
call(args, stdout=outf)
69
outf.close()
70
71
call([ADIFF, '-o', 'statsDiff.xml'] + statFiles)
72
os.chdir('..')
73
74
# final summary
75
differences = [os.path.join(d, 'statsDiff.xml') for d in tDirs]
76
args = [ASTATS, '-x', 'globalStats.xml', '-b', '0'] + differences
77
call(args)
78
79