Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8352176: Automate setting up environment for mac signing tests #24087

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions test/jdk/tools/jpackage/TEST.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
keys=jpackagePlatformPackage
requires.properties=jpackage.test.SQETest jpackage.test.SignEnv
maxOutputSize=2000000
keys = \
jpackagePlatformPackage

requires.properties = \
jpackage.test.SQETest \
jpackage.test.MacSignTests

maxOutputSize = 2000000

# Run jpackage tests on windows platform sequentially.
# Having "share" directory in the list affects tests on other platforms.
@@ -9,10 +14,13 @@ maxOutputSize=2000000
# exclusiveAccess.dirs=share windows
# }
# but conditionals are not supported by jtreg configuration files.
exclusiveAccess.dirs=share windows
exclusiveAccess.dirs = \
share \
windows

modules=jdk.jpackage/jdk.jpackage.internal:+open \
jdk.jpackage/jdk.jpackage.internal.util \
jdk.jpackage/jdk.jpackage.internal.util.function \
java.base/jdk.internal.util \
jdk.jlink/jdk.tools.jlink.internal
modules = \
jdk.jpackage/jdk.jpackage.internal:+open \
jdk.jpackage/jdk.jpackage.internal.util \
jdk.jpackage/jdk.jpackage.internal.util.function \
java.base/jdk.internal.util \
jdk.jlink/jdk.tools.jlink.internal
5 changes: 4 additions & 1 deletion test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java
Original file line number Diff line number Diff line change
@@ -518,11 +518,14 @@ public static RuntimeException throwUnknownPlatformError() {
}

public static RuntimeException throwSkippedException(String reason) {
trace("Skip the test: " + reason);
RuntimeException ex = ThrowingSupplier.toSupplier(
() -> (RuntimeException) Class.forName("jtreg.SkippedException").getConstructor(
String.class).newInstance(reason)).get();
return throwSkippedException(reason);
}

public static RuntimeException throwSkippedException(RuntimeException ex) {
trace("Skip the test: " + ex.getMessage());
currentTest.notifySkipped(ex);
throw ex;
}
Original file line number Diff line number Diff line change
@@ -253,7 +253,7 @@ public void run() throws Throwable {
status = Status.Failed;
}

if (!KEEP_WORK_DIR.contains(status)) {
if (!KEEP_WORK_DIR.contains(status) && Files.isDirectory(workDir)) {
if (Files.isSameFile(workDir, Path.of("."))) {
// 1. If the work directory is the current directory, don't
// delete it, just clean as deleting it would be confusing.
22 changes: 18 additions & 4 deletions test/jdk/tools/jpackage/macosx/base/SigningBase.java
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
* @library /test/jdk/tools/jpackage/helpers
* @build jdk.jpackage.test.*
* @compile -Xlint:all -Werror SigningBase.java
* @requires (jpackage.test.SignEnv == "setup")
* @requires (jpackage.test.MacSignTests == "setup")
* @run main/othervm/timeout=1440 -Xmx512m jdk.jpackage.test.Main
* --jpt-run=SigningBase.setUp
*/
@@ -56,7 +56,7 @@
* @library /test/jdk/tools/jpackage/helpers
* @build jdk.jpackage.test.*
* @compile -Xlint:all -Werror SigningBase.java
* @requires (jpackage.test.SignEnv == "teardown")
* @requires (jpackage.test.MacSignTests == "teardown")
* @run main/othervm/timeout=1440 -Xmx512m jdk.jpackage.test.Main
* --jpt-run=SigningBase.tearDown
*/
@@ -88,15 +88,29 @@ private static CertificateRequest.Builder cert() {
return new CertificateRequest.Builder();
}

private static List<KeychainWithCertsSpec> signingEnv() {
return Stream.of(values()).map(StandardKeychain::spec).toList();
}

final KeychainWithCertsSpec spec;
}

public static void setUp() {
MacSign.setUp(Stream.of(StandardKeychain.values()).map(StandardKeychain::spec).toList());
MacSign.setUp(StandardKeychain.signingEnv());
}

public static void tearDown() {
MacSign.tearDown(Stream.of(StandardKeychain.values()).map(StandardKeychain::spec).toList());
MacSign.tearDown(StandardKeychain.signingEnv());
}

public static void verifySignTestEnvReady() {
if (!Inner.SIGN_ENV_READY) {
TKit.throwSkippedException(new IllegalStateException("Misconfigured signing test environment"));
}
}

private final class Inner {
private final static boolean SIGN_ENV_READY = MacSign.isDeployed(StandardKeychain.signingEnv());
}

enum CertIndex {