8017463: [TEST_BUG] 2 tests from tools/pack200/ remain about 1 GB of data in work directory after execution
Reviewed-by: mchung
--- a/jdk/test/tools/pack200/AttributeTests.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/AttributeTests.java Tue Jul 02 05:28:31 2013 -0700
@@ -37,6 +37,7 @@
public static void main(String... args) throws Exception {
test6746111();
testMethodParameters();
+ Utils.cleanup();
}
/*
--- a/jdk/test/tools/pack200/BandIntegrity.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/BandIntegrity.java Tue Jul 02 05:28:31 2013 -0700
@@ -40,7 +40,7 @@
* the java packer and unpacker must be called in the same java instance.
*/
public class BandIntegrity {
- public static void main(String... args) throws IOException {
+ public static void main(String... args) throws IOException {
File testFile = new File("test.jar");
Utils.jar("cvf", testFile.getName(),
"-C", Utils.TEST_CLS_DIR.getAbsolutePath(),
@@ -56,6 +56,7 @@
Utils.createFile(configFile, scratch);
File outFile = new File("out.jar");
Utils.repack(testFile, outFile, true,
- "-v", "--config-file=" + configFile.getName());
+ "-v", "--config-file=" + configFile.getName());
+ Utils.cleanup();
}
}
--- a/jdk/test/tools/pack200/CommandLineTests.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/CommandLineTests.java Tue Jul 02 05:28:31 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -83,6 +83,11 @@
Utils.recursiveCopy(Utils.JavaSDK, EXP_SDK);
creatConfigFile();
}
+ // cleanup the test area
+ static void cleanup() throws IOException {
+ Utils.recursiveDelete(EXP_SDK);
+ Utils.cleanup();
+ }
// Hopefully, this should be kept in sync with what the installer does.
static void creatConfigFile() throws IOException {
@@ -172,6 +177,7 @@
init();
testJRE();
testJDK();
+ cleanup(); // cleanup only if we pass successfully
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
--- a/jdk/test/tools/pack200/InstructionTests.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/InstructionTests.java Tue Jul 02 05:28:31 2013 -0700
@@ -35,6 +35,7 @@
public class InstructionTests {
public static void main(String... args) throws Exception {
testInvokeOpCodes();
+ Utils.cleanup();
}
/*
* the following should produce invokestatic and invokespecial
--- a/jdk/test/tools/pack200/Pack200Props.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/Pack200Props.java Tue Jul 02 05:28:31 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -31,6 +31,7 @@
*/
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -45,11 +46,12 @@
public class Pack200Props {
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
verifyDefaults();
File out = new File("test" + Utils.PACK_FILE_EXT);
out.delete();
verifySegmentLimit(out);
+ Utils.cleanup();
}
static void verifySegmentLimit(File outFile) {
--- a/jdk/test/tools/pack200/Pack200Test.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/Pack200Test.java Tue Jul 02 05:28:31 2013 -0700
@@ -66,7 +66,7 @@
}
}
- private static void doPackUnpack() {
+ private static void doPackUnpack() throws IOException {
for (File in : jarList) {
JarOutputStream javaUnpackerStream = null;
JarOutputStream nativeUnpackerStream = null;
@@ -117,12 +117,13 @@
Utils.close((Closeable) jarFile);
}
}
+ Utils.cleanup(); // cleanup artifacts, if successful run
}
/**
* @param args the command line arguments
*/
- public static void main(String[] args) {
+ 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"));
--- a/jdk/test/tools/pack200/PackageVersionTest.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/PackageVersionTest.java Tue Jul 02 05:28:31 2013 -0700
@@ -1,6 +1,5 @@
-
/*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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 +53,7 @@
public final static int JAVA7_PACKAGE_MAJOR_VERSION = 170;
public final static int JAVA7_PACKAGE_MINOR_VERSION = 1;
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
if (!javaHome.getName().endsWith("jre")) {
throw new RuntimeException("Error: requires an SDK to run");
}
@@ -78,6 +77,7 @@
// test for resource file, ie. no class files
verifyPack("Test6.java", JAVA5_PACKAGE_MAJOR_VERSION,
JAVA5_PACKAGE_MINOR_VERSION);
+ Utils.cleanup();
}
static void verify6991164() {
--- a/jdk/test/tools/pack200/RepackTest.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/RepackTest.java Tue Jul 02 05:28:31 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -36,6 +36,7 @@
public static void main(String... args) throws Exception {
testRepack();
+ Utils.cleanup();
}
/*
--- a/jdk/test/tools/pack200/T7007157.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/T7007157.java Tue Jul 02 05:28:31 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -63,5 +63,6 @@
Utils.close(fos);
Utils.close(jarFile);
}
+ Utils.cleanup();
}
}
--- a/jdk/test/tools/pack200/TestExceptions.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/TestExceptions.java Tue Jul 02 05:28:31 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -219,12 +219,13 @@
}
}
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
init();
pack200Test1();
pack200Test2();
pack200Test3();
unpack200Test1();
+ Utils.cleanup();
}
// containers for test inputs and management
--- a/jdk/test/tools/pack200/TimeStamp.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/TimeStamp.java Tue Jul 02 05:28:31 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -149,6 +149,7 @@
Utils.close(jf1);
Utils.close(jf2);
}
+ Utils.cleanup();
if (errors > 0) {
throw new RuntimeException("FAIL:" + errors + " error(s) encounted");
}
--- a/jdk/test/tools/pack200/UnpackerMemoryTest.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/UnpackerMemoryTest.java Tue Jul 02 05:28:31 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -81,6 +81,7 @@
Utils.close(fos);
}
}
+ Utils.cleanup();
}
}
--- a/jdk/test/tools/pack200/Utils.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/Utils.java Tue Jul 02 05:28:31 2013 -0700
@@ -75,6 +75,7 @@
static final File TEST_CLS_DIR = new File(System.getProperty("test.classes"));
static final String VERIFIER_DIR_NAME = "pack200-verifier";
static final File VerifierJar = new File(VERIFIER_DIR_NAME + JAR_FILE_EXT);
+ static final File XCLASSES = new File("xclasses");
private Utils() {} // all static
@@ -95,8 +96,7 @@
}
List<File> javaFileList = findFiles(srcDir, createFilter(JAVA_FILE_EXT));
File tmpFile = File.createTempFile("javac", ".tmp");
- File classesDir = new File("xclasses");
- classesDir.mkdirs();
+ XCLASSES.mkdirs();
FileOutputStream fos = null;
PrintStream ps = null;
try {
@@ -111,14 +111,14 @@
}
compiler("-d",
- "xclasses",
+ XCLASSES.getName(),
"@" + tmpFile.getAbsolutePath());
jar("cvfe",
VerifierJar.getName(),
"sun.tools.pack.verify.Main",
"-C",
- "xclasses",
+ XCLASSES.getName(),
".");
}
@@ -175,6 +175,33 @@
};
}
+ /*
+ * clean up all the usual suspects
+ */
+ static void cleanup() throws IOException {
+ recursiveDelete(XCLASSES);
+ List<File> toDelete = new ArrayList<>();
+ toDelete.addAll(Utils.findFiles(new File("."),
+ Utils.createFilter(".out")));
+ toDelete.addAll(Utils.findFiles(new File("."),
+ Utils.createFilter(".bak")));
+ toDelete.addAll(Utils.findFiles(new File("."),
+ Utils.createFilter(".jar")));
+ toDelete.addAll(Utils.findFiles(new File("."),
+ Utils.createFilter(".pack")));
+ toDelete.addAll(Utils.findFiles(new File("."),
+ Utils.createFilter(".bnd")));
+ toDelete.addAll(Utils.findFiles(new File("."),
+ Utils.createFilter(".txt")));
+ toDelete.addAll(Utils.findFiles(new File("."),
+ Utils.createFilter(".idx")));
+ toDelete.addAll(Utils.findFiles(new File("."),
+ Utils.createFilter(".gidx")));
+ for (File f : toDelete) {
+ f.delete();
+ }
+ }
+
static final FileFilter DIR_FILTER = new FileFilter() {
public boolean accept(File pathname) {
if (pathname.isDirectory()) {
@@ -199,6 +226,9 @@
Files.createDirectories(parent);
}
Files.copy(src.toPath(), dst.toPath(), COPY_ATTRIBUTES, REPLACE_EXISTING);
+ if (dst.isDirectory() && !dst.canWrite()) {
+ dst.setWritable(true);
+ }
}
static String baseName(File file, String extension) {
--- a/jdk/test/tools/pack200/typeannos/TestTypeAnnotations.java Tue Jul 02 11:30:31 2013 +0200
+++ b/jdk/test/tools/pack200/typeannos/TestTypeAnnotations.java Tue Jul 02 05:28:31 2013 -0700
@@ -41,5 +41,6 @@
"-C", Utils.TEST_CLS_DIR.getAbsolutePath(),
".");
Utils.testWithRepack(testFile, "--unknown-attribute=error");
+ Utils.cleanup();
}
}