提交 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 {
public static void main(String... args) throws Exception {
test6746111();
testMethodParameters();
Utils.cleanup();
}
/*
......
......@@ -40,7 +40,7 @@ import java.util.List;
* 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 @@ public class BandIntegrity {
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();
}
}
/*
* 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 @@ public class CommandLineTests {
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 @@ public class CommandLineTests {
init();
testJRE();
testJDK();
cleanup(); // cleanup only if we pass successfully
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
......
......@@ -35,6 +35,7 @@ import java.util.List;
public class InstructionTests {
public static void main(String... args) throws Exception {
testInvokeOpCodes();
Utils.cleanup();
}
/*
* 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.
*
* 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 @@ import java.util.jar.Pack200.Packer;
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) {
......
......@@ -66,7 +66,7 @@ public class Pack200Test {
}
}
private static void doPackUnpack() {
private static void doPackUnpack() throws IOException {
for (File in : jarList) {
JarOutputStream javaUnpackerStream = null;
JarOutputStream nativeUnpackerStream = null;
......@@ -117,12 +117,13 @@ public class Pack200Test {
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"));
......
/*
* 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 class PackageVersionTest {
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 @@ public class PackageVersionTest {
// test for resource file, ie. no class files
verifyPack("Test6.java", JAVA5_PACKAGE_MAJOR_VERSION,
JAVA5_PACKAGE_MINOR_VERSION);
Utils.cleanup();
}
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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -36,6 +36,7 @@ public class RepackTest {
public static void main(String... args) throws Exception {
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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -63,5 +63,6 @@ public class T7007157 {
Utils.close(fos);
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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -219,12 +219,13 @@ public class TestExceptions {
}
}
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
......
/*
* 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 @@ public class TimeStamp {
Utils.close(jf1);
Utils.close(jf2);
}
Utils.cleanup();
if (errors > 0) {
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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -81,6 +81,7 @@ public class UnpackerMemoryTest {
Utils.close(fos);
}
}
Utils.cleanup();
}
}
......@@ -75,6 +75,7 @@ class Utils {
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 @@ class Utils {
}
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 @@ class Utils {
}
compiler("-d",
"xclasses",
XCLASSES.getName(),
"@" + tmpFile.getAbsolutePath());
jar("cvfe",
VerifierJar.getName(),
"sun.tools.pack.verify.Main",
"-C",
"xclasses",
XCLASSES.getName(),
".");
}
......@@ -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() {
public boolean accept(File pathname) {
if (pathname.isDirectory()) {
......@@ -199,6 +226,9 @@ class Utils {
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) {
......
......@@ -41,5 +41,6 @@ public class TestTypeAnnotations {
"-C", Utils.TEST_CLS_DIR.getAbsolutePath(),
".");
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.
先完成此消息的编辑!
想要评论请 注册