< prev index next >

test/hotspot/jtreg/compiler/graalunit/common/GraalUnitTestLauncher.java

Print this page


   1 /*
   2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


 224 
 225         ArrayList<String> javaFlags = new ArrayList<String>();
 226 
 227         // add modules and exports
 228         javaFlags.add("--add-modules");
 229         javaFlags.add("jdk.internal.vm.compiler,jdk.internal.vm.ci");
 230         javaFlags.add("--add-exports");
 231         javaFlags.add("java.base/jdk.internal.module=ALL-UNNAMED");
 232         javaFlags.addAll(getModuleExports("jdk.internal.vm.compiler", "ALL-UNNAMED"));
 233         javaFlags.addAll(getModuleExports("jdk.internal.vm.ci", "ALL-UNNAMED,jdk.internal.vm.compiler"));
 234 
 235 
 236         // add VM flags
 237         javaFlags.add("-XX:+UnlockExperimentalVMOptions");
 238         javaFlags.add("-XX:+EnableJVMCI");
 239         javaFlags.add("-Djava.awt.headless=true");
 240         javaFlags.add("-esa");
 241         javaFlags.add("-ea");
 242         // Make sure exception message is never null
 243         javaFlags.add("-XX:-OmitStackTraceInFastThrow");
 244         // set timeout factor based on jtreg harness settings
 245         javaFlags.add("-Dgraaltest.timeout.factor=" + System.getProperty("test.timeout.factor", "1.0"));
 246 
 247         // generate class path
 248         ArrayList<String> graalJars = new ArrayList<String>(Arrays.asList(GRAAL_EXTRA_JARS));
 249         graalJars.add(MXTOOL_JARFILE);
 250         graalJars.add(GRAAL_UNITTESTS_JARFILE);
 251 
 252         String graalJarsCP = graalJars.stream()
 253                                       .map(s -> String.join(File.separator, libsDir, s))
 254                                       .collect(Collectors.joining(File.pathSeparator));
 255 
 256         javaFlags.add("-cp");
 257         // Existing classpath returned by System.getProperty("java.class.path") may contain another
 258         // version of junit with which the jtreg tool is built. It may be incompatible with required
 259         // junit version. So we put graalJarsCP before existing classpath when generating a new one
 260         // to avoid incompatibility issues.
 261         javaFlags.add(String.join(File.pathSeparator, graalJarsCP, System.getProperty("java.class.path")));
 262 
 263         //
 264         javaFlags.add("com.oracle.mxtool.junit.MxJUnitWrapper");
 265         javaFlags.add("-JUnitVerbose");
 266         javaFlags.add("-JUnitEagerStackTrace");
 267         javaFlags.add("-JUnitEnableTiming");
 268 
 269         javaFlags.add("@"+GENERATED_TESTCLASSES_FILENAME);
 270 
 271         ProcessBuilder javaPB = ProcessTools.createJavaProcessBuilder(true,
 272                 javaFlags.toArray(new String[javaFlags.size()]));
 273 
 274         // Some tests rely on MX_SUBPROCESS_COMMAND_FILE env variable which contains
 275         // name of the file with java executable and java args used to launch the current process.
 276         Path cmdFile = Files.createTempFile(Path.of(""), "mx_subprocess_", ".cmd");
 277         Files.write(cmdFile, javaPB.command());

 278         javaPB.environment().put("MX_SUBPROCESS_COMMAND_FILE", cmdFile.toAbsolutePath().toString());
 279 
 280         System.out.println("INFO: run command: " + String.join(" ", javaPB.command()));
 281 
 282         OutputAnalyzer outputAnalyzer = new OutputAnalyzer(javaPB.start());
 283         System.out.println("INFO: execution result: " + outputAnalyzer.getOutput());
 284         outputAnalyzer.shouldHaveExitValue(0);
 285     }
 286 }
   1 /*
   2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


 224 
 225         ArrayList<String> javaFlags = new ArrayList<String>();
 226 
 227         // add modules and exports
 228         javaFlags.add("--add-modules");
 229         javaFlags.add("jdk.internal.vm.compiler,jdk.internal.vm.ci");
 230         javaFlags.add("--add-exports");
 231         javaFlags.add("java.base/jdk.internal.module=ALL-UNNAMED");
 232         javaFlags.addAll(getModuleExports("jdk.internal.vm.compiler", "ALL-UNNAMED"));
 233         javaFlags.addAll(getModuleExports("jdk.internal.vm.ci", "ALL-UNNAMED,jdk.internal.vm.compiler"));
 234 
 235 
 236         // add VM flags
 237         javaFlags.add("-XX:+UnlockExperimentalVMOptions");
 238         javaFlags.add("-XX:+EnableJVMCI");
 239         javaFlags.add("-Djava.awt.headless=true");
 240         javaFlags.add("-esa");
 241         javaFlags.add("-ea");
 242         // Make sure exception message is never null
 243         javaFlags.add("-XX:-OmitStackTraceInFastThrow");
 244 

 245 
 246         // generate class path
 247         ArrayList<String> graalJars = new ArrayList<String>(Arrays.asList(GRAAL_EXTRA_JARS));
 248         graalJars.add(MXTOOL_JARFILE);
 249         graalJars.add(GRAAL_UNITTESTS_JARFILE);
 250 
 251         String graalJarsCP = graalJars.stream()
 252                                       .map(s -> String.join(File.separator, libsDir, s))
 253                                       .collect(Collectors.joining(File.pathSeparator));
 254 
 255         javaFlags.add("-cp");
 256         javaFlags.add(String.join(File.pathSeparator, System.getProperty("java.class.path"), graalJarsCP));




 257 
 258         //
 259         javaFlags.add("com.oracle.mxtool.junit.MxJUnitWrapper");
 260         javaFlags.add("-JUnitVerbose");
 261         javaFlags.add("-JUnitEagerStackTrace");
 262         javaFlags.add("-JUnitEnableTiming");
 263 
 264         javaFlags.add("@"+GENERATED_TESTCLASSES_FILENAME);
 265 
 266         ProcessBuilder javaPB = ProcessTools.createJavaProcessBuilder(true,
 267                 javaFlags.toArray(new String[javaFlags.size()]));
 268 
 269         // Some tests rely on MX_SUBPROCESS_COMMAND_FILE env variable which contains
 270         // name of the file with java executable and java args used to launch the current process.
 271         Path cmdFile = Files.createTempFile(Path.of(""), "mx_subprocess_", ".cmd");
 272         Files.writeString(cmdFile, JDKToolFinder.getJDKTool("java") + System.lineSeparator());
 273         Files.write(cmdFile, javaFlags, StandardOpenOption.APPEND);
 274         javaPB.environment().put("MX_SUBPROCESS_COMMAND_FILE", cmdFile.toAbsolutePath().toString());
 275 
 276         System.out.println("INFO: run command: " + String.join(" ", javaPB.command()));
 277 
 278         OutputAnalyzer outputAnalyzer = new OutputAnalyzer(javaPB.start());
 279         System.out.println("INFO: execution result: " + outputAnalyzer.getOutput());
 280         outputAnalyzer.shouldHaveExitValue(0);
 281     }
 282 }
< prev index next >