8067889: 4 pack200 tests fail on mac since jdk became modular
authorksrini
Mon, 29 Dec 2014 07:38:54 -0800
changeset 28255 ddb0157601ed
parent 28252 4673729e145d
child 28256 a9a57ee3c134
8067889: 4 pack200 tests fail on mac since jdk became modular Reviewed-by: alanb, chegar
jdk/test/tools/pack200/Pack200Test.java
jdk/test/tools/pack200/PackTestZip64.java
jdk/test/tools/pack200/RepackTest.java
jdk/test/tools/pack200/TimeStamp.java
jdk/test/tools/pack200/Utils.java
--- a/jdk/test/tools/pack200/Pack200Test.java	Tue Dec 23 12:40:06 2014 -0800
+++ b/jdk/test/tools/pack200/Pack200Test.java	Mon Dec 29 07:38:54 2014 -0800
@@ -127,7 +127,7 @@
         // select the jars carefully, adding more jars will increase the
         // testing time, especially for jprt.
         jarList.add(Utils.createRtJar());
-        jarList.add(Utils.locateJar("golden.jar"));
+        jarList.add(Utils.getGoldenJar());
         System.out.println(jarList);
         doPackUnpack();
     }
--- a/jdk/test/tools/pack200/PackTestZip64.java	Tue Dec 23 12:40:06 2014 -0800
+++ b/jdk/test/tools/pack200/PackTestZip64.java	Mon Dec 29 07:38:54 2014 -0800
@@ -52,7 +52,7 @@
         // make a copy of the test specimen to local directory
         File testFile = new File("tools_java.jar");
         // Add a large number of small files to the golden jar
-        generateLargeJar(testFile, Utils.locateJar("golden.jar"));
+        generateLargeJar(testFile, Utils.getGoldenJar());
 
         List<String> cmdsList = new ArrayList<>();
 
--- a/jdk/test/tools/pack200/RepackTest.java	Tue Dec 23 12:40:06 2014 -0800
+++ b/jdk/test/tools/pack200/RepackTest.java	Mon Dec 29 07:38:54 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -50,7 +50,7 @@
 
         // make a copy of the test specimen to local directory
         File testFile = new File("src_tools.jar");
-        Utils.copyFile(Utils.locateJar("golden.jar"), testFile);
+        Utils.copyFile(Utils.getGoldenJar(), testFile);
         List<String> cmdsList = new ArrayList<>();
 
         // case 1:
--- a/jdk/test/tools/pack200/TimeStamp.java	Tue Dec 23 12:40:06 2014 -0800
+++ b/jdk/test/tools/pack200/TimeStamp.java	Mon Dec 29 07:38:54 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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
@@ -54,7 +54,7 @@
     public static void main(String... args) throws IOException {
 
         // make a local copy of our test file
-        File srcFile = Utils.locateJar("golden.jar");
+        File srcFile = Utils.getGoldenJar();
         File goldenFile = new File("golden.jar");
         Utils.copyFile(srcFile, goldenFile);
 
--- a/jdk/test/tools/pack200/Utils.java	Tue Dec 23 12:40:06 2014 -0800
+++ b/jdk/test/tools/pack200/Utils.java	Mon Dec 29 07:38:54 2014 -0800
@@ -63,7 +63,7 @@
             System.getProperty("os.name").startsWith("Windows");
     static final boolean Is64Bit =
             System.getProperty("sun.arch.data.model", "32").equals("64");
-    static final File   JavaSDK =  new File(JavaHome).getParentFile();
+    static final File   JavaSDK =  new File(JavaHome);
 
     static final String PACK_FILE_EXT   = ".pack";
     static final String JAVA_FILE_EXT   = ".java";
@@ -82,11 +82,7 @@
         if (VerifierJar.exists()) {
             return;
         }
-        File srcDir = new File(TEST_SRC_DIR, VERIFIER_DIR_NAME);
-        if (!srcDir.exists()) {
-            // if not available try one level above
-            srcDir = new File(TEST_SRC_DIR.getParentFile(), VERIFIER_DIR_NAME);
-        }
+        File srcDir = new File(getVerifierDir(), "src");
         List<File> javaFileList = findFiles(srcDir, createFilter(JAVA_FILE_EXT));
         File tmpFile = File.createTempFile("javac", ".tmp");
         XCLASSES.mkdirs();
@@ -115,6 +111,18 @@
             ".");
     }
 
+    private static File getVerifierDir() {
+        File srcDir = new File(TEST_SRC_DIR, VERIFIER_DIR_NAME);
+        if (!srcDir.exists()) {
+            // if not available try one level above
+            srcDir = new File(TEST_SRC_DIR.getParentFile(), VERIFIER_DIR_NAME);
+        }
+        return srcDir;
+    }
+
+    static File getGoldenJar() {
+        return new File(new File(getVerifierDir(), "data"), "golden.jar");
+    }
     static void dirlist(File dir) {
         File[] files = dir.listFiles();
         System.out.println("--listing " + dir.getAbsolutePath() + "---");
@@ -564,7 +572,8 @@
         File rtJar = new File("rt.jar");
         cmdList.clear();
         cmdList.add(getJarCmd());
-        cmdList.add("cvf");
+        // cmdList.add("cvf"); too noisy
+        cmdList.add("cf");
         cmdList.add(rtJar.getName());
         cmdList.add("-C");
         cmdList.add("out");
@@ -574,24 +583,4 @@
         recursiveDelete(new File("out"));
         return rtJar;
     }
-    private static List<File> locaterCache = null;
-    // search the source dir and jdk dir for requested file and returns
-    // the first location it finds.
-    static File locateJar(String name) {
-        try {
-            if (locaterCache == null) {
-                locaterCache = new ArrayList<File>();
-                locaterCache.addAll(findFiles(TEST_SRC_DIR, createFilter(JAR_FILE_EXT)));
-                locaterCache.addAll(findFiles(JavaSDK, createFilter(JAR_FILE_EXT)));
-            }
-            for (File f : locaterCache) {
-                if (f.getName().equals(name)) {
-                    return f;
-                }
-            }
-            throw new IOException("file not found: " + name);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
 }