3 # This script runs tests in helix. It defines a set of test scenarios
4 # that enable various combinations of runtime configurations to be set
5 # via the test process environment.
7 # This script calls "corerun xunit.console.dll xunitwrapper.dll",
8 # where the xunitwrapper.dll will run a .sh/.cmd script per test in a
9 # separate process. This process will have the scenario environment
10 # variables set, but the xunit process will not.
12 # TODO: Factor out logic common with runtest.py
21 "jitstress2": { "COMPlus_TieredCompilation": "0",
22 "COMPlus_JitStress": "2" },
25 if sys.platform.startswith('linux') or sys.platform == "darwin":
26 platform_type = "unix"
27 elif sys.platform == "win32":
28 platform_type = "windows"
30 print("unknown os: %s" % sys.platform)
33 def get_testenv_script(env_dict):
34 if platform_type == "unix":
35 return ''.join([ "export %s=%s%s" % (k, v, os.linesep) for k, v in env_dict.items() ])
36 elif platform_type == "windows":
37 return ''.join([ "set %s=%s%s" % (k, v, os.linesep) for k, v in env_dict.items() ])
39 if __name__ == "__main__":
40 parser = argparse.ArgumentParser(description="Parse arguments")
41 parser.add_argument("-scenario", dest="scenario", default=None)
42 parser.add_argument("-wrapper", dest="wrapper", default=None, required=True)
43 args = parser.parse_args()
44 scenario = args.scenario
45 wrapper = args.wrapper
47 if not "HELIX_CORRELATION_PAYLOAD" in os.environ:
48 print("HELIX_CORRELATION_PAYLOAD must be defined in environment")
51 if not "HELIX_WORKITEM_PAYLOAD" in os.environ:
52 print("HELIX_WORKITEM_PAYLOAD must be defined in environment")
55 core_root = os.environ["HELIX_CORRELATION_PAYLOAD"]
57 if platform_type == "unix":
58 corerun = os.path.join(core_root, "corerun")
60 corerun = os.path.join(core_root, "corerun.exe")
62 # Unlike the old test wrapper, this runs xunit.console.dll from
63 # the correlation payload. This removes the need for redundant
64 # copies of the console runner in each test directory.
66 os.path.join(os.environ["HELIX_CORRELATION_PAYLOAD"], "xunit.console.dll"),
67 os.path.join(os.environ["HELIX_WORKITEM_PAYLOAD"], wrapper),
69 "-xml", "testResults.xml",
70 "-notrait", "category=outerloop",
71 "-notrait", "category=failing"]
74 print("CORE_ROOT=%s" % core_root)
75 os.environ["CORE_ROOT"] = core_root
77 print("BEGIN EXECUTION")
78 print(' '.join(command))
79 proc = subprocess.Popen(command)
81 print("Finished running tests. Exit code = %d" % proc.returncode)
82 sys.exit(proc.returncode)
84 print("scenario: %s" % scenario)
85 with tempfile.NamedTemporaryFile(mode="w") as testenv:
86 testenv.write(get_testenv_script(test_scenarios[scenario]))
89 print("__TestEnv=%s" % testenv.name)
90 os.environ["__TestEnv"] = testenv.name
92 with open(testenv.name) as testenv_written:
93 contents = testenv_written.read()
96 print("CORE_ROOT=%s" % core_root)
97 os.environ["CORE_ROOT"] = core_root
99 print("BEGIN EXECUTION")
100 print(' '.join(command))
101 proc = subprocess.Popen(command)
103 print("Finished running tests. Exit code = %d" % proc.returncode)
104 sys.exit(proc.returncode)