changeset 10797:d8b62e626cc8

8058853: Update pack200 tests to work with modular image Contributed-by: kumar.x.srinivasan@oracle.com
author alanb
date Wed, 08 Oct 2014 22:56:55 +0100
parents 9ec05097e132
children f25996bc3361
files test/ProblemList.txt test/tools/pack200/CommandLineTests.java test/tools/pack200/Pack200Props.java test/tools/pack200/Pack200Test.java test/tools/pack200/T7007157.java test/tools/pack200/Utils.java
diffstat 6 files changed, 63 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/test/ProblemList.txt	Mon Oct 06 11:53:10 2014 +0200
+++ b/test/ProblemList.txt	Wed Oct 08 22:56:55 2014 +0100
@@ -256,7 +256,8 @@
 # jdk_tools
 
 # Tests take too long, on sparcs see 7143279
-tools/pack200/CommandLineTests.java                             solaris-all,macosx-all
+# also see 8059906
+tools/pack200/CommandLineTests.java
 tools/pack200/Pack200Test.java                                  solaris-all,macosx-all
 
 # 8007410
--- a/test/tools/pack200/CommandLineTests.java	Mon Oct 06 11:53:10 2014 +0200
+++ b/test/tools/pack200/CommandLineTests.java	Wed Oct 08 22:56:55 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -24,6 +24,7 @@
 /*
  * @test CommandLineTests.sh
  * @bug  6521334 6965836 6965836
+ * @ignore 8059906
  * @compile -XDignore.symbol.file CommandLineTests.java Pack200Test.java
  * @run main/timeout=1200 CommandLineTests
  * @summary An ad hoc test to verify the behavior of pack200/unpack200 CLIs,
--- a/test/tools/pack200/Pack200Props.java	Mon Oct 06 11:53:10 2014 +0200
+++ b/test/tools/pack200/Pack200Props.java	Wed Oct 08 22:56:55 2014 +0100
@@ -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,9 +54,9 @@
         Utils.cleanup();
     }
 
-    static void verifySegmentLimit(File outFile) {
+    static void verifySegmentLimit(File outFile) throws IOException {
         File sdkHome = Utils.JavaSDK;
-        File testJar = new File(new File(sdkHome, "lib"), "tools.jar");
+        File testJar = Utils.createRtJar();
 
         System.out.println("using pack200: " + Utils.getPack200Cmd());
 
--- a/test/tools/pack200/Pack200Test.java	Mon Oct 06 11:53:10 2014 +0200
+++ b/test/tools/pack200/Pack200Test.java	Wed Oct 08 22:56:55 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -126,8 +126,7 @@
     public static void main(String[] args) throws IOException {
         // select the jars carefully, adding more jars will increase the
         // testing time, especially for jprt.
-        jarList.add(Utils.locateJar("tools.jar"));
-        jarList.add(Utils.locateJar("rt.jar"));
+        jarList.add(Utils.createRtJar());
         jarList.add(Utils.locateJar("golden.jar"));
         System.out.println(jarList);
         doPackUnpack();
--- a/test/tools/pack200/T7007157.java	Mon Oct 06 11:53:10 2014 +0200
+++ b/test/tools/pack200/T7007157.java	Wed Oct 08 22:56:55 2014 +0100
@@ -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
@@ -38,7 +38,8 @@
 
     public static void main(String... args) throws IOException {
         File sdkHome = Utils.JavaSDK;
-        File testJar = new File(new File(sdkHome, "lib"), "tools.jar");
+        File testJar = new File("test.jar");
+        Utils.jar("cvf", testJar.getName(), Utils.TEST_CLS_DIR.getAbsolutePath());
         JarFile jarFile = new JarFile(testJar);
         File packFile = new File("foo.pack");
         Pack200.Packer packer = Pack200.newPacker();
--- a/test/tools/pack200/Utils.java	Mon Oct 06 11:53:10 2014 +0200
+++ b/test/tools/pack200/Utils.java	Wed Oct 08 22:56:55 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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,8 +54,7 @@
  */
 
 /*
- * This class contains all the commonly used utilities used by various tests
- * in this directory.
+ * This class contains the commonly used utilities.
  */
 class Utils {
     static final String JavaHome = System.getProperty("test.java",
@@ -131,8 +130,7 @@
         List<String> cmds = new ArrayList<String>();
         cmds.add(getJavaCmd());
         cmds.add("-cp");
-        cmds.add(Utils.locateJar("tools.jar") +
-                System.getProperty("path.separator") + VerifierJar.getName());
+        cmds.add(VerifierJar.getName());
         cmds.add("sun.tools.pack.verify.Main");
         cmds.add(reference.getAbsolutePath());
         cmds.add(specimen.getAbsolutePath());
@@ -146,8 +144,7 @@
         List<String> cmds = new ArrayList<String>();
         cmds.add(getJavaCmd());
         cmds.add("-cp");
-        cmds.add(Utils.locateJar("tools.jar")
-                + System.getProperty("path.separator") + VerifierJar.getName());
+        cmds.add(VerifierJar.getName());
         cmds.add("sun.tools.pack.verify.Main");
         cmds.add(reference.getName());
         cmds.add(specimen.getName());
@@ -337,17 +334,21 @@
     }
 
     static void compiler(String... javacCmds) {
-        if (com.sun.tools.javac.Main.compile(javacCmds) != 0) {
-            throw new RuntimeException("compilation failed");
+        List<String> cmdList = new ArrayList<>();
+        cmdList.add(getJavacCmd());
+        for (String x : javacCmds) {
+            cmdList.add(x);
         }
+        runExec(cmdList);
     }
 
     static void jar(String... jargs) {
-        sun.tools.jar.Main jarTool =
-                new sun.tools.jar.Main(System.out, System.err, "jartool");
-        if (!jarTool.run(jargs)) {
-            throw new RuntimeException("jar command failed");
+        List<String> cmdList = new ArrayList<>();
+        cmdList.add(getJarCmd());
+        for (String x : jargs) {
+            cmdList.add(x);
         }
+        runExec(cmdList);
     }
 
     static void testWithRepack(File inFile, String... repackOpts) throws IOException {
@@ -522,6 +523,18 @@
         return getAjavaCmd("java");
     }
 
+    static String getJavacCmd() {
+        return getAjavaCmd("javac");
+    }
+
+    static String getJarCmd() {
+        return getAjavaCmd("jar");
+    }
+
+    static String getJimageCmd() {
+        return getAjavaCmd("jimage");
+    }
+
     static String getAjavaCmd(String cmdStr) {
         File binDir = new File(JavaHome, "bin");
         File unpack200File = IsWindows
@@ -536,6 +549,31 @@
         return cmd;
     }
 
+    static File createRtJar() throws IOException {
+        File LibDir = new File(JavaHome, "lib");
+        File ModuleDir = new File(LibDir, "modules");
+        File BootModules = new File(ModuleDir, "bootmodules.jimage");
+        List<String> cmdList = new ArrayList<>();
+        cmdList.add(getJimageCmd());
+        cmdList.add("expand");
+        cmdList.add(BootModules.getAbsolutePath());
+        cmdList.add("--dir");
+        cmdList.add("out");
+        runExec(cmdList);
+
+        File rtJar = new File("rt.jar");
+        cmdList.clear();
+        cmdList.add(getJarCmd());
+        cmdList.add("cvf");
+        cmdList.add(rtJar.getName());
+        cmdList.add("-C");
+        cmdList.add("out");
+        cmdList.add(".");
+        runExec(cmdList);
+
+        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.