changeset 50488:93a7cbd3f838

8195002: Fix test/hotspot/jtreg/gtest/GTestWrapper.java on Alpine/Musl Reviewed-by: stuefe, clanger, mikael
author asiebenborn
date Thu, 26 Apr 2018 12:54:53 +0200
parents 3b43e97b3697
children 99e698e94cc7
files test/hotspot/jtreg/gtest/GTestWrapper.java
diffstat 1 files changed, 27 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/test/hotspot/jtreg/gtest/GTestWrapper.java	Thu May 03 15:04:01 2018 +0800
+++ b/test/hotspot/jtreg/gtest/GTestWrapper.java	Thu Apr 26 12:54:53 2018 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Stream;
 import java.util.stream.Collectors;
 
@@ -59,12 +60,31 @@
         if (!path.toFile().exists()) {
             throw new Error("TESTBUG: the library has not been found in " + nativePath);
         }
-        path = path.resolve("gtestLauncher" + (Platform.isWindows() ? ".exe" : ""));
-        ProcessTools.executeCommand(new String[] {
-                path.toString(),
-                "-jdk",
-                System.getProperty("test.jdk")
-        }).shouldHaveExitValue(0);
+
+        Path execPath = path.resolve("gtestLauncher" + (Platform.isWindows() ? ".exe" : ""));
+        ProcessBuilder pb = new ProcessBuilder();
+        Map<String, String> env = pb.environment();
+
+        // The GTestWrapper was started using the normal java launcher, which
+        // may have set LD_LIBRARY_PATH or LIBPATH to point to the jdk libjvm. In
+        // that case, prepend the path with the location of the gtest library."
+
+        String ldLibraryPath = System.getenv("LD_LIBRARY_PATH");
+        if (ldLibraryPath != null) {
+            env.put("LD_LIBRARY_PATH", path + ":" + ldLibraryPath);
+        }
+
+        String libPath = System.getenv("LIBPATH");
+        if (libPath != null) {
+            env.put("LIBPATH", path + ":" + libPath);
+        }
+
+        pb.command(new String[] {
+            execPath.toString(),
+            "-jdk",
+            System.getProperty("test.jdk")
+        });
+        ProcessTools.executeCommand(pb).shouldHaveExitValue(0);
     }
 
     private static String getJVMVariantSubDir() {