From c15438cf79a12f80c83b4b8d3f226bcea63e6e88 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Wed, 11 Dec 2024 21:31:38 +0100 Subject: [PATCH] Test fixes --- .../jlink/bindservices/BindServices.java | 22 ++++++------- .../jlink/bindservices/SuggestProviders.java | 32 +++++++++---------- .../AbstractLinkableRuntimeTest.java | 4 +-- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/test/jdk/tools/jlink/bindservices/BindServices.java b/test/jdk/tools/jlink/bindservices/BindServices.java index 8a34801212d3f..89095631040f5 100644 --- a/test/jdk/tools/jlink/bindservices/BindServices.java +++ b/test/jdk/tools/jlink/bindservices/BindServices.java @@ -69,14 +69,12 @@ public class BindServices { private static String[] modules = new String[] {"m1", "m2", "m3"}; - private static boolean isApplicable() { - if (!JMODS_EXIST) { - if (!LINKABLE_RUNTIME) { - System.err.println("Test skipped. Not a linkable runtime and no JMODs"); - return false; - } + private static boolean isExplodedJDKImage() { + if (!JMODS_EXIST && !LINKABLE_RUNTIME) { + System.err.println("Test skipped. Not a linkable runtime and no JMODs"); + return true; } - return true; + return false; } /* @@ -84,7 +82,7 @@ private static boolean isApplicable() { */ @BeforeTest public void compileAll() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; for (String mn : modules) { Path msrc = SRC_DIR.resolve(mn); @@ -95,7 +93,7 @@ public void compileAll() throws Throwable { @Test public void noServiceBinding() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; Path dir = Paths.get("noServiceBinding"); @@ -109,7 +107,7 @@ public void noServiceBinding() throws Throwable { @Test public void fullServiceBinding() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; Path dir = Paths.get("fullServiceBinding"); @@ -128,7 +126,7 @@ public void fullServiceBinding() throws Throwable { @Test public void testVerbose() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; Path dir = Paths.get("verbose"); @@ -159,7 +157,7 @@ public void testVerbose() throws Throwable { @Test public void testVerboseAndNoBindServices() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; Path dir = Paths.get("verboseNoBind"); diff --git a/test/jdk/tools/jlink/bindservices/SuggestProviders.java b/test/jdk/tools/jlink/bindservices/SuggestProviders.java index 7590c359353d3..794d22fc57042 100644 --- a/test/jdk/tools/jlink/bindservices/SuggestProviders.java +++ b/test/jdk/tools/jlink/bindservices/SuggestProviders.java @@ -69,14 +69,12 @@ public class SuggestProviders { private static String[] modules = new String[] {"m1", "m2", "m3"}; - private static boolean isApplicable() { - if (!JMODS_EXIST) { - if (!LINKABLE_RUNTIME) { - System.err.println("Test skipped. Not a linkable runtime and no JMODs"); - return false; - } + private static boolean isExplodedJDKImage() { + if (!JMODS_EXIST && !LINKABLE_RUNTIME) { + System.err.println("Test skipped. Not a linkable runtime and no JMODs"); + return true; } - return true; + return false; } /* @@ -84,7 +82,7 @@ private static boolean isApplicable() { */ @BeforeTest public void compileAll() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; for (String mn : modules) { Path msrc = SRC_DIR.resolve(mn); @@ -134,7 +132,7 @@ public void compileAll() throws Throwable { @Test public void suggestProviders() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; List output = JLink.run("--module-path", MODULE_PATH, "--suggest-providers").output(); @@ -154,7 +152,7 @@ public void suggestProviders() throws Throwable { */ @Test public void observableModules() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; List output = JLink.run("--module-path", MODULE_PATH, "--add-modules", "m1", @@ -174,7 +172,7 @@ public void observableModules() throws Throwable { */ @Test public void limitModules() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; List output = JLink.run("--module-path", MODULE_PATH, "--limit-modules", "m1", @@ -193,7 +191,7 @@ public void limitModules() throws Throwable { @Test public void providersForServices() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; List output = JLink.run("--module-path", MODULE_PATH, @@ -212,7 +210,7 @@ public void providersForServices() throws Throwable { @Test public void unusedService() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; List output = JLink.run("--module-path", MODULE_PATH, @@ -230,7 +228,7 @@ public void unusedService() throws Throwable { @Test public void nonExistentService() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; List output = JLink.run("--module-path", MODULE_PATH, @@ -245,7 +243,7 @@ public void nonExistentService() throws Throwable { @Test public void noSuggestProviders() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; List output = JLink.run("--module-path", MODULE_PATH, @@ -259,7 +257,7 @@ public void noSuggestProviders() throws Throwable { @Test public void suggestTypeNotRealProvider() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; List output = JLink.run("--module-path", MODULE_PATH, @@ -277,7 +275,7 @@ public void suggestTypeNotRealProvider() throws Throwable { @Test public void addNonObservableModule() throws Throwable { - if (!isApplicable()) return; + if (isExplodedJDKImage()) return; List output = JLink.run("--module-path", MODULE_PATH, diff --git a/test/jdk/tools/jlink/runtimeImage/AbstractLinkableRuntimeTest.java b/test/jdk/tools/jlink/runtimeImage/AbstractLinkableRuntimeTest.java index 7acb1991d11f4..1df4455bc7dc2 100644 --- a/test/jdk/tools/jlink/runtimeImage/AbstractLinkableRuntimeTest.java +++ b/test/jdk/tools/jlink/runtimeImage/AbstractLinkableRuntimeTest.java @@ -192,8 +192,8 @@ protected Path jlinkUsingImage(JlinkSpec spec, OutputAnalyzerHandler handler, Pr // if the exit checker failed, we expected the other outcome // i.e. fail for success and success for fail. boolean successExit = analyzer.getExitValue() == 0; - String msg = String.format("Expected jlink to %s given a run-time image " + - "link capable image. Exit code was: %d", + String msg = String.format("Expected jlink to %s given a linkable run-time image. " + + "Exit code was: %d", (successExit ? "fail" : "pass"), analyzer.getExitValue()); throw new AssertionError(msg); }