Skip to content

Commit

Permalink
[GR-53769] The native-truffle-unittest command should use enterprise …
Browse files Browse the repository at this point in the history
…Truffle runtime when available.

PullRequest: graal/17642
  • Loading branch information
tzezula committed May 10, 2024
2 parents 9c89605 + 20e8b54 commit 37938da
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion truffle/mx.truffle/mx_truffle.py
Expand Up @@ -538,6 +538,7 @@ def _split_command_line_arguments(build_args):
try:
jdk = mx.get_jdk(tag='graalvm')
unittest_distributions = ['mx:JUNIT-PLATFORM-NATIVE']
truffle_runtime_distributions = resolve_truffle_dist_names(True, True)
test_classes_file = os.path.join(tmp, 'test_classes.txt')

def collect_unittest_distributions(test_deps, vm_launcher, vm_args):
Expand All @@ -556,7 +557,7 @@ def collect_unittest_distributions(test_deps, vm_launcher, vm_args):
'-Djunit.platform.listeners.uid.tracking.enabled=true',
f'-Djunit.platform.listeners.uid.tracking.output.dir={os.path.join(tmp, "test-ids")}'
]
vm_args = enable_asserts_args + uid_tracking_args + mx.get_runtime_jvm_args(names=unittest_distributions) + module_args
vm_args = enable_asserts_args + uid_tracking_args + mx.get_runtime_jvm_args(names=unittest_distributions + truffle_runtime_distributions) + module_args

# 2. Collect test ids for a native image build
junit_console_launcher_with_args = [
Expand Down
2 changes: 0 additions & 2 deletions truffle/mx.truffle/suite.py
Expand Up @@ -1498,7 +1498,6 @@
"distDependencies" : [
"sdk:POLYGLOT",
"TRUFFLE_API",
"TRUFFLE_RUNTIME",
"TRUFFLE_SL",
"TRUFFLE_MODULARIZED_TEST_SEPARATE_MODULE_TEST",
],
Expand Down Expand Up @@ -2174,7 +2173,6 @@
],
"distDependencies" : [
"TRUFFLE_API",
"TRUFFLE_RUNTIME",
"TRUFFLE_SL",
"TRUFFLE_TCK_COMMON",
"TRUFFLE_TCK_TESTS",
Expand Down
Expand Up @@ -53,6 +53,7 @@
import java.util.Properties;
import java.util.Set;

import com.oracle.truffle.tck.tests.TruffleTestAssumptions;
import org.graalvm.options.OptionCategory;
import org.graalvm.options.OptionDescriptors;
import org.graalvm.options.OptionKey;
Expand Down Expand Up @@ -147,7 +148,9 @@ private static boolean supportsPolyglotIsolates() {

private static boolean supportsSandboxInstrument() {
try (Engine engine = Engine.create()) {
return engine.getInstruments().containsKey("sandbox");
// Polyglot sandbox limits can only be used with runtimes that support enterprise
// extensions.
return engine.getInstruments().containsKey("sandbox") && TruffleTestAssumptions.isEnterpriseRuntime();
}
}

Expand Down
Expand Up @@ -43,6 +43,8 @@
import org.graalvm.polyglot.Engine;
import org.junit.Assume;

import java.util.regex.Pattern;

public class TruffleTestAssumptions {
private static final boolean spawnIsolate = Boolean.getBoolean("polyglot.engine.SpawnIsolate");
private static final boolean aot = Boolean.getBoolean("com.oracle.graalvm.isaot");
Expand Down Expand Up @@ -101,6 +103,19 @@ public static boolean isOptimizingRuntime() {
return optimizing;
}

private static volatile Boolean enterpriseRuntimeUsed;

public static boolean isEnterpriseRuntime() {
Boolean enterprise = enterpriseRuntimeUsed;
if (enterprise == null) {
try (Engine e = Engine.create()) {
enterprise = Pattern.compile("Oracle GraalVM( Isolated)?").matcher(e.getImplementationName()).matches();
enterpriseRuntimeUsed = enterprise;
}
}
return enterprise;
}

public static boolean isWeakEncapsulation() {
return !isIsolateEncapsulation() && !isClassLoaderEncapsulation();
}
Expand Down

0 comments on commit 37938da

Please sign in to comment.