@@ -462,8 +462,12 @@ class TruffleGateTags:
462
462
dsl_max_state_bit_test = ['dsl-max-state-bit-test' , 'fulltest' ]
463
463
parser_test = ['parser-test' , 'test' , 'fulltest' ]
464
464
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' ]
467
471
468
472
def _truffle_gate_runner (args , tasks ):
469
473
jdk = mx .get_jdk (tag = mx .DEFAULT_JDK_TAG )
@@ -516,20 +520,34 @@ def gate_truffle_jvm(tasks):
516
520
if t :
517
521
sl_jvm_gate_tests (additional_jvm_args )
518
522
523
+
519
524
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
521
526
name_suffix = ' with quickbuild' if quickbuild else ''
527
+
522
528
with Task ('Truffle SL Native Fallback' + name_suffix , tasks , tags = tag ) as t :
523
529
if t :
524
530
sl_native_fallback_gate_tests (quickbuild )
531
+
525
532
with Task ('Truffle SL Native Optimized' + name_suffix , tasks , tags = tag ) as t :
526
533
if t :
527
534
sl_native_optimized_gate_tests (quickbuild )
535
+
536
+ tag = TruffleGateTags .unittest_native_quickbuild if quickbuild else TruffleGateTags .unittest_native
528
537
with Task ('Truffle API Native Tests' + name_suffix , tasks , tags = tag ) as t :
529
538
if t :
539
+ truffle_native_context_preinitialization_tests (quickbuild )
530
540
truffle_native_unit_tests_gate (True , quickbuild )
531
541
truffle_native_unit_tests_gate (False , quickbuild )
532
542
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
+
533
551
# Run with:
534
552
# mx -p ../vm --env ce build
535
553
# export JAVA_HOME=`mx -p ../vm --env ce --quiet --no-warning graalvm-home`
@@ -707,7 +725,15 @@ def _allow_runtime_reflection(for_types):
707
725
'-cp' , tmp ,
708
726
'--features=org.graalvm.junit.platform.JUnitPlatformFeature' ,
709
727
'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 )
711
737
712
738
# 4. Execute native unittests
713
739
test_results = os .path .join (tmp , 'test-results-native' , 'test' )
@@ -834,7 +860,21 @@ def sl_native_fallback_gate_tests(quick_build=False):
834
860
_sl_native_fallback_gate_tests (force_cp = True , quick_build = quick_build )
835
861
836
862
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
838
878
if use_optimized_runtime :
839
879
build_truffle_runtime_args = []
840
880
run_truffle_runtime_args = []
@@ -846,20 +886,18 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False
846
886
else :
847
887
build_optimize_args = []
848
888
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
-
857
889
# Run Truffle and NFI tests
858
890
test_packages = [
859
891
'com.oracle.truffle.api.test' ,
860
892
'com.oracle.truffle.api.staticobject.test' ,
861
- 'com.oracle.truffle.nfi .test' ,
893
+ 'com.oracle.truffle.sandbox.enterprise .test' ,
862
894
]
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
+
863
901
excluded_tests = [
864
902
'com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest' , # runs in its own image
865
903
'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
872
910
excluded_tests = excluded_tests + [
873
911
'com.oracle.truffle.api.test.TruffleSafepointTest' # GR-44492
874
912
]
875
- build_args = build_optimize_args + build_truffle_runtime_args + [
913
+ build_args = build_args + build_optimize_args + build_truffle_runtime_args + [
876
914
'-R:MaxHeapSize=2g' ,
877
915
'-H:MaxRuntimeCompileMethods=5000' ,
878
916
'--enable-url-protocols=http,jar' ,
@@ -881,7 +919,7 @@ def truffle_native_unit_tests_gate(use_optimized_runtime=True, quick_build=False
881
919
'--add-exports=org.graalvm.truffle/com.oracle.truffle.api.impl.asm=ALL-UNNAMED' ,
882
920
'--enable-native-access=org.graalvm.truffle' ,
883
921
]
884
- run_args = run_truffle_runtime_args + [
922
+ run_args = run_truffle_runtime_args + ([ '-Xss1m' ] if is_libc_musl else []) + [
885
923
mx_subst .path_substitutions .substitute ('-Dnative.test.path=<path:truffle:TRUFFLE_TEST_NATIVE>' ),
886
924
]
887
925
exclude_args = list (itertools .chain (* [('--exclude-class' , item ) for item in excluded_tests ]))
@@ -910,12 +948,11 @@ def _run_sl_tests(create_command):
910
948
base_name = os .path .splitext (f )[0 ]
911
949
test_file = join (test_path , base_name + '.sl' )
912
950
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
+
919
956
diff = compare_files (expected_file , temp .name )
920
957
if diff :
921
958
mx .log ("Failed command: {}" .format (" " .join (command )))
0 commit comments