提交 466cc3ec 编写于 作者: K ksrini

8017463: [TEST_BUG] 2 tests from tools/pack200/ remain about 1 GB of data in...

8017463: [TEST_BUG] 2 tests from tools/pack200/ remain about 1 GB of data in work directory after execution
Reviewed-by: mchung
上级 989b5fff
...@@ -37,6 +37,7 @@ public class AttributeTests { ...@@ -37,6 +37,7 @@ public class AttributeTests {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
test6746111(); test6746111();
testMethodParameters(); testMethodParameters();
Utils.cleanup();
} }
/* /*
......
...@@ -40,7 +40,7 @@ import java.util.List; ...@@ -40,7 +40,7 @@ import java.util.List;
* the java packer and unpacker must be called in the same java instance. * the java packer and unpacker must be called in the same java instance.
*/ */
public class BandIntegrity { 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"); File testFile = new File("test.jar");
Utils.jar("cvf", testFile.getName(), Utils.jar("cvf", testFile.getName(),
"-C", Utils.TEST_CLS_DIR.getAbsolutePath(), "-C", Utils.TEST_CLS_DIR.getAbsolutePath(),
...@@ -56,6 +56,7 @@ public class BandIntegrity { ...@@ -56,6 +56,7 @@ public class BandIntegrity {
Utils.createFile(configFile, scratch); Utils.createFile(configFile, scratch);
File outFile = new File("out.jar"); File outFile = new File("out.jar");
Utils.repack(testFile, outFile, true, Utils.repack(testFile, outFile, true,
"-v", "--config-file=" + configFile.getName()); "-v", "--config-file=" + configFile.getName());
Utils.cleanup();
} }
} }
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -83,6 +83,11 @@ public class CommandLineTests { ...@@ -83,6 +83,11 @@ public class CommandLineTests {
Utils.recursiveCopy(Utils.JavaSDK, EXP_SDK); Utils.recursiveCopy(Utils.JavaSDK, EXP_SDK);
creatConfigFile(); 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. // Hopefully, this should be kept in sync with what the installer does.
static void creatConfigFile() throws IOException { static void creatConfigFile() throws IOException {
...@@ -172,6 +177,7 @@ public class CommandLineTests { ...@@ -172,6 +177,7 @@ public class CommandLineTests {
init(); init();
testJRE(); testJRE();
testJDK(); testJDK();
cleanup(); // cleanup only if we pass successfully
} catch (IOException ioe) { } catch (IOException ioe) {
throw new RuntimeException(ioe); throw new RuntimeException(ioe);
} }
......
...@@ -35,6 +35,7 @@ import java.util.List; ...@@ -35,6 +35,7 @@ import java.util.List;
public class InstructionTests { public class InstructionTests {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
testInvokeOpCodes(); testInvokeOpCodes();
Utils.cleanup();
} }
/* /*
* the following should produce invokestatic and invokespecial * the following should produce invokestatic and invokespecial
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
*/ */
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -45,11 +46,12 @@ import java.util.jar.Pack200.Packer; ...@@ -45,11 +46,12 @@ import java.util.jar.Pack200.Packer;
public class Pack200Props { public class Pack200Props {
public static void main(String... args) { public static void main(String... args) throws IOException {
verifyDefaults(); verifyDefaults();
File out = new File("test" + Utils.PACK_FILE_EXT); File out = new File("test" + Utils.PACK_FILE_EXT);
out.delete(); out.delete();
verifySegmentLimit(out); verifySegmentLimit(out);
Utils.cleanup();
} }
static void verifySegmentLimit(File outFile) { static void verifySegmentLimit(File outFile) {
......
...@@ -66,7 +66,7 @@ public class Pack200Test { ...@@ -66,7 +66,7 @@ public class Pack200Test {
} }
} }
private static void doPackUnpack() { private static void doPackUnpack() throws IOException {
for (File in : jarList) { for (File in : jarList) {
JarOutputStream javaUnpackerStream = null; JarOutputStream javaUnpackerStream = null;
JarOutputStream nativeUnpackerStream = null; JarOutputStream nativeUnpackerStream = null;
...@@ -117,12 +117,13 @@ public class Pack200Test { ...@@ -117,12 +117,13 @@ public class Pack200Test {
Utils.close((Closeable) jarFile); Utils.close((Closeable) jarFile);
} }
} }
Utils.cleanup(); // cleanup artifacts, if successful run
} }
/** /**
* @param args the command line arguments * @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 // select the jars carefully, adding more jars will increase the
// testing time, especially for jprt. // testing time, especially for jprt.
jarList.add(Utils.locateJar("tools.jar")); jarList.add(Utils.locateJar("tools.jar"));
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -54,7 +53,7 @@ public class PackageVersionTest { ...@@ -54,7 +53,7 @@ public class PackageVersionTest {
public final static int JAVA7_PACKAGE_MAJOR_VERSION = 170; public final static int JAVA7_PACKAGE_MAJOR_VERSION = 170;
public final static int JAVA7_PACKAGE_MINOR_VERSION = 1; 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")) { if (!javaHome.getName().endsWith("jre")) {
throw new RuntimeException("Error: requires an SDK to run"); throw new RuntimeException("Error: requires an SDK to run");
} }
...@@ -78,6 +77,7 @@ public class PackageVersionTest { ...@@ -78,6 +77,7 @@ public class PackageVersionTest {
// test for resource file, ie. no class files // test for resource file, ie. no class files
verifyPack("Test6.java", JAVA5_PACKAGE_MAJOR_VERSION, verifyPack("Test6.java", JAVA5_PACKAGE_MAJOR_VERSION,
JAVA5_PACKAGE_MINOR_VERSION); JAVA5_PACKAGE_MINOR_VERSION);
Utils.cleanup();
} }
static void verify6991164() { static void verify6991164() {
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -36,6 +36,7 @@ public class RepackTest { ...@@ -36,6 +36,7 @@ public class RepackTest {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
testRepack(); testRepack();
Utils.cleanup();
} }
/* /*
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -63,5 +63,6 @@ public class T7007157 { ...@@ -63,5 +63,6 @@ public class T7007157 {
Utils.close(fos); Utils.close(fos);
Utils.close(jarFile); Utils.close(jarFile);
} }
Utils.cleanup();
} }
} }
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -219,12 +219,13 @@ public class TestExceptions { ...@@ -219,12 +219,13 @@ public class TestExceptions {
} }
} }
public static void main(String... args) { public static void main(String... args) throws IOException {
init(); init();
pack200Test1(); pack200Test1();
pack200Test2(); pack200Test2();
pack200Test3(); pack200Test3();
unpack200Test1(); unpack200Test1();
Utils.cleanup();
} }
// containers for test inputs and management // containers for test inputs and management
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -149,6 +149,7 @@ public class TimeStamp { ...@@ -149,6 +149,7 @@ public class TimeStamp {
Utils.close(jf1); Utils.close(jf1);
Utils.close(jf2); Utils.close(jf2);
} }
Utils.cleanup();
if (errors > 0) { if (errors > 0) {
throw new RuntimeException("FAIL:" + errors + " error(s) encounted"); throw new RuntimeException("FAIL:" + errors + " error(s) encounted");
} }
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -81,6 +81,7 @@ public class UnpackerMemoryTest { ...@@ -81,6 +81,7 @@ public class UnpackerMemoryTest {
Utils.close(fos); Utils.close(fos);
} }
} }
Utils.cleanup();
} }
} }
...@@ -75,6 +75,7 @@ class Utils { ...@@ -75,6 +75,7 @@ class Utils {
static final File TEST_CLS_DIR = new File(System.getProperty("test.classes")); static final File TEST_CLS_DIR = new File(System.getProperty("test.classes"));
static final String VERIFIER_DIR_NAME = "pack200-verifier"; static final String VERIFIER_DIR_NAME = "pack200-verifier";
static final File VerifierJar = new File(VERIFIER_DIR_NAME + JAR_FILE_EXT); static final File VerifierJar = new File(VERIFIER_DIR_NAME + JAR_FILE_EXT);
static final File XCLASSES = new File("xclasses");
private Utils() {} // all static private Utils() {} // all static
...@@ -95,8 +96,7 @@ class Utils { ...@@ -95,8 +96,7 @@ class Utils {
} }
List<File> javaFileList = findFiles(srcDir, createFilter(JAVA_FILE_EXT)); List<File> javaFileList = findFiles(srcDir, createFilter(JAVA_FILE_EXT));
File tmpFile = File.createTempFile("javac", ".tmp"); File tmpFile = File.createTempFile("javac", ".tmp");
File classesDir = new File("xclasses"); XCLASSES.mkdirs();
classesDir.mkdirs();
FileOutputStream fos = null; FileOutputStream fos = null;
PrintStream ps = null; PrintStream ps = null;
try { try {
...@@ -111,14 +111,14 @@ class Utils { ...@@ -111,14 +111,14 @@ class Utils {
} }
compiler("-d", compiler("-d",
"xclasses", XCLASSES.getName(),
"@" + tmpFile.getAbsolutePath()); "@" + tmpFile.getAbsolutePath());
jar("cvfe", jar("cvfe",
VerifierJar.getName(), VerifierJar.getName(),
"sun.tools.pack.verify.Main", "sun.tools.pack.verify.Main",
"-C", "-C",
"xclasses", XCLASSES.getName(),
"."); ".");
} }
...@@ -175,6 +175,33 @@ class Utils { ...@@ -175,6 +175,33 @@ class Utils {
}; };
} }
/*
* 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() { static final FileFilter DIR_FILTER = new FileFilter() {
public boolean accept(File pathname) { public boolean accept(File pathname) {
if (pathname.isDirectory()) { if (pathname.isDirectory()) {
...@@ -199,6 +226,9 @@ class Utils { ...@@ -199,6 +226,9 @@ class Utils {
Files.createDirectories(parent); Files.createDirectories(parent);
} }
Files.copy(src.toPath(), dst.toPath(), COPY_ATTRIBUTES, REPLACE_EXISTING); 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) { static String baseName(File file, String extension) {
......
...@@ -41,5 +41,6 @@ public class TestTypeAnnotations { ...@@ -41,5 +41,6 @@ public class TestTypeAnnotations {
"-C", Utils.TEST_CLS_DIR.getAbsolutePath(), "-C", Utils.TEST_CLS_DIR.getAbsolutePath(),
"."); ".");
Utils.testWithRepack(testFile, "--unknown-attribute=error"); Utils.testWithRepack(testFile, "--unknown-attribute=error");
Utils.cleanup();
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册