Skip to content

Commit 139280e

Browse files
committed
Reintroduce --macro:junitcp for truffle junit tests
1 parent 9b70e98 commit 139280e

File tree

6 files changed

+47
-12
lines changed

6 files changed

+47
-12
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file contains support for building a set of junit tests into a native-image
2+
3+
ImageName = svmjunit
4+
5+
ImageClasspath = ${.}/junit-support.jar:${.}/junit-tool.jar:${.}/junit.jar:${.}/hamcrest.jar
6+
7+
Args = -H:Features=com.oracle.svm.junit.JUnitFeature \
8+
-H:Class=com.oracle.svm.junit.SVMJUnitRunner \
9+
-H:TestFile=${*} \
10+
--initialize-at-build-time=org.junit,com.oracle.mxtool.junit.MxJUnitRequest \
11+

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def image_demo_task(extra_image_args=None, flightrecorder=True):
337337

338338

339339
def truffle_unittest_task(quickbuild=False):
340-
truffle_build_args = ['--build-args', '--macro:truffle',
340+
truffle_build_args = ['--force-builder-on-cp', '--build-args', '--macro:truffle',
341341
'-H:MaxRuntimeCompileMethods=5000',
342342
'-H:+TruffleCheckBlackListedMethods']
343343
if quickbuild:
@@ -413,7 +413,7 @@ def svm_gate_body(args, tasks):
413413
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
414414
testlib = mx_subst.path_substitutions.substitute('-Dnative.test.lib=<path:truffle:TRUFFLE_TEST_NATIVE>/<lib:nativetest>')
415415
isolation_testlib = mx_subst.path_substitutions.substitute('-Dnative.isolation.test.lib=<path:truffle:TRUFFLE_TEST_NATIVE>/<lib:isolationtest>')
416-
native_unittest_args = ['com.oracle.truffle.nfi.test', '--build-args', '--language:nfi',
416+
native_unittest_args = ['com.oracle.truffle.nfi.test', '--force-builder-on-cp', '--build-args', '--language:nfi',
417417
'-H:MaxRuntimeCompileMethods=2000',
418418
'-H:+TruffleCheckBlackListedMethods',
419419
'--run-args', testlib, isolation_testlib, '--very-verbose', '--enable-timing']
@@ -424,7 +424,7 @@ def svm_gate_body(args, tasks):
424424
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
425425
testlib = mx_subst.path_substitutions.substitute('-Dnative.test.lib=<path:truffle:TRUFFLE_TEST_NATIVE>/<lib:nativetest>')
426426
isolation_testlib = mx_subst.path_substitutions.substitute('-Dnative.isolation.test.lib=<path:truffle:TRUFFLE_TEST_NATIVE>/<lib:isolationtest>')
427-
native_unittest_args = ['com.oracle.truffle.nfi.test', '--build-args', '--language:nfi',
427+
native_unittest_args = ['com.oracle.truffle.nfi.test', '--force-builder-on-cp', '--build-args', '--language:nfi',
428428
'-H:MaxRuntimeCompileMethods=2000',
429429
'-H:+TruffleCheckBlackListedMethods'] + DEVMODE_FLAGS + [
430430
'--run-args', testlib, isolation_testlib, '--very-verbose', '--enable-timing']
@@ -570,7 +570,7 @@ def javac_image_command(javac_path):
570570
)
571571

572572

573-
def _native_junit(native_image, unittest_args, build_args=None, run_args=None, blacklist=None, whitelist=None, preserve_image=False):
573+
def _native_junit(native_image, unittest_args, build_args=None, run_args=None, blacklist=None, whitelist=None, preserve_image=False, force_builder_on_cp=False):
574574
build_args = build_args or []
575575
javaProperties = {}
576576
for dist in suite.dists:
@@ -597,7 +597,8 @@ def dummy_harness(test_deps, vm_launcher, vm_args):
597597
with open(unittest_file, 'r') as f:
598598
mx.log('Building junit image for matching: ' + ' '.join(l.rstrip() for l in f))
599599
extra_image_args = mx.get_runtime_jvm_args(unittest_deps, jdk=mx_compiler.jdk, exclude_names=['substratevm:LIBRARY_SUPPORT'])
600-
unittest_image = native_image(['-ea', '-esa'] + build_args + extra_image_args + ['--macro:junit=' + unittest_file, '-H:Path=' + junit_test_dir])
600+
macro_junit = '--macro:junit' + ('cp' if force_builder_on_cp else '')
601+
unittest_image = native_image(['-ea', '-esa'] + build_args + extra_image_args + [macro_junit + '=' + unittest_file, '-H:Path=' + junit_test_dir])
601602
mx.log('Running: ' + ' '.join(map(pipes.quote, [unittest_image] + run_args)))
602603
mx.run([unittest_image] + run_args)
603604
finally:
@@ -620,13 +621,14 @@ def unmask(args):
620621

621622
def _native_unittest(native_image, cmdline_args):
622623
parser = ArgumentParser(prog='mx native-unittest', description='Run unittests as native image.')
623-
all_args = ['--build-args', '--run-args', '--blacklist', '--whitelist', '-p', '--preserve-image']
624+
all_args = ['--build-args', '--run-args', '--blacklist', '--whitelist', '-p', '--preserve-image', '--force-builder-on-cp']
624625
cmdline_args = [_mask(arg, all_args) for arg in cmdline_args]
625626
parser.add_argument(all_args[0], metavar='ARG', nargs='*', default=[])
626627
parser.add_argument(all_args[1], metavar='ARG', nargs='*', default=[])
627628
parser.add_argument('--blacklist', help='run all testcases not specified in <file>', metavar='<file>')
628629
parser.add_argument('--whitelist', help='run testcases specified in <file> only', metavar='<file>')
629630
parser.add_argument('-p', '--preserve-image', help='do not delete the generated native image', action='store_true')
631+
parser.add_argument('--force-builder-on-cp', help='force image builder to run on classpath', action='store_true')
630632
parser.add_argument('unittest_args', metavar='TEST_ARG', nargs='*')
631633
pargs = parser.parse_args(cmdline_args)
632634

@@ -647,7 +649,7 @@ def _native_unittest(native_image, cmdline_args):
647649
mx.log('warning: could not read blacklist: ' + blacklist)
648650

649651
unittest_args = unmask(pargs.unittest_args) if unmask(pargs.unittest_args) else ['com.oracle.svm.test', 'com.oracle.svm.configure.test']
650-
_native_junit(native_image, unittest_args, unmask(pargs.build_args), unmask(pargs.run_args), blacklist, whitelist, pargs.preserve_image)
652+
_native_junit(native_image, unittest_args, unmask(pargs.build_args), unmask(pargs.run_args), blacklist, whitelist, pargs.preserve_image, pargs.force_builder_on_cp)
651653

652654

653655
def jvm_unittest(args):
@@ -1069,6 +1071,19 @@ def _native_image_launcher_extra_jvm_args():
10691071
jlink=False,
10701072
))
10711073

