8230942: Support compressed cores in SA tests
Reviewed-by: dholmes, sspitsyn
This commit is contained in:
parent
9f4484ff92
commit
3e3d90d6a1
@ -34,26 +34,30 @@
|
|||||||
* @run main/othervm/timeout=2400 -Xmx1g ClhsdbCDSCore
|
* @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.IOException;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import jdk.test.lib.Asserts;
|
import java.util.ArrayList;
|
||||||
import java.util.regex.Pattern;
|
import java.util.Arrays;
|
||||||
import java.util.regex.Matcher;
|
import java.util.HashMap;
|
||||||
import jdk.internal.misc.Unsafe;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
|
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;
|
import jtreg.SkippedException;
|
||||||
|
|
||||||
class CrashApp {
|
class CrashApp {
|
||||||
@ -102,6 +106,7 @@ public class ClhsdbCDSCore {
|
|||||||
|
|
||||||
System.out.println(crashOut.getOutput());
|
System.out.println(crashOut.getOutput());
|
||||||
String crashOutputString = crashOut.getOutput();
|
String crashOutputString = crashOut.getOutput();
|
||||||
|
SATestUtils.unzipCores(new File("."));
|
||||||
String coreFileLocation = getCoreFileLocation(crashOutputString);
|
String coreFileLocation = getCoreFileLocation(crashOutputString);
|
||||||
if (coreFileLocation == null) {
|
if (coreFileLocation == null) {
|
||||||
if (Platform.isOSX()) {
|
if (Platform.isOSX()) {
|
||||||
|
@ -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.
|
* 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
|
||||||
@ -29,19 +29,20 @@
|
|||||||
* @run driver/timeout=240 TestJmapCore run heap
|
* @run driver/timeout=240 TestJmapCore run heap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import jdk.test.lib.Asserts;
|
import jdk.test.lib.Asserts;
|
||||||
import jdk.test.lib.JDKToolFinder;
|
import jdk.test.lib.JDKToolFinder;
|
||||||
import jdk.test.lib.JDKToolLauncher;
|
import jdk.test.lib.JDKToolLauncher;
|
||||||
import jdk.test.lib.Platform;
|
import jdk.test.lib.Platform;
|
||||||
|
import jdk.test.lib.Utils;
|
||||||
import jdk.test.lib.classloader.GeneratingClassLoader;
|
import jdk.test.lib.classloader.GeneratingClassLoader;
|
||||||
import jdk.test.lib.hprof.HprofParser;
|
import jdk.test.lib.hprof.HprofParser;
|
||||||
import jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import jdk.test.lib.Utils;
|
import jdk.test.lib.SA.SATestUtils;
|
||||||
import jtreg.SkippedException;
|
import jtreg.SkippedException;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class TestJmapCore {
|
public class TestJmapCore {
|
||||||
static final String pidSeparator = ":KILLED_PID";
|
static final String pidSeparator = ":KILLED_PID";
|
||||||
|
|
||||||
@ -97,9 +98,11 @@ public class TestJmapCore {
|
|||||||
? ProcessTools.executeProcess(pb)
|
? ProcessTools.executeProcess(pb)
|
||||||
: ProcessTools.executeProcess("sh", "-c", "ulimit -c unlimited && "
|
: ProcessTools.executeProcess("sh", "-c", "ulimit -c unlimited && "
|
||||||
+ ProcessTools.getCommandLine(pb));
|
+ ProcessTools.getCommandLine(pb));
|
||||||
|
File pwd = new File(".");
|
||||||
|
SATestUtils.unzipCores(pwd);
|
||||||
File core;
|
File core;
|
||||||
String pattern = Platform.isWindows() ? ".*\\.mdmp" : "core(\\.\\d+)?";
|
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) {
|
if (cores.length == 0) {
|
||||||
// /cores/core.$pid might be generated on macosx by default
|
// /cores/core.$pid might be generated on macosx by default
|
||||||
String pid = output.firstMatch("^(\\d+)" + pidSeparator, 1);
|
String pid = output.firstMatch("^(\\d+)" + pidSeparator, 1);
|
||||||
@ -110,7 +113,7 @@ public class TestJmapCore {
|
|||||||
} else {
|
} else {
|
||||||
Asserts.assertTrue(cores.length == 1,
|
Asserts.assertTrue(cores.length == 1,
|
||||||
"There are unexpected files containing core "
|
"There are unexpected files containing core "
|
||||||
+ ": " + String.join(",", new File(".").list()) + ".");
|
+ ": " + String.join(",", pwd.list()) + ".");
|
||||||
core = cores[0];
|
core = cores[0];
|
||||||
}
|
}
|
||||||
System.out.println("Found corefile: " + core.getAbsolutePath());
|
System.out.println("Found corefile: " + core.getAbsolutePath());
|
||||||
|
@ -22,12 +22,18 @@
|
|||||||
*/
|
*/
|
||||||
package jdk.test.lib.SA;
|
package jdk.test.lib.SA;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
import jdk.test.lib.Asserts;
|
import jdk.test.lib.Asserts;
|
||||||
import jdk.test.lib.Platform;
|
import jdk.test.lib.Platform;
|
||||||
import java.util.concurrent.TimeUnit;
|
import jtreg.SkippedException;
|
||||||
|
|
||||||
public class SATestUtils {
|
public class SATestUtils {
|
||||||
|
|
||||||
@ -77,4 +83,22 @@ public class SATestUtils {
|
|||||||
outStringList.addAll(cmdStringList);
|
outStringList.addAll(cmdStringList);
|
||||||
return outStringList;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user