aboutsummaryrefslogtreecommitdiff
path: root/mesontest.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesontest.py')
-rwxr-xr-xmesontest.py57
1 files changed, 32 insertions, 25 deletions
diff --git a/mesontest.py b/mesontest.py
index f5da103..96f0315 100755
--- a/mesontest.py
+++ b/mesontest.py
@@ -25,6 +25,7 @@ import time, datetime, multiprocessing, json
import concurrent.futures as conc
import platform
import signal
+import random
# GNU autotools interprets a return code of 77 from tests it executes to
# mean that the test should be skipped.
@@ -158,7 +159,6 @@ class TestHarness:
self.skip_count = 0
self.timeout_count = 0
self.is_run = False
- self.cant_rebuild = False
self.tests = None
self.suites = None
if self.options.benchmark:
@@ -166,27 +166,6 @@ class TestHarness:
else:
self.load_datafile(os.path.join(options.wd, 'meson-private', 'meson_test_setup.dat'))
- def rebuild_all(self):
- if not os.path.isfile(os.path.join(self.options.wd, 'build.ninja')):
- print("Only ninja backend is supported to rebuilt tests before running them.")
- self.cant_rebuild = True
- return True
-
- ninja = environment.detect_ninja()
- if not ninja:
- print("Can't find ninja, can't rebuild test.")
- self.cant_rebuild = True
- return False
-
- p = subprocess.Popen([ninja, '-C', self.options.wd])
- (stdo, stde) = p.communicate()
-
- if p.returncode != 0:
- print("Could not rebuild")
- return False
-
- return True
-
def run_single_test(self, wrap, test):
if test.fname[0].endswith('.jar'):
cmd = ['java', '-jar'] + test.fname
@@ -221,6 +200,14 @@ class TestHarness:
if len(test.extra_paths) > 0:
child_env['PATH'] += ';'.join([''] + test.extra_paths)
+ # If MALLOC_PERTURB_ is not set, or if it is set to an empty value,
+ # (i.e., the test or the environment don't explicitly set it), set
+ # it ourselves. We do this unconditionally because it is extremely
+ # useful to have in tests.
+ # Setting MALLOC_PERTURB_="0" will completely disable this feature.
+ if 'MALLOC_PERTURB_' not in child_env or not child_env['MALLOC_PERTURB_']:
+ child_env['MALLOC_PERTURB_'] = str(random.randint(1, 255))
+
setsid = None
stdout = None
stderr = None
@@ -539,6 +526,25 @@ def merge_suite_options(options):
options.wrapper = current.exe_wrapper
return current.env
+def rebuild_all(wd):
+ if not os.path.isfile(os.path.join(wd, 'build.ninja')):
+ print("Only ninja backend is supported to rebuild tests before running them.")
+ return True
+
+ ninja = environment.detect_ninja()
+ if not ninja:
+ print("Can't find ninja, can't rebuild test.")
+ return False
+
+ p = subprocess.Popen([ninja, '-C', wd])
+ (stdo, stde) = p.communicate()
+
+ if p.returncode != 0:
+ print("Could not rebuild")
+ return False
+
+ return True
+
def run(args):
options = parser.parse_args(args)
@@ -564,13 +570,14 @@ def run(args):
options.wd = os.path.abspath(options.wd)
+ if not options.no_rebuild:
+ if not rebuild_all(options.wd):
+ sys.exit(-1)
+
th = TestHarness(options)
if options.list:
list_tests(th)
return 0
- if not options.no_rebuild:
- if not th.rebuild_all():
- sys.exit(-1)
if len(options.args) == 0:
return th.doit()
return th.run_special()