Skip to content

Commit

Permalink
Reintroduce --macro:junitcp for truffle junit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olpaw committed Apr 6, 2022
1 parent 9b70e98 commit 139280e
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
11 changes: 11 additions & 0 deletions substratevm/mx.substratevm/macro-junitcp.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file contains support for building a set of junit tests into a native-image

ImageName = svmjunit

ImageClasspath = ${.}/junit-support.jar:${.}/junit-tool.jar:${.}/junit.jar:${.}/hamcrest.jar

Args = -H:Features=com.oracle.svm.junit.JUnitFeature \
-H:Class=com.oracle.svm.junit.SVMJUnitRunner \
-H:TestFile=${*} \
--initialize-at-build-time=org.junit,com.oracle.mxtool.junit.MxJUnitRequest \
[email protected]
29 changes: 22 additions & 7 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def image_demo_task(extra_image_args=None, flightrecorder=True):


def truffle_unittest_task(quickbuild=False):
truffle_build_args = ['--build-args', '--macro:truffle',
truffle_build_args = ['--force-builder-on-cp', '--build-args', '--macro:truffle',
'-H:MaxRuntimeCompileMethods=5000',
'-H:+TruffleCheckBlackListedMethods']
if quickbuild:
Expand Down Expand Up @@ -413,7 +413,7 @@ def svm_gate_body(args, tasks):
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
testlib = mx_subst.path_substitutions.substitute('-Dnative.test.lib=<path:truffle:TRUFFLE_TEST_NATIVE>/<lib:nativetest>')
isolation_testlib = mx_subst.path_substitutions.substitute('-Dnative.isolation.test.lib=<path:truffle:TRUFFLE_TEST_NATIVE>/<lib:isolationtest>')
native_unittest_args = ['com.oracle.truffle.nfi.test', '--build-args', '--language:nfi',
native_unittest_args = ['com.oracle.truffle.nfi.test', '--force-builder-on-cp', '--build-args', '--language:nfi',
'-H:MaxRuntimeCompileMethods=2000',
'-H:+TruffleCheckBlackListedMethods',
'--run-args', testlib, isolation_testlib, '--very-verbose', '--enable-timing']
Expand All @@ -424,7 +424,7 @@ def svm_gate_body(args, tasks):
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
testlib = mx_subst.path_substitutions.substitute('-Dnative.test.lib=<path:truffle:TRUFFLE_TEST_NATIVE>/<lib:nativetest>')
isolation_testlib = mx_subst.path_substitutions.substitute('-Dnative.isolation.test.lib=<path:truffle:TRUFFLE_TEST_NATIVE>/<lib:isolationtest>')
native_unittest_args = ['com.oracle.truffle.nfi.test', '--build-args', '--language:nfi',
native_unittest_args = ['com.oracle.truffle.nfi.test', '--force-builder-on-cp', '--build-args', '--language:nfi',
'-H:MaxRuntimeCompileMethods=2000',
'-H:+TruffleCheckBlackListedMethods'] + DEVMODE_FLAGS + [
'--run-args', testlib, isolation_testlib, '--very-verbose', '--enable-timing']
Expand Down Expand Up @@ -570,7 +570,7 @@ def javac_image_command(javac_path):
)


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

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

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

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


def jvm_unittest(args):
Expand Down Expand Up @@ -1069,6 +1071,19 @@ def _native_image_launcher_extra_jvm_args():
jlink=False,
))

mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVMSvmMacro(
suite=suite,
name='Native Image JUnit with image-builder on classpath',
short_name='njucp',
dir_name='junitcp',
license_files=[],
third_party_license_files=[],
dependencies=['SubstrateVM'],
jar_distributions=['substratevm:JUNIT_SUPPORT', 'mx:JUNIT_TOOL', 'mx:JUNIT', 'mx:HAMCREST'],
support_distributions=['substratevm:NATIVE_IMAGE_JUNITCP_SUPPORT'],
jlink=False,
))

jar_distributions = [
'substratevm:GRAAL_HOTSPOT_LIBRARY',
'compiler:GRAAL_TRUFFLE_COMPILER_LIBGRAAL',
Expand Down
9 changes: 9 additions & 0 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,15 @@
},
},

"NATIVE_IMAGE_JUNITCP_SUPPORT" : {
"native" : True,
"description" : "Native-image based junit testing support but with running image-builder on classpath",
"layout" : {
"native-image.properties" : "file:mx.substratevm/macro-junitcp.properties",
"svm-junit.packages" : "file:mx.substratevm/svm-junit.packages",
},
},

"SVM_LLVM" : {
"subDir" : "src",
"description" : "LLVM backend for Native Image",
Expand Down
2 changes: 1 addition & 1 deletion vm/mx.vm/ce-python
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Do not modify this env file without updating the Graal.Python benchmark builders
DYNAMIC_IMPORTS=/compiler,/graal-js,/regex,/sdk,/substratevm,/sulong,/tools,/truffle,graalpython
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
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
NATIVE_IMAGES=graalpython,lib:jvmcicompiler
DISABLE_INSTALLABLES=False
2 changes: 1 addition & 1 deletion vm/mx.vm/ce-test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DYNAMIC_IMPORTS=/compiler,/graal-js,/regex,/sdk,/substratevm,/sulong,/tools,/truffle
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
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
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
DISABLE_INSTALLABLES=llp
6 changes: 3 additions & 3 deletions vm/mx.vm/mx_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
ce_complete_components = ce_aarch64_complete_components + ['ellvm', 'pyn', 'R', 'bRMain', 'pynl']
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']
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']
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']
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']
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']
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']

Expand Down Expand Up @@ -176,9 +176,9 @@
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')

if mx.get_os() == 'windows':
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)
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)
else:
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)
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)
# pylint: enable=line-too-long


Expand Down

0 comments on commit 139280e

Please sign in to comment.