< prev index next >

test/native/GTestWrapper.java

Print this page
rev 11190 : 8156681: Add jtreg wrapper for hotspot gtest tests
rev 11191 : [mq]: 8156681-2

*** 42,71 **** import jdk.test.lib.OutputAnalyzer; import jdk.test.lib.Utils; public class GTestWrapper { public static void main(String[] args) throws Throwable { ! String nativePath = System.getProperty("test.nativepath"); ! Path gtestLauncher = Paths.get(nativePath, "hotspot", "gtest"); ! if (Platform.isServer()) { ! gtestLauncher = gtestLauncher.resolve("server"); ! } else if (Platform.isClient()) { ! gtestLauncher = gtestLauncher.resolve("client"); ! } else if (Platform.isMinimal()) { ! gtestLauncher = gtestLauncher.resolve("minimal"); } ! gtestLauncher = gtestLauncher.resolve( ! "gtestLauncher" + (Platform.isWindows() ? ".exe" : "")); List<String> cmds = Stream.concat( Stream.of( ! gtestLauncher.toString(), "-jdk", System.getProperty("test.jdk")), ! Arrays.stream(Utils.getTestJavaOpts())) .collect(Collectors.toList()); ProcessBuilder builder = new ProcessBuilder(cmds); - builder.inheritIO(); - OutputAnalyzer oa = ProcessTools.executeProcess(builder); oa.shouldHaveExitValue(0); } } --- 42,85 ---- import jdk.test.lib.OutputAnalyzer; import jdk.test.lib.Utils; public class GTestWrapper { public static void main(String[] args) throws Throwable { ! // nativePath points either to <test_image>/hotspot/jtreg/native or to <test_image>/hotspot/gtest ! Path nativePath = Paths.get(System.getProperty("test.nativepath")); ! // let's assume it's <test_image>/hotspot/gtest ! Path path = getJVMVariantSubDir(nativePath); ! if (!path.toFile().exists()) { ! // maybe it is <test_image>/hotspot/jtreg/native ! path = getJVMVariantSubDir(nativePath.getParent() ! .getParent() ! .resolve("gtest")); } ! if (!path.toFile().exists()) { ! throw new Error("TESTBUG: the library has not been found in " + nativePath); ! } ! path = path.resolve("gtestLauncher" + (Platform.isWindows() ? ".exe" : "")); List<String> cmds = Stream.concat( Stream.of( ! path.toString(), "-jdk", System.getProperty("test.jdk")), ! Arrays.stream(Utils.getTestJavaOpts()) ! .filter(s -> s.startsWith("-X") || s.startsWith("-D"))) .collect(Collectors.toList()); ProcessBuilder builder = new ProcessBuilder(cmds); OutputAnalyzer oa = ProcessTools.executeProcess(builder); oa.shouldHaveExitValue(0); } + + private static Path getJVMVariantSubDir(Path root) { + if (Platform.isServer()) { + return root.resolve("server"); + } else if (Platform.isClient()) { + return root.resolve("client"); + } else if (Platform.isMinimal()) { + return root.resolve("minimal"); + } else { + throw new Error("TESTBUG: unsuppported vm variant"); + } + } }
< prev index next >