test/tools/launcher/ExecutionEnvironment.java

Print this page


   1 /*
   2  * Copyright (c) 2009, 2014, 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  */


 167                     "> the process execing ?");
 168         }
 169     }
 170 
 171     /*
 172      * This test ensures that LD_LIBRARY_PATH* values are interpreted by the VM
 173      * and the expected java.library.path behaviour.
 174      * For Generic platforms (All *nixes):
 175      *    * All LD_LIBRARY_PATH variable should be on java.library.path
 176      * For Solaris 32-bit
 177      *    * The LD_LIBRARY_PATH_32 should override LD_LIBRARY_PATH if specified
 178      * For Solaris 64-bit
 179      *    * The LD_LIBRARY_PATH_64 should override LD_LIBRARY_PATH if specified
 180      */
 181     @Test
 182     void testJavaLibraryPath() {
 183         TestResult tr = null;
 184 
 185         Map<String, String> env = new HashMap<>();
 186 
 187         if (TestHelper.isLinux || TestHelper.isMacOSX || TestHelper.isAIX) {
 188             for (String x : LD_PATH_STRINGS) {
 189                 String pairs[] = x.split("=");
 190                 env.put(pairs[0], pairs[1]);
 191             }
 192 
 193             tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
 194             verifyJavaLibraryPathGeneric(tr);
 195         } else { // Solaris
 196             // no override
 197             env.clear();
 198             env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
 199             tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
 200             verifyJavaLibraryPathGeneric(tr);
 201 
 202             env.clear();
 203             for (String x : LD_PATH_STRINGS) {
 204                 String pairs[] = x.split("=");
 205                 env.put(pairs[0], pairs[1]);
 206             }
 207 
 208             // verify the override occurs for 64-bit system
 209             tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
 210             verifyJavaLibraryPathOverride(tr, false);








 211         }
 212     }
 213 
 214     private void verifyJavaLibraryPathGeneric(TestResult tr) {
 215         if (!tr.matches("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*")) {
 216             flagError(tr, "testJavaLibraryPath: java.library.path does not contain " +
 217                     LD_LIBRARY_PATH_VALUE);
 218         }
 219     }
 220 
 221     private void verifyJavaLibraryPathOverride(TestResult tr,
 222             boolean is32Bit) {
 223         // make sure the 32/64 bit value exists
 224         if (!tr.matches("java.library.path=.*" +
 225                 (is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE) + ".*")) {
 226             flagError(tr, "verifyJavaLibraryPathOverride: " +
 227                 " java.library.path does not contain " +
 228                     (is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE));
 229 
 230         }


   1 /*
   2  * Copyright (c) 2009, 2015, 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  */


 167                     "> the process execing ?");
 168         }
 169     }
 170 
 171     /*
 172      * This test ensures that LD_LIBRARY_PATH* values are interpreted by the VM
 173      * and the expected java.library.path behaviour.
 174      * For Generic platforms (All *nixes):
 175      *    * All LD_LIBRARY_PATH variable should be on java.library.path
 176      * For Solaris 32-bit
 177      *    * The LD_LIBRARY_PATH_32 should override LD_LIBRARY_PATH if specified
 178      * For Solaris 64-bit
 179      *    * The LD_LIBRARY_PATH_64 should override LD_LIBRARY_PATH if specified
 180      */
 181     @Test
 182     void testJavaLibraryPath() {
 183         TestResult tr = null;
 184 
 185         Map<String, String> env = new HashMap<>();
 186 
 187         if (TestHelper.isSolaris) {








 188             // no override
 189             env.clear();
 190             env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
 191             tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
 192             verifyJavaLibraryPathGeneric(tr);
 193 
 194             env.clear();
 195             for (String x : LD_PATH_STRINGS) {
 196                 String pairs[] = x.split("=");
 197                 env.put(pairs[0], pairs[1]);
 198             }
 199 
 200             // verify the override occurs for 64-bit system
 201             tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
 202             verifyJavaLibraryPathOverride(tr, false);
 203         } else {
 204             for (String x : LD_PATH_STRINGS) {
 205                 String pairs[] = x.split("=");
 206                 env.put(pairs[0], pairs[1]);
 207             }
 208 
 209             tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
 210             verifyJavaLibraryPathGeneric(tr);
 211         }
 212     }
 213 
 214     private void verifyJavaLibraryPathGeneric(TestResult tr) {
 215         if (!tr.matches("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*")) {
 216             flagError(tr, "testJavaLibraryPath: java.library.path does not contain " +
 217                     LD_LIBRARY_PATH_VALUE);
 218         }
 219     }
 220 
 221     private void verifyJavaLibraryPathOverride(TestResult tr,
 222             boolean is32Bit) {
 223         // make sure the 32/64 bit value exists
 224         if (!tr.matches("java.library.path=.*" +
 225                 (is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE) + ".*")) {
 226             flagError(tr, "verifyJavaLibraryPathOverride: " +
 227                 " java.library.path does not contain " +
 228                     (is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE));
 229 
 230         }