1074+
mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVMSvmMacro(
1075+
suite=suite,
1076+
name='Native Image JUnit with image-builder on classpath',
1077+
short_name='njucp',
1078+
dir_name='junitcp',
1079+
license_files=[],
1080+
third_party_license_files=[],
1081+
dependencies=['SubstrateVM'],
1082+
jar_distributions=['substratevm:JUNIT_SUPPORT', 'mx:JUNIT_TOOL', 'mx:JUNIT', 'mx:HAMCREST'],
1083+
support_distributions=['substratevm:NATIVE_IMAGE_JUNITCP_SUPPORT'],
1084+
jlink=False,
1085+
))
1086+
10721087
jar_distributions = [
10731088
'substratevm:GRAAL_HOTSPOT_LIBRARY',
10741089
'compiler:GRAAL_TRUFFLE_COMPILER_LIBGRAAL',

substratevm/mx.substratevm/suite.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,15 @@
15971597
},
15981598
},
15991599

1600+
"NATIVE_IMAGE_JUNITCP_SUPPORT" : {
1601+
"native" : True,
1602+
"description" : "Native-image based junit testing support but with running image-builder on classpath",
1603+
"layout" : {
1604+
"native-image.properties" : "file:mx.substratevm/macro-junitcp.properties",
1605+
"svm-junit.packages" : "file:mx.substratevm/svm-junit.packages",
1606+
},
1607+
},
1608+
16001609
"SVM_LLVM" : {
16011610
"subDir" : "src",
16021611
"description" : "LLVM backend for Native Image",

vm/mx.vm/ce-python

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Do not modify this env file without updating the Graal.Python benchmark builders
22
DYNAMIC_IMPORTS=/compiler,/graal-js,/regex,/sdk,/substratevm,/sulong,/tools,/truffle,graalpython
3-
COMPONENTS=cmp,cov,dap,dis,gu,gvm,icu4j,ins,insight,insightheap,js,lg,llp,llrc,llrl,llrn,lsp,nfi-libffi,ni,nic,nil,nju,pbm,pmh,poly,polynative,pro,pyn,pynl,rgx,sdk,svm,svml,svmnfi,tfl,tflm,vvm
3+
COMPONENTS=cmp,cov,dap,dis,gu,gvm,icu4j,ins,insight,insightheap,js,lg,llp,llrc,llrl,llrn,lsp,nfi-libffi,ni,nic,nil,nju,njucp,pbm,pmh,poly,polynative,pro,pyn,pynl,rgx,sdk,svm,svml,svmnfi,tfl,tflm,vvm
44
NATIVE_IMAGES=graalpython,lib:jvmcicompiler
55
DISABLE_INSTALLABLES=False

vm/mx.vm/ce-test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
DYNAMIC_IMPORTS=/compiler,/graal-js,/regex,/sdk,/substratevm,/sulong,/tools,/truffle
2-
COMPONENTS=cmp,cov,dap,dis,gu,gvm,icu4j,ins,insight,insightheap,js,lg,llp,llrc,llrl,llrn,lsp,nfi-libffi,ni,nic,nil,nju,poly,polynative,pro,rgx,sdk,svm,svml,svmnfi,tfl,tflm,vvm
2+
COMPONENTS=cmp,cov,dap,dis,gu,gvm,icu4j,ins,insight,insightheap,js,lg,llp,llrc,llrl,llrn,lsp,nfi-libffi,ni,nic,nil,nju,njucp,poly,polynative,pro,rgx,sdk,svm,svml,svmnfi,tfl,tflm,vvm
33
NATIVE_IMAGES=graalvm-native-binutil,graalvm-native-clang,graalvm-native-clang++,graalvm-native-ld,gu,lib:jsvm,lib:jvmcicompiler,lib:native-image-agent,lib:native-image-diagnostics-agent,lli,native-image,native-image-configure
44
DISABLE_INSTALLABLES=llp

vm/mx.vm/mx_vm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
ce_complete_components = ce_aarch64_complete_components + ['ellvm', 'pyn', 'R', 'bRMain', 'pynl']
148148
ce_darwin_aarch64_complete_components = ['bnative-image-configure', 'bpolyglot', 'cmp', 'cov', 'dap', 'ejvm', 'gu', 'gvm', 'icu4j', 'ins', 'insight', 'insightheap', 'java', 'js', 'lg', 'libpoly', 'llp', 'llrc', 'llrl', 'llrn', 'lsp', 'nfi', 'nfi-libffi', 'ni', 'nic', 'nil', 'poly', 'polynative', 'pro', 'rgx', 'sdk', 'spolyglot', 'svm', 'svmnfi', 'tfl', 'tflm', 'vvm']
149149
ce_ruby_components = ['cmp', 'cov', 'dap', 'gvm', 'ins', 'insight', 'insightheap', 'lg', 'llp', 'llrc', 'llrn', 'lsp', 'nfi-libffi', 'nfi', 'pro', 'rby', 'rbyl', 'rgx', 'sdk', 'svm', 'svmnfi', 'tfl', 'tflm', 'vvm']
150-
ce_python_components = ['bgraalvm-native-binutil', 'bgraalvm-native-clang', 'bgraalvm-native-clang++', 'bgraalvm-native-ld', 'bgu', 'sjsvm', 'blli', 'bnative-image', 'bnative-image-configure', 'bpolybench', 'bpolyglot', 'cmp', 'cov', 'dap', 'dis', 'gu', 'gvm', 'icu4j', 'ins', 'insight', 'insightheap', 'js', 'lg', 'libpoly', 'llp', 'llrc', 'llrl', 'llrn', 'lsp', 'nfi-libffi', 'nfi', 'ni', 'nic', 'nil', 'nju', 'pbm', 'pmh', 'poly', 'polynative', 'pro', 'pyn', 'pynl', 'rgx', 'sdk', 'snative-image-agent', 'snative-image-diagnostics-agent', 'spolyglot', 'svm', 'svml', 'svmnfi', 'tfl', 'tflm', 'vvm']
150+
ce_python_components = ['bgraalvm-native-binutil', 'bgraalvm-native-clang', 'bgraalvm-native-clang++', 'bgraalvm-native-ld', 'bgu', 'sjsvm', 'blli', 'bnative-image', 'bnative-image-configure', 'bpolybench', 'bpolyglot', 'cmp', 'cov', 'dap', 'dis', 'gu', 'gvm', 'icu4j', 'ins', 'insight', 'insightheap', 'js', 'lg', 'libpoly', 'llp', 'llrc', 'llrl', 'llrn', 'lsp', 'nfi-libffi', 'nfi', 'ni', 'nic', 'nil', 'nju', 'njucp', 'pbm', 'pmh', 'poly', 'polynative', 'pro', 'pyn', 'pynl', 'rgx', 'sdk', 'snative-image-agent', 'snative-image-diagnostics-agent', 'spolyglot', 'svm', 'svml', 'svmnfi', 'tfl', 'tflm', 'vvm']
151151
ce_fastr_components = ['R', 'bRMain', 'bgraalvm-native-binutil', 'bgraalvm-native-clang', 'bgraalvm-native-clang++', 'bgraalvm-native-ld', 'bgu', 'sjsvm', 'blli', 'bpolyglot', 'cmp', 'cov', 'dap', 'gu', 'gvm', 'icu4j', 'ins', 'insight', 'insightheap', 'js', 'lg', 'libpoly', 'llp', 'llrc', 'llrl', 'llrn', 'lsp', 'nfi-libffi', 'nfi', 'poly', 'polynative', 'pro', 'rgx', 'sdk', 'spolyglot', 'svm', 'svml', 'svmnfi', 'tfl', 'tflm', 'vvm']
152152
ce_no_native_components = ['bgu', 'sjsvm', 'blli', 'bgraalvm-native-clang', 'bgraalvm-native-clang++', 'bgraalvm-native-ld', 'bgraalvm-native-binutil', 'bnative-image', 'bnative-image-configure', 'bpolyglot', 'cmp', 'cov', 'dap', 'gu', 'gvm', 'icu4j', 'ins', 'insight', 'insightheap', 'js', 'lsp', 'nfi-libffi', 'nfi', 'ni', 'nic', 'nil', 'polynative', 'pro', 'rgx', 'sdk', 'llrc', 'llrn', 'llrl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'spolyglot', 'svm', 'svmnfi', 'svml', 'tfl', 'tflm', 'libpoly', 'poly', 'vvm']
153153

@@ -176,9 +176,9 @@
176176
mx_sdk_vm.register_vm_config('ce', ['bgraalvm-native-binutil', 'bgraalvm-native-clang', 'bgraalvm-native-clang++', 'bgraalvm-native-ld', 'blli', 'bnative-image', 'cmp', 'lg', 'llrc', 'llrl', 'llrn', 'nfi-libffi', 'nfi', 'ni', 'nil', 'pbm', 'pbi', 'sdk', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmnfi', 'tfl', 'tflm'], _suite, env_file='polybench-sulong-ce')
177177

178178
if mx.get_os() == 'windows':
179-
mx_sdk_vm.register_vm_config('svm', ['bnative-image', 'bnative-image-configure', 'bpolyglot', 'cmp', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'nic', 'poly', 'polynative', 'rgx', 'sdk', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmnfi', 'tfl', 'tflm'], _suite, env_file=False)
179+
mx_sdk_vm.register_vm_config('svm', ['bnative-image', 'bnative-image-configure', 'bpolyglot', 'cmp', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'njucp', 'nic', 'poly', 'polynative', 'rgx', 'sdk', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmnfi', 'tfl', 'tflm'], _suite, env_file=False)
180180
else:
181-
mx_sdk_vm.register_vm_config('svm', ['bnative-image', 'bnative-image-configure', 'bpolyglot', 'cmp', 'gu', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'nic', 'poly', 'polynative', 'rgx', 'sdk', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmnfi', 'svml', 'tfl', 'tflm'], _suite, env_file=False)
181+
mx_sdk_vm.register_vm_config('svm', ['bnative-image', 'bnative-image-configure', 'bpolyglot', 'cmp', 'gu', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'njucp', 'nic', 'poly', 'polynative', 'rgx', 'sdk', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmnfi', 'svml', 'tfl', 'tflm'], _suite, env_file=False)
182182
# pylint: enable=line-too-long
183183

184184

0 commit comments

Comments
 (0)