--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java Fri Sep 27 08:57:25 2019 -0700
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java Fri Sep 27 10:48:23 2019 -0700
@@ -34,26 +34,30 @@
* @run main/othervm/timeout=2400 -Xmx1g ClhsdbCDSCore
*/
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.HashMap;
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.Platform;
-import jdk.test.lib.process.OutputAnalyzer;
-import jdk.test.lib.cds.CDSTestUtils;
-import jdk.test.lib.cds.CDSOptions;
+import java.io.File;
import java.io.IOException;
-import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import jdk.test.lib.Asserts;
-import java.util.regex.Pattern;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import jdk.internal.misc.Unsafe;
-import java.util.Scanner;
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.Platform;
+import jdk.test.lib.cds.CDSOptions;
+import jdk.test.lib.cds.CDSTestUtils;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.SA.SATestUtils;
+
import jtreg.SkippedException;
class CrashApp {
@@ -102,6 +106,7 @@
System.out.println(crashOut.getOutput());
String crashOutputString = crashOut.getOutput();
+ SATestUtils.unzipCores(new File("."));
String coreFileLocation = getCoreFileLocation(crashOutputString);
if (coreFileLocation == null) {
if (Platform.isOSX()) {
--- a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java Fri Sep 27 08:57:25 2019 -0700
+++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java Fri Sep 27 10:48:23 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, 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
@@ -29,19 +29,20 @@
* @run driver/timeout=240 TestJmapCore run heap
*/
+import java.io.File;
+
import jdk.test.lib.Asserts;
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Platform;
+import jdk.test.lib.Utils;
import jdk.test.lib.classloader.GeneratingClassLoader;
import jdk.test.lib.hprof.HprofParser;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
-import jdk.test.lib.Utils;
+import jdk.test.lib.SA.SATestUtils;
import jtreg.SkippedException;
-import java.io.File;
-
public class TestJmapCore {
static final String pidSeparator = ":KILLED_PID";
@@ -97,9 +98,11 @@
? ProcessTools.executeProcess(pb)
: ProcessTools.executeProcess("sh", "-c", "ulimit -c unlimited && "
+ ProcessTools.getCommandLine(pb));
+ File pwd = new File(".");
+ SATestUtils.unzipCores(pwd);
File core;
String pattern = Platform.isWindows() ? ".*\\.mdmp" : "core(\\.\\d+)?";
- File[] cores = new File(".").listFiles((dir, name) -> name.matches(pattern));
+ File[] cores = pwd.listFiles((dir, name) -> name.matches(pattern));
if (cores.length == 0) {
// /cores/core.$pid might be generated on macosx by default
String pid = output.firstMatch("^(\\d+)" + pidSeparator, 1);
@@ -110,7 +113,7 @@
} else {
Asserts.assertTrue(cores.length == 1,
"There are unexpected files containing core "
- + ": " + String.join(",", new File(".").list()) + ".");
+ + ": " + String.join(",", pwd.list()) + ".");
core = cores[0];
}
System.out.println("Found corefile: " + core.getAbsolutePath());
--- a/test/lib/jdk/test/lib/SA/SATestUtils.java Fri Sep 27 08:57:25 2019 -0700
+++ b/test/lib/jdk/test/lib/SA/SATestUtils.java Fri Sep 27 10:48:23 2019 -0700
@@ -22,12 +22,18 @@
*/
package jdk.test.lib.SA;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
-import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+import java.util.zip.GZIPInputStream;
+
import jdk.test.lib.Asserts;
import jdk.test.lib.Platform;
-import java.util.concurrent.TimeUnit;
+import jtreg.SkippedException;
public class SATestUtils {
@@ -77,4 +83,22 @@
outStringList.addAll(cmdStringList);
return outStringList;
}
+
+ public static void unzipCores(File dir) {
+ File[] gzCores = dir.listFiles((directory, name) -> name.matches("core(\\.\\d+)?\\.gz"));
+ for (File gzCore : gzCores) {
+ String coreFileName = gzCore.getName().replace(".gz", "");
+ System.out.println("Unzipping core into " + coreFileName);
+ try (GZIPInputStream gzis = new GZIPInputStream(new FileInputStream(gzCore));
+ FileOutputStream fos = new FileOutputStream(coreFileName)) {
+ byte[] buffer = new byte[1024];
+ int length;
+ while ((length = gzis.read(buffer)) > 0) {
+ fos.write(buffer, 0, length);
+ }
+ } catch (IOException e) {
+ throw new SkippedException("Not able to unzip file: " + gzCore.getAbsolutePath(), e);
+ }
+ }
+ }
}