Skip to content

Commit 69f10d3

Browse files
committed
[GR-64753] Consolidate svm-enterprise-truffle-unittests and truffle-native gate.
PullRequest: graal/20729
2 parents 70972c3 + f88cf6e commit 69f10d3

File tree

4 files changed

+84
-49
lines changed

4 files changed

+84
-49
lines changed

sdk/mx.sdk/mx_sdk_vm_impl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3036,7 +3036,7 @@ def _get_jvm_cfg():
30363036
def _get_jvm_cfg_contents(cfgs_to_add):
30373037

30383038
def validate_cfg_line(line, source):
3039-
if line.startswith('#'):
3039+
if line.startswith('#') or len(line.strip()) == 0:
30403040
return
30413041
if not line.startswith('-'):
30423042
raise mx.abort("Invalid line in {}:\n{}".format(source, line))

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

+23-6
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,28 @@
112112
name: 'gate-truffle-ce-jvm-' + self.jdk_name + '-linux-amd64',
113113
},
114114

115+
# runs only truffle native unittests
116+
local truffle_native_unittest_gate = truffle_common + {
117+
gate_tag_suffix: '',
118+
run+: [
119+
['mx', '--no-jlinking', 'gate', '--no-warning-as-error', '--tags', 'build,unittest-native' + self.gate_tag_suffix],
120+
],
121+
notify_groups: ["truffle"],
122+
components+: ["truffle"],
123+
timelimit: '1:00:00',
124+
name: 'gate-truffle-ce-native-unittest' + self.gate_tag_suffix + '-jvm-' + self.jdk_name + '-' + self.os + '-' + self.arch,
125+
},
126+
127+
# runs native SL tests and truffle native unittests
115128
local truffle_native_gate = truffle_common + {
116129
gate_tag_suffix: '',
117130
run+: [
118131
['mx', '--no-jlinking', 'gate', '--no-warning-as-error', '--tags', 'build,truffle-native' + self.gate_tag_suffix],
119132
],
120133
notify_groups: ["truffle"],
121134
components+: ["truffle"],
122-
timelimit: '1:00:00',
123-
name: 'gate-truffle-ce-native' + self.gate_tag_suffix + '-jvm-' + self.jdk_name + '-linux-amd64',
135+
timelimit: '1:30:00',
136+
name: 'gate-truffle-ce-native' + self.gate_tag_suffix + '-jvm-' + self.jdk_name + '-' + self.os + '-' + self.arch,
124137
},
125138

