Skip to content

Commit 7aff7ed

Browse files
committed
[GR-64753] Consolidate svm-enterprise-truffle-unittests and truffle-native gate.
1 parent 9da64df commit 7aff7ed

File tree

3 files changed

+79
-38
lines changed

3 files changed

+79
-38
lines changed

substratevm/mx.substratevm/mx_substratevm.py

+1-20
Original file line numberDiff line numberDiff line change
@@ -375,21 +375,6 @@ def truffle_args(extra_build_args):
375375

376376
def truffle_unittest_task(extra_build_args=None):
377377
extra_build_args = extra_build_args or []
378-
379-
# ContextPreInitializationNativeImageTest can only run with its own image.
380-
# See class javadoc for details.
381-
truffle_context_pre_init_unittest_task(extra_build_args)
382-
383-
# Regular Truffle tests that can run with isolated compilation
384-
truffle_tests = ['com.oracle.truffle.api.staticobject.test',
385-
'com.oracle.truffle.api.test.polyglot.ContextPolicyTest']
386-
387-
if '-Ob' not in extra_build_args:
388-
# GR-44492:
389-
truffle_tests += ['com.oracle.truffle.api.test.TruffleSafepointTest']
390-
391-
native_unittest(truffle_tests + truffle_args(extra_build_args) + (['-Xss1m'] if '--libc=musl' in extra_build_args else []))
392-
393378
# White Box Truffle compilation tests that need access to compiler graphs.
394379
if '-Ob' not in extra_build_args:
395380
# GR-44492
@@ -419,10 +404,6 @@ def truffle_unittest_task(extra_build_args=None):
419404
os.unlink(logfile.name)
420405

421406

422-
def truffle_context_pre_init_unittest_task(extra_build_args):
423-
native_unittest(['com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest'] + truffle_args(extra_build_args))
424-
425-
426407
def svm_gate_body(args, tasks):
427408
with Task('image demos', tasks, tags=[GraalTags.helloworld]) as t:
428409
if t:
@@ -456,7 +437,7 @@ def svm_gate_body(args, tasks):
456437
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
457438
conditional_config_task(native_image)
458439

459-
with Task('Run Truffle unittests with SVM image', tasks, tags=[GraalTags.truffle_unittests]) as t:
440+
with Task('Run Truffle Compiler unittests with SVM image', tasks, tags=[GraalTags.truffle_unittests]) as t:
460441
if t:
461442
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
462443
truffle_unittest_task(args.extra_image_builder_arguments)

truffle/ci/ci.jsonnet

+10-6
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@
119119
],
120120
notify_groups: ["truffle"],
121121
components+: ["truffle"],
122-
timelimit: '1:00:00',
123-
name: 'gate-truffle-ce-native' + self.gate_tag_suffix + '-jvm-' + self.jdk_name + '-linux-amd64',
122+
timelimit: '1:30:00',
123+
name: 'gate-truffle-ce-native' + self.gate_tag_suffix + '-jvm-' + self.jdk_name + '-' + self.os + '-' + self.arch,
124124
},
125125

126126
local truffle_gate = truffle_common + common.deps.eclipse + common.deps.jdt + common.deps.spotbugs {
@@ -153,12 +153,16 @@
153153
linux_amd64 + common.oraclejdk23 + truffle_jvm_gate,
154154
linux_amd64 + graalVMCELatest + truffle_jvm_gate,
155155
# Truffle Native gate
156-
linux_amd64 + common.graalvmee21 + truffle_native_gate,
157-
linux_amd64 + common.graalvmee21 + truffle_native_gate + {
156+
linux_amd64 + common.graalvmee21 + truffle_native_gate,
157+
linux_amd64 + common.graalvmee21 + truffle_native_gate + {
158158
gate_tag_suffix: '-quickbuild'
159159
},
160-
linux_amd64 + graalVMCELatest + truffle_native_gate,
161-
linux_amd64 + graalVMCELatest + truffle_native_gate + {
160+
linux_amd64 + graalVMCELatest + truffle_native_gate,
161+
windows_amd64 + graalVMCELatest + devkits["windows-jdkLatest"] + truffle_native_gate,
162+
linux_amd64 + graalVMCELatest + truffle_native_gate + {
163+
gate_tag_suffix: '-quickbuild'
164+
},
165+
windows_amd64 + graalVMCELatest + devkits["windows-jdkLatest"] + truffle_native_gate + {
162166
gate_tag_suffix: '-quickbuild'
163167
},
164168

truffle/mx.truffle/mx_truffle.py

+68-12
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ class TruffleGateTags:
464464
truffle_jvm = ['truffle-jvm']
465465
truffle_native = ['truffle-native']
466466
truffle_native_quickbuild = ['truffle-native-quickbuild']
467+
truffle_native_memory_fencing = ['truffle-native-memory-fencing']
468+
truffle_native_memory_fencing_quickbuild = ['truffle-native-memory-fencing-quickbuild']
469+
truffle_native_libcmusl_static = ['truffle-native-libcmusl-static']
470+
truffle_native_libcmusl_static_quickbuild = ['truffle-native-libcmusl-static-quickbuild']
467471

468472
def _truffle_gate_runner(args, tasks):
469473
jdk = mx.get_jdk(tag=mx.DEFAULT_JDK_TAG)
@@ -516,20 +520,60 @@ def gate_truffle_jvm(tasks):
516520
if t:
517521
sl_jvm_gate_tests(additional_jvm_args)
518522

523+
524+
def _native_image_supports_option(option):
525+
native_image = _native_image(mx.get_jdk(tag='graalvm'))
526+
out = mx.LinesOutputCapture()
527+
mx.run([native_image, '--expert-options-all'], out=out)
528+
for line in out.lines:
529+
if option in line:
530+
return True
531+
return False
532+
533+
519534
def gate_truffle_native(tasks, quickbuild=False):
520535
tag = TruffleGateTags.truffle_native_quickbuild if quickbuild else TruffleGateTags.truffle_native
521536
name_suffix = ' with quickbuild' if quickbuild else ''
537+
522538
with Task('Truffle SL Native Fallback' + name_suffix, tasks, tags=tag) as t:
523539
if t:
524540
sl_native_fallback_gate_tests(quickbuild)
541+
525542
with Task('Truffle SL Native Optimized' + name_suffix, tasks, tags=tag) as t:
526543
if t:
527544
sl_native_optimized_gate_tests(quickbuild)
545+
528546
with Task('Truffle API Native Tests' + name_suffix, tasks, tags=tag) as t:
529547
if t:
548+
truffle_native_context_preinitialization_tests(quickbuild)
549+
# Test that the static object model can deal with non-long aligned byte array base offsets (GR-43403)
550+
if _native_image_supports_option('OptionalIdentityHashCodes'):
551+
truffle_native_context_preinitialization_tests(quickbuild, [
552+
'-H:+UnlockExperimentalVMOptions',
553+
'-H:-OptionalIdentityHashCodes',
554+
'-H:-UnlockExperimentalVMOptions'
555+
])
530556
truffle_native_unit_tests_gate(True, quickbuild)
531557
truffle_native_unit_tests_gate(False, quickbuild)
532558

559+
tag = TruffleGateTags.truffle_native_memory_fencing_quickbuild if quickbuild else TruffleGateTags.truffle_native_memory_fencing
560+
with Task('Truffle API Native Tests with MemoryMaskingAndFencing mitigation' + name_suffix, tasks, tags=tag) as t:
561+
if t:
562+
if _native_image_supports_option('MemoryMaskingAndFencing'):
563+
truffle_native_unit_tests_gate(True, False, [
564+
'-H:+UnlockExperimentalVMOptions',
565+
'-R:+MemoryMaskingAndFencing',
566+
'-H:-UnlockExperimentalVMOptions'
567+
])
568+
569+
tag = TruffleGateTags.truffle_native_libcmusl_static_quickbuild if quickbuild else TruffleGateTags.truffle_native_libcmusl_static
570+
with Task('Truffle API Native Tests with static libc musl' + name_suffix, tasks, tags=tag) as t:
571+
if t:
572+
truffle_native_unit_tests_gate(True, False, [
573+
"--libc=musl",
574+
"--static"
575+
])
576+
533577
# Run with:
534578
# mx -p ../vm --env ce build
535579
# export JAVA_HOME=`mx -p ../vm --env ce --quiet --no-warning graalvm-home`
@@ -834,7 +878,21 @@ def sl_native_fallback_gate_tests(quick_build=False):
834878
_sl_native_fallback_gate_tests(force_cp=True, quick_build=quick_build)
835879

836880

837-
def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False):
881+
def truffle_native_context_preinitialization_tests(quick_build=False, build_args=None):
882+
# ContextPreInitializationNativeImageTest can only run with its own image.
883+
# See class javadoc for details.
884+
# Context pre-initialization is supported only in optimized runtime.
885+
# See TruffleFeature for details.
886+
use_build_args = build_args if build_args else []
887+
if quick_build:
888+
use_build_args = use_build_args + ['-Ob']
889+
native_truffle_unittest(['com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest'] + ['--build-args'] + use_build_args)
890+
891+
892+
def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False, build_args=None):
893+
build_args = build_args if build_args else []
894+
is_libc_musl = '--libc=musl' in build_args
895+
is_static = '--static' in build_args
838896
if use_optimized_runtime:
839897
build_truffle_runtime_args = []
840898
run_truffle_runtime_args = []
@@ -846,20 +904,18 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False
846904
else:
847905
build_optimize_args = []
848906

849-
# ContextPreInitializationNativeImageTest can only run with its own image.
850-
# See class javadoc for details.
851-
# Context pre-initialization is supported only in optimized runtime.
852-
# See TruffleFeature for details.
853-
if use_optimized_runtime:
854-
native_truffle_unittest(['com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest'] +
855-
['--build-args'] + build_optimize_args)
856-
857907
# Run Truffle and NFI tests
858908
test_packages = [
859909
'com.oracle.truffle.api.test',
860910
'com.oracle.truffle.api.staticobject.test',
861-
'com.oracle.truffle.nfi.test',
911+
'com.oracle.truffle.sandbox.enterprise.test',
862912
]
913+
if not is_static:
914+
# static executable does not support dynamic library loading required by NFI tests
915+
test_packages += [
916+
'com.oracle.truffle.nfi.test',
917+
]
918+
863919
excluded_tests = [
864920
'com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest', # runs in its own image
865921
'com.oracle.truffle.api.test.profiles.*', # GR-52260
@@ -872,7 +928,7 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False
872928
excluded_tests = excluded_tests + [
873929
'com.oracle.truffle.api.test.TruffleSafepointTest' # GR-44492
874930
]
875-
build_args = build_optimize_args + build_truffle_runtime_args + [
931+
build_args = build_args + build_optimize_args + build_truffle_runtime_args + [
876932
'-R:MaxHeapSize=2g',
877933
'-H:MaxRuntimeCompileMethods=5000',
878934
'--enable-url-protocols=http,jar',
@@ -881,7 +937,7 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False
881937
'--add-exports=org.graalvm.truffle/com.oracle.truffle.api.impl.asm=ALL-UNNAMED',
882938
'--enable-native-access=org.graalvm.truffle',
883939
]
884-
run_args = run_truffle_runtime_args + [
940+
run_args = run_truffle_runtime_args + (['-Xss1m'] if is_libc_musl else []) + [
885941
mx_subst.path_substitutions.substitute('-Dnative.test.path=<path:truffle:TRUFFLE_TEST_NATIVE>'),
886942
]
887943
exclude_args = list(itertools.chain(*[('--exclude-class', item) for item in excluded_tests]))

0 commit comments

Comments
 (0)