From 716d47ee959542dc8b1fca5d3668696cabf22548 Mon Sep 17 00:00:00 2001 From: Anna Babu Palathingal Date: Wed, 8 Nov 2023 15:11:50 -0500 Subject: [PATCH] User specfic extra_options appended to JVM options - Append user specified jvmOpts to exisitng jvm options - Added the null pointer check for other options and jvm options resolves : https://github.com/adoptium/aqa-tests/issues/4849 Signed-off-by: Anna Babu Palathingal --- jck/jtrunner/JavaTestRunner.java | 24 ++++++++++++++++-------- jck/jtrunner/JavatestUtil.java | 21 +++++++++++++++------ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/jck/jtrunner/JavaTestRunner.java b/jck/jtrunner/JavaTestRunner.java index 1e606ea8de..a8b0b5fc99 100644 --- a/jck/jtrunner/JavaTestRunner.java +++ b/jck/jtrunner/JavaTestRunner.java @@ -49,7 +49,7 @@ public class JavaTestRunner { private static String testExecutionType; private static String withAgent; private static String interactive; - private static String extraJvmOptions; + private static String extraJvmOptions = ""; private static String concurrencyString; private static String jckVersion; private static String config; @@ -168,8 +168,16 @@ public static void main(String args[]) throws Exception { } } } - - jvmOpts = System.getProperty("jvm.options").trim() + " " + System.getProperty("other.opts"); + + String otherOptions = System.getProperty("other.options"); + String jvmOptions = System.getProperty("jvm.options"); + if (otherOptions != null) { + jvmOpts += otherOptions.trim() + " "; + } + + if (jvmOptions != null) { + jvmOpts += jvmOptions.trim() + " "; + } task = testArgs.get(TASK); customJtx = testArgs.get(CUSTOM_JTX); spec = testArgs.get(SPEC); @@ -491,8 +499,6 @@ public static boolean jckConfigurationForMultijvmWithNoAgent() throws Exception String robotAvailable = ""; String hostname = ""; String ipAddress = ""; - extraJvmOptions = jvmOpts; - InetAddress addr = InetAddress.getLocalHost(); ipAddress = addr.getHostAddress(); hostname = addr.getHostName(); @@ -731,7 +737,7 @@ public static boolean jckConfigurationForMultijvmWithNoAgent() throws Exception } // Add the JVM options supplied by the user plus those added in this method to the jtb file option. - fileContent += "set jck.env.runtime.testExecute.otherOpts \" " + extraJvmOptions + " \"" + ";\n"; + fileContent += "set jck.env.runtime.testExecute.otherOpts \" " + extraJvmOptions + " " + jvmOpts + " \"" + ";\n"; // Tests that need Display on OSX also require AWT_FORCE_HEADFUL=true if (spec.contains("osx")) { @@ -800,13 +806,14 @@ public static boolean jckConfigurationForMultijvmWithNoAgent() throws Exception } extraJvmOptions += suppressOutOfMemoryDumpOptions; + if (jckVersionInt > 11) { extraJvmOptions += " --enable-preview -Xfuture "; } // Add the JVM options supplied by the user plus those added in this method to the jtb file option. - fileContent += "set jck.env.compiler.compRefExecute.otherOpts \" " + extraJvmOptions + " \"" + ";\n"; + fileContent += "set jck.env.compiler.compRefExecute.otherOpts \" " + extraJvmOptions + " " + jvmOpts + " \"" + ";\n"; } // Devtools settings if (testSuite.equals("DEVTOOLS")) { @@ -893,9 +900,10 @@ public static boolean jckConfigurationForMultijvmWithNoAgent() throws Exception extraJvmOptions += getTestSpecificJvmOptions(jckVersion, tests); extraJvmOptions += suppressOutOfMemoryDumpOptions; + // Add the JVM options supplied by the user plus those added in this method to the jtb file option. - fileContent += "set jck.env.devtools.refExecute.otherOpts \" " + extraJvmOptions + " \"" + ";\n"; + fileContent += "set jck.env.devtools.refExecute.otherOpts \" " + extraJvmOptions + " " + jvmOpts + " \"" + ";\n"; } return true; } diff --git a/jck/jtrunner/JavatestUtil.java b/jck/jtrunner/JavatestUtil.java index 7c5a952b2c..e0d18a3679 100644 --- a/jck/jtrunner/JavatestUtil.java +++ b/jck/jtrunner/JavatestUtil.java @@ -51,7 +51,7 @@ public class JavatestUtil { private static String testExecutionType; private static String withAgent; private static String interactive; - private static String extraJvmOptions; + private static String extraJvmOptions = ""; private static String concurrencyString; private static String jckVersion; private static String config; @@ -177,7 +177,14 @@ public static void main(String args[]) throws Exception { } } - jvmOpts = System.getProperty("jvm.options").trim() + " " + System.getProperty("other.opts"); + String otherOptions = System.getProperty("other.options"); + String jvmOptions = System.getProperty("jvm.options"); + if (otherOptions != null) { + jvmOpts += otherOptions.trim() + " "; + } + if (jvmOptions != null) { + jvmOpts += jvmOptions.trim() + " "; + } testFlag = System.getenv("TEST_FLAG"); task = testArgs.get(TASK).trim(); customJtx = testArgs.get(CUSTOM_JTX) == null ? "" : testArgs.get(CUSTOM_JTX); @@ -419,7 +426,6 @@ private static boolean generateJTB() throws Exception { String robotAvailable = ""; String hostname = ""; String ipAddress = ""; - extraJvmOptions = jvmOpts; // Use escaped backslashes for paths on Windows if (spec.contains("win")) { @@ -664,13 +670,14 @@ private static boolean generateJTB() throws Exception { // Get any additional jvm options for specific tests. extraJvmOptions += getTestSpecificJvmOptions(jckVersion, tests); extraJvmOptions += suppressOutOfMemoryDumpOptions; + if (jckVersionInt > 11) { extraJvmOptions += " --enable-preview -Xfuture "; } // Add the JVM options supplied by the user plus those added in this method to the jtb file option. - fileContent += "set jck.env.runtime.testExecute.otherOpts \" " + extraJvmOptions + " \"" + ";\n"; + fileContent += "set jck.env.runtime.testExecute.otherOpts \" " + extraJvmOptions + " " + jvmOpts + " \"" + ";\n"; // Tests that need Display on OSX also require AWT_FORCE_HEADFUL=true if (spec.contains("osx")) { @@ -746,6 +753,7 @@ private static boolean generateJTB() throws Exception { } extraJvmOptions += suppressOutOfMemoryDumpOptions; + if (jckVersionInt > 11) { extraJvmOptions += " --enable-preview -Xfuture "; @@ -753,7 +761,7 @@ private static boolean generateJTB() throws Exception { // Add the JVM options supplied by the user plus those added in this method to the jtb file option. if (!testExecutionType.equals("multijvm")) { - fileContent += "set jck.env.compiler.compRefExecute.otherOpts \" " + extraJvmOptions + " \"" + ";\n"; + fileContent += "set jck.env.compiler.compRefExecute.otherOpts \" " + extraJvmOptions + " " + jvmOpts + " \"" + ";\n"; } } // Devtools settings @@ -839,9 +847,10 @@ private static boolean generateJTB() throws Exception { // Get any additional jvm options for specific tests. extraJvmOptions += getTestSpecificJvmOptions(jckVersion, tests); extraJvmOptions += suppressOutOfMemoryDumpOptions; + // Add the JVM options supplied by the user plus those added in this method to the jtb file option. - fileContent += "set jck.env.devtools.refExecute.otherOpts \" " + extraJvmOptions + " \"" + ";\n"; + fileContent += "set jck.env.devtools.refExecute.otherOpts \" " + extraJvmOptions + " " + jvmOpts + " \"" + ";\n"; } // Only use default initial jtx exclude and disregard the rest of jck exclude lists