Skip to content

Commit c52f68a

Browse files
[MERGE #5273 @Penguinwizzard] Add arm/arm64 and chakrafull support to runtests.py
Merge pull request #5273 from Penguinwizzard:runtestspy_arm64_full This allows running jshost on the core unit tests easily from the python runner, as well as running core tests on arm and arm64. Note: hold this change, and re-target to release/1.10 when ready.
2 parents 76ad640 + 4849ccb commit c52f68a

File tree

1 file changed

+62
-12
lines changed

1 file changed

+62
-12
lines changed

test/runtests.py

Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
help='use debug build');
5151
parser.add_argument('-t', '--test', '--test-build', action='store_true',
5252
help='use test build')
53+
parser.add_argument('-f', '--full', '--chakrafull', action='store_true',
54+
help='test chakrafull instead of chakracore')
5355
parser.add_argument('--static', action='store_true',
5456
help='mark that we are testing a static build')
5557
parser.add_argument('--variants', metavar='variant', nargs='+',
@@ -78,12 +80,18 @@
7880
help='use x86 build')
7981
parser.add_argument('--x64', action='store_true',
8082
help='use x64 build')
83+
parser.add_argument('--arm', action='store_true',
84+
help='use arm build')
85+
parser.add_argument('--arm64', action='store_true',
86+
help='use arm64 build')
8187
parser.add_argument('-j', '--processcount', metavar='processcount', type=int,
8288
help='number of parallel threads to use')
8389
parser.add_argument('--warn-on-timeout', action='store_true',
8490
help='warn when a test times out instead of labelling it as an error immediately')
8591
parser.add_argument('--override-test-root', type=str,
8692
help='change the base directory for the tests (where rlexedirs will be sought)')
93+
parser.add_argument('--extra-flags', type=str,
94+
help='add extra flags to all executed tests')
8795
args = parser.parse_args()
8896

8997
test_root = os.path.dirname(os.path.realpath(__file__))
@@ -93,8 +101,17 @@
93101
if args.override_test_root:
94102
test_root = os.path.realpath(args.override_test_root)
95103

96-
# arch: x86, x64
97-
arch = 'x86' if args.x86 else ('x64' if args.x64 else None)
104+
# arch: x86, x64, arm, arm64
105+
arch = None
106+
if args.x86:
107+
arch = 'x86'
108+
elif args.x64:
109+
arch = 'x64'
110+
elif args.arm:
111+
arch = 'arm'
112+
elif args.arm64:
113+
arch = 'arm64'
114+
98115
if arch == None:
99116
arch = os.environ.get('_BuildArch', 'x86')
100117
if sys.platform != 'win32':
@@ -110,26 +127,46 @@
110127
sys.exit(1)
111128
flavor_alias = 'chk' if flavor == 'Debug' else 'fre'
112129

130+
# handling for extra flags
131+
extra_flags = []
132+
if args.extra_flags:
133+
extra_flags = args.extra_flags.split()
134+
113135
# test variants
114136
if not args.variants:
115137
args.variants = ['interpreted', 'dynapogo']
116138

139+
# target binary variants
140+
binary_name_noext = "ch"
141+
if args.full:
142+
binary_name_noext = "jshost"
143+
repo_root = os.path.dirname(repo_root)
144+
# we need this to have consistent error message formatting with ch
145+
extra_flags.append("-bvt")
146+
else:
147+
extra_flags.append('-WERExceptionSupport')
148+
149+
# append exe to the binary name on windows
150+
binary_name = binary_name_noext
151+
if sys.platform == 'win32':
152+
binary_name = binary_name + ".exe"
153+
117154
# binary: full ch path
118155
binary = args.binary
119156
if binary == None:
120157
if sys.platform == 'win32':
121158
build = "VcBuild.SWB" if args.swb else "VcBuild"
122-
binary = 'Build\\' + build + '\\bin\\{}_{}\\ch.exe'.format(arch, flavor)
159+
binary = os.path.join(repo_root, 'Build', build, 'bin', '{}_{}'.format(arch, flavor), binary_name)
123160
else:
124-
binary = 'out/{0}/ch'.format(flavor)
125-
binary = os.path.join(repo_root, binary)
161+
binary = os.path.join(repo_root, 'out', flavor, binary_name)
162+
126163
if not os.path.isfile(binary):
127164
print('{} not found. Did you run ./build.sh already?'.format(binary))
128165
sys.exit(1)
129166

130167
# global tags/not_tags
131168
tags = set(args.tag or [])
132-
not_tags = set(args.not_tag or []).union(['fail', 'exclude_' + arch, 'exclude_' + flavor, 'exclude_ch'])
169+
not_tags = set(args.not_tag or []).union(['fail', 'exclude_' + arch, 'exclude_' + flavor])
133170

134171
if arch_alias:
135172
not_tags.add('exclude_' + arch_alias)
@@ -158,6 +195,14 @@
158195
else:
159196
not_tags.add('exclude_windows')
160197

198+
# exclude tests that depend on features not supported on a platform
199+
if arch == 'arm' or arch == 'arm64':
200+
not_tags.add('require_asmjs')
201+
202+
# exclude tests that exclude the current binary
203+
not_tags.add('exclude_' + binary_name_noext)
204+
205+
# exclude tests known to fail under certain sanitizers
161206
if args.sanitize != None:
162207
not_tags.add('exclude_sanitize_'+args.sanitize)
163208

@@ -204,7 +249,7 @@ def __init__(self, log_file_path = None):
204249
# Set up the log file paths
205250
# Make sure the right directory exists and the log file doesn't
206251
log_file_name = "testrun.{0}{1}.log".format(arch, flavor)
207-
log_file_directory = os.path.join(repo_root, "test", "logs")
252+
log_file_directory = os.path.join(test_root, "logs")
208253

209254
if not os.path.exists(log_file_directory):
210255
os.mkdir(log_file_directory)
@@ -306,7 +351,7 @@ class TestVariant(object):
306351
def __init__(self, name, compile_flags=[], variant_not_tags=[]):
307352
self.name = name
308353
self.compile_flags = \
309-
['-WERExceptionSupport', '-ExtendedErrorStackForTestHost',
354+
['-ExtendedErrorStackForTestHost',
310355
'-BaselineMode'] + compile_flags
311356
self._compile_flags_has_expansion = self._has_expansion(compile_flags)
312357
self.tags = tags.copy()
@@ -318,6 +363,11 @@ def __init__(self, name, compile_flags=[], variant_not_tags=[]):
318363
self.test_count = 0
319364
self._print_lines = [] # _print lines buffer
320365
self._last_len = 0
366+
if verbose:
367+
print("Added variant {0}:".format(name))
368+
print("Flags: " + ", ".join(self.compile_flags))
369+
print("Tags: " + ", ".join(self.tags))
370+
print("NotTags: " + ", ".join(self.not_tags))
321371

322372
@staticmethod
323373
def _has_expansion(flags):
@@ -506,7 +556,7 @@ def timeout_func(timeout_data):
506556
return self._show_failed(timedout=True, **fail_args)
507557

508558
# check ch failed
509-
if exit_code != 0:
559+
if exit_code != 0 and binary_name_noext == 'ch':
510560
return self._show_failed(**fail_args)
511561

512562
# check output
@@ -706,19 +756,19 @@ def main():
706756

707757
# test variants
708758
variants = [x for x in [
709-
TestVariant('interpreted', [
759+
TestVariant('interpreted', extra_flags + [
710760
'-maxInterpretCount:1', '-maxSimpleJitRunCount:1', '-bgjit-',
711761
'-dynamicprofilecache:profile.dpl.${id}'
712762
], [
713763
'require_disable_jit'
714764
]),
715-
TestVariant('dynapogo', [
765+
TestVariant('dynapogo', extra_flags + [
716766
'-forceNative', '-off:simpleJit', '-bgJitDelay:0',
717767
'-dynamicprofileinput:profile.dpl.${id}'
718768
], [
719769
'require_disable_jit'
720770
]),
721-
TestVariant('disable_jit', [
771+
TestVariant('disable_jit', extra_flags + [
722772
'-nonative'
723773
], [
724774
'exclude_interpreted', 'fails_interpreted', 'require_backend'

0 commit comments

Comments
 (0)