From 85e0e6452d167db2fadd60543f875a6375339604 Mon Sep 17 00:00:00 2001 From: Alexander Matveev Date: Fri, 4 Oct 2024 21:21:47 +0000 Subject: [PATCH] 8341443: [macos] AppContentTest and SigningOptionsTest failed due to "codesign" does not fails with "--app-content" on macOS 15 Reviewed-by: asemenyuk --- .../jpackage/macosx/SigningOptionsTest.java | 11 ++++++++++- .../tools/jpackage/share/AppContentTest.java | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/test/jdk/tools/jpackage/macosx/SigningOptionsTest.java b/test/jdk/tools/jpackage/macosx/SigningOptionsTest.java index 9db836af992..fee874da2e8 100644 --- a/test/jdk/tools/jpackage/macosx/SigningOptionsTest.java +++ b/test/jdk/tools/jpackage/macosx/SigningOptionsTest.java @@ -91,8 +91,17 @@ public final class SigningOptionsTest { new String[]{"--type"}, "Option [--mac-installer-sign-identity] is not valid with type"}, // --app-content and --type app-image + // JDK-8340802: "codesign" may or may not fail if additional + // content is specified based on macOS version. For example on + // macOS 15 aarch64 "codesign" will not fail with additional content. + // Since we only need to check that warning is displayed when + // "codesign" fails and "--app-content" is provided, lets fail + // "codesign" for some better reason like identity which does not + // exists. {"Hello", - new String[]{"--app-content", TEST_DUKE}, + new String[]{"--app-content", TEST_DUKE, + "--mac-sign", + "--mac-app-image-sign-identity", "test-identity"}, null, "\"codesign\" failed and additional application content" + " was supplied via the \"--app-content\" parameter."}, diff --git a/test/jdk/tools/jpackage/share/AppContentTest.java b/test/jdk/tools/jpackage/share/AppContentTest.java index b31a6e637b2..a343e20d8a7 100644 --- a/test/jdk/tools/jpackage/share/AppContentTest.java +++ b/test/jdk/tools/jpackage/share/AppContentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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 @@ -34,6 +34,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import jdk.internal.util.OSVersion; /** * Tests generation of packages with input folder containing empty folders. @@ -48,6 +49,7 @@ import java.util.List; * @build jdk.jpackage.test.* * @build AppContentTest * @modules jdk.jpackage/jdk.jpackage.internal + * @modules java.base/jdk.internal.util * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=AppContentTest */ @@ -81,6 +83,17 @@ public class AppContentTest { @Test public void test() throws Exception { + // On macOS signing may or may not work for modified app bundles. + // It works on macOS 15 and up, but fails on macOS below 15. + final int expectedJPackageExitCode; + final boolean isMacOS15 = (OSVersion.current().compareTo( + new OSVersion(15, 0, 0)) > 0); + if (testPathArgs.contains(TEST_BAD) || (TKit.isOSX() && !isMacOS15)) { + expectedJPackageExitCode = 1; + } else { + expectedJPackageExitCode = 0; + } + new PackageTest().configureHelloApp() .addInitializer(cmd -> { for (String arg : testPathArgs) { @@ -99,9 +112,7 @@ public class AppContentTest { } }) - // On macOS we always signing app image and signing will fail, since - // test produces invalid app bundle. - .setExpectedExitCode(testPathArgs.contains(TEST_BAD) || TKit.isOSX() ? 1 : 0) + .setExpectedExitCode(expectedJPackageExitCode) .run(); } }