8310380: Handle problems in core-related tests on macOS when codesign tool does not work
Reviewed-by: lucy, clanger, cjplummer
This commit is contained in:
parent
526dba1a29
commit
39c104df44
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2023, 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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* @test TestJmapCoreMetaspace
|
||||
* @summary Test verifies that jhsdb jmap could generate heap dump from core when metspace is full
|
||||
* @summary Test verifies that jhsdb jmap could generate heap dump from core when metaspace is full
|
||||
* @requires vm.hasSA
|
||||
* @library /test/lib
|
||||
* @run driver/timeout=480 TestJmapCore run metaspace
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2023, 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
|
||||
@ -53,7 +53,7 @@ public class TestMutuallyExclusivePlatformPredicates {
|
||||
IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isMusl",
|
||||
"isSlowDebugBuild", "hasSA", "isRoot", "isTieredSupported",
|
||||
"areCustomLoadersSupportedForCDS", "isDefaultCDSArchiveSupported",
|
||||
"isHardenedOSX");
|
||||
"isHardenedOSX", "hasOSXPlistEntries");
|
||||
|
||||
public final List<String> methodNames;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2023, 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
|
||||
@ -260,6 +260,36 @@ public class Platform {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Process launchCodesignOnJavaBinary() throws IOException {
|
||||
String jdkPath = System.getProperty("java.home");
|
||||
Path javaPath = Paths.get(jdkPath + "/bin/java");
|
||||
String javaFileName = javaPath.toAbsolutePath().toString();
|
||||
if (Files.notExists(javaPath)) {
|
||||
throw new FileNotFoundException("Could not find file " + javaFileName);
|
||||
}
|
||||
ProcessBuilder pb = new ProcessBuilder("codesign", "--display", "--verbose", javaFileName);
|
||||
pb.redirectErrorStream(true); // redirect stderr to stdout
|
||||
Process codesignProcess = pb.start();
|
||||
return codesignProcess;
|
||||
}
|
||||
|
||||
public static boolean hasOSXPlistEntries() throws IOException {
|
||||
Process codesignProcess = launchCodesignOnJavaBinary();
|
||||
BufferedReader is = new BufferedReader(new InputStreamReader(codesignProcess.getInputStream()));
|
||||
String line;
|
||||
while ((line = is.readLine()) != null) {
|
||||
System.out.println("STDOUT: " + line);
|
||||
if (line.indexOf("Info.plist=not bound") != -1) {
|
||||
return false;
|
||||
}
|
||||
if (line.indexOf("Info.plist entries=") != -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
System.out.println("No matching Info.plist entry was found");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the test JDK is hardened, otherwise false. Only valid on OSX.
|
||||
*/
|
||||
@ -269,19 +299,7 @@ public class Platform {
|
||||
if (getOsVersionMajor() == 10 && getOsVersionMinor() < 14) {
|
||||
return false; // assume not hardened
|
||||
}
|
||||
|
||||
// Find the path to the java binary.
|
||||
String jdkPath = System.getProperty("java.home");
|
||||
Path javaPath = Paths.get(jdkPath + "/bin/java");
|
||||
String javaFileName = javaPath.toAbsolutePath().toString();
|
||||
if (Files.notExists(javaPath)) {
|
||||
throw new FileNotFoundException("Could not find file " + javaFileName);
|
||||
}
|
||||
|
||||
// Run codesign on the java binary.
|
||||
ProcessBuilder pb = new ProcessBuilder("codesign", "--display", "--verbose", javaFileName);
|
||||
pb.redirectErrorStream(true); // redirect stderr to stdout
|
||||
Process codesignProcess = pb.start();
|
||||
Process codesignProcess = launchCodesignOnJavaBinary();
|
||||
BufferedReader is = new BufferedReader(new InputStreamReader(codesignProcess.getInputStream()));
|
||||
String line;
|
||||
boolean isHardened = false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2023, 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
|
||||
@ -127,6 +127,8 @@ public class CoreUtils {
|
||||
}
|
||||
|
||||
return coreFileLocation; // success!
|
||||
} else {
|
||||
System.out.println("Core file not found. Trying to find a reason why...");
|
||||
}
|
||||
|
||||
// See if we can figure out the likely reason the core file was not found. Recover from
|
||||
@ -148,6 +150,11 @@ public class CoreUtils {
|
||||
// We can't generate cores files with hardened binaries on OSX 10.15 and later.
|
||||
throw new SkippedException("Cannot produce core file with hardened binary on OSX 10.15 and later");
|
||||
}
|
||||
} else {
|
||||
// codesign has to add entitlements using the plist. If this is not present we might not generate a core file.
|
||||
if (!Platform.hasOSXPlistEntries()) {
|
||||
throw new SkippedException("Cannot produce core file with binary having no plist entitlement entries");
|
||||
}
|
||||
}
|
||||
} else if (Platform.isLinux()) {
|
||||
// Check if a crash report tool is installed.
|
||||
|
Loading…
Reference in New Issue
Block a user