126139
local truffle_gate = truffle_common + common.deps.eclipse + common.deps.jdt + common.deps.spotbugs {
@@ -153,12 +166,16 @@
153166
linux_amd64 + common.oraclejdk23 + truffle_jvm_gate,
154167
linux_amd64 + graalVMCELatest + truffle_jvm_gate,
155168
# Truffle Native gate
156-
linux_amd64 + common.graalvmee21 + truffle_native_gate,
157-
linux_amd64 + common.graalvmee21 + truffle_native_gate + {
169+
linux_amd64 + common.graalvmee21 + truffle_native_gate,
170+
linux_amd64 + common.graalvmee21 + truffle_native_gate + {
171+
gate_tag_suffix: '-quickbuild'
172+
},
173+
linux_amd64 + graalVMCELatest + truffle_native_gate,
174+
windows_amd64 + graalVMCELatest + devkits["windows-jdkLatest"] + truffle_native_unittest_gate,
175+
linux_amd64 + graalVMCELatest + truffle_native_gate + {
158176
gate_tag_suffix: '-quickbuild'
159177
},
160-
linux_amd64 + graalVMCELatest + truffle_native_gate,
161-
linux_amd64 + graalVMCELatest + truffle_native_gate + {
178+
windows_amd64 + graalVMCELatest + devkits["windows-jdkLatest"] + truffle_native_unittest_gate + {
162179
gate_tag_suffix: '-quickbuild'
163180
},
164181

truffle/mx.truffle/mx_truffle.py

+59-22
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,12 @@ class TruffleGateTags:
462462
dsl_max_state_bit_test = ['dsl-max-state-bit-test', 'fulltest']
463463
parser_test = ['parser-test', 'test', 'fulltest']
464464
truffle_jvm = ['truffle-jvm']
465-
truffle_native = ['truffle-native']
466-
truffle_native_quickbuild = ['truffle-native-quickbuild']
465+
sl_native = ['sl-native', 'truffle-native']
466+
sl_native_quickbuild = ['sl-native-quickbuild', 'truffle-native-quickbuild']
467+
unittest_native = ['unittest-native', 'truffle-native']
468+
unittest_native_quickbuild = ['unittest-native-quickbuild', 'truffle-native-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,34 @@ def gate_truffle_jvm(tasks):
516520
if t:
517521
sl_jvm_gate_tests(additional_jvm_args)
518522

523+
519524
def gate_truffle_native(tasks, quickbuild=False):
520-
tag = TruffleGateTags.truffle_native_quickbuild if quickbuild else TruffleGateTags.truffle_native
525+
tag = TruffleGateTags.sl_native_quickbuild if quickbuild else TruffleGateTags.sl_native
521526
name_suffix = ' with quickbuild' if quickbuild else ''
527+
522528
with Task('Truffle SL Native Fallback' + name_suffix, tasks, tags=tag) as t:
523529
if t:
524530
sl_native_fallback_gate_tests(quickbuild)
531+
525532
with Task('Truffle SL Native Optimized' + name_suffix, tasks, tags=tag) as t:
526533
if t:
527534
sl_native_optimized_gate_tests(quickbuild)
535+
536+
tag = TruffleGateTags.unittest_native_quickbuild if quickbuild else TruffleGateTags.unittest_native
528537
with Task('Truffle API Native Tests' + name_suffix, tasks, tags=tag) as t:
529538
if t:
539+
truffle_native_context_preinitialization_tests(quickbuild)
530540
truffle_native_unit_tests_gate(True, quickbuild)
531541
truffle_native_unit_tests_gate(False, quickbuild)
532542

543+
tag = TruffleGateTags.truffle_native_libcmusl_static_quickbuild if quickbuild else TruffleGateTags.truffle_native_libcmusl_static
544+
with Task('Truffle API Native Tests with static libc musl' + name_suffix, tasks, tags=tag) as t:
545+
if t:
546+
truffle_native_unit_tests_gate(True, False, [
547+
"--libc=musl",
548+
"--static"
549+
])
550+
533551
# Run with:
534552
# mx -p ../vm --env ce build
535553
# export JAVA_HOME=`mx -p ../vm --env ce --quiet --no-warning graalvm-home`
@@ -707,7 +725,15 @@ def _allow_runtime_reflection(for_types):
707725
'-cp', tmp,
708726
'--features=org.graalvm.junit.platform.JUnitPlatformFeature',
709727
'org.graalvm.junit.platform.NativeImageJUnitLauncher']
710-
mx.run([native_image] + vm_args + native_image_args)
728+
729+
# Use an argument file to avoid exceeding the command-line length limit on Windows
730+
with tempfile.NamedTemporaryFile(mode='w', delete=False) as args_file:
731+
for arg in vm_args + native_image_args:
732+
args_file.write(arg)
733+
args_file.write(os.linesep)
734+
mx.run([native_image, '@' + args_file.name])
735+
# delete file only on success
736+
os.unlink(args_file.name)
711737

712738
# 4. Execute native unittests
713739
test_results = os.path.join(tmp, 'test-results-native', 'test')
@@ -834,7 +860,21 @@ def sl_native_fallback_gate_tests(quick_build=False):
834860
_sl_native_fallback_gate_tests(force_cp=True, quick_build=quick_build)
835861

836862

837-
def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False):
863+
def truffle_native_context_preinitialization_tests(quick_build=False, build_args=None):
864+
# ContextPreInitializationNativeImageTest can only run with its own image.
865+
# See class javadoc for details.
866+
# Context pre-initialization is supported only in optimized runtime.
867+
# See TruffleFeature for details.
868+
use_build_args = build_args if build_args else []
869+
if quick_build:
870+
use_build_args = use_build_args + ['-Ob']
871+
native_truffle_unittest(['com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest'] + ['--build-args'] + use_build_args)
872+
873+
874+
def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False, build_args=None):
875+
build_args = build_args if build_args else []
876+
is_libc_musl = '--libc=musl' in build_args
877+
is_static = '--static' in build_args
838878
if use_optimized_runtime:
839879
build_truffle_runtime_args = []
840880
run_truffle_runtime_args = []
@@ -846,20 +886,18 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False
846886
else:
847887
build_optimize_args = []
848888

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-
857889
# Run Truffle and NFI tests
858890
test_packages = [
859891
'com.oracle.truffle.api.test',
860892
'com.oracle.truffle.api.staticobject.test',
861-
'com.oracle.truffle.nfi.test',
893+
'com.oracle.truffle.sandbox.enterprise.test',
862894
]
895+
if not is_static:
896+
# static executable does not support dynamic library loading required by NFI tests
897+
test_packages += [
898+
'com.oracle.truffle.nfi.test',
899+
]
900+
863901
excluded_tests = [
864902
'com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest', # runs in its own image
865903
'com.oracle.truffle.api.test.profiles.*', # GR-52260
@@ -872,7 +910,7 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False
872910
excluded_tests = excluded_tests + [
873911
'com.oracle.truffle.api.test.TruffleSafepointTest' # GR-44492
874912
]
875-
build_args = build_optimize_args + build_truffle_runtime_args + [
913+
build_args = build_args + build_optimize_args + build_truffle_runtime_args + [
876914
'-R:MaxHeapSize=2g',
877915
'-H:MaxRuntimeCompileMethods=5000',
878916
'--enable-url-protocols=http,jar',
@@ -881,7 +919,7 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False
881919
'--add-exports=org.graalvm.truffle/com.oracle.truffle.api.impl.asm=ALL-UNNAMED',
882920
'--enable-native-access=org.graalvm.truffle',
883921
]
884-
run_args = run_truffle_runtime_args + [
922+
run_args = run_truffle_runtime_args + (['-Xss1m'] if is_libc_musl else []) + [
885923
mx_subst.path_substitutions.substitute('-Dnative.test.path=<path:truffle:TRUFFLE_TEST_NATIVE>'),
886924
]
887925
exclude_args = list(itertools.chain(*[('--exclude-class', item) for item in excluded_tests]))
@@ -910,12 +948,11 @@ def _run_sl_tests(create_command):
910948
base_name = os.path.splitext(f)[0]
911949
test_file = join(test_path, base_name + '.sl')
912950
expected_file = join(test_path, base_name + '.output')
913-
temp = tempfile.NamedTemporaryFile(delete=False)
914-
command = create_command(test_file)
915-
mx.log("Running SL test {}".format(test_file))
916-
with open(temp.name, 'w') as out:
917-
mx.run(command, nonZeroIsFatal=False, out=out, err=out)
918-
out.flush()
951+
with tempfile.NamedTemporaryFile(delete=False) as temp:
952+
command = create_command(test_file)
953+
mx.log("Running SL test {}".format(test_file))
954+
mx.run(command, nonZeroIsFatal=False, out=temp, err=temp)
955+
919956
diff = compare_files(expected_file, temp.name)
920957
if diff:
921958
mx.log("Failed command: {}".format(" ".join(command)))

0 commit comments

Comments
 (0)