|
1 | 1 | /* |
2 | | - * Copyright (c) 2025, SAP SE. All rights reserved. |
| 2 | + * Copyright (c) 2025 SAP SE. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
21 | 21 | * questions. |
22 | 22 | */ |
23 | 23 |
|
24 | | -import java.io.File; |
| 24 | +import java.io.IOException; |
25 | 25 | import java.nio.file.Files; |
26 | 26 | import java.nio.file.Path; |
27 | 27 |
|
28 | | -import jdk.test.lib.JDKToolFinder; |
29 | | -import jdk.test.lib.Platform; |
30 | | -import jdk.test.lib.process.*; |
31 | | -import jdk.test.whitebox.WhiteBox; |
| 28 | +import org.testng.annotations.Test; |
32 | 29 |
|
33 | | -import tests.Helper; |
| 30 | +import jdk.test.lib.Platform; |
34 | 31 |
|
35 | 32 | import jtreg.SkippedException; |
36 | 33 |
|
| 34 | +import static org.testng.Assert.assertFalse; |
| 35 | +import static org.testng.Assert.assertTrue; |
| 36 | + |
| 37 | +import tests.Helper; |
| 38 | + |
37 | 39 | /* @test |
38 | | - * @bug 8264322 |
39 | 40 | * @summary Test the --add-sapmachine-tools plugin |
40 | | - * @requires os.family == "linux" | os.family == "mac" |
41 | 41 | * @library ../../lib |
42 | 42 | * @library /test/lib |
43 | 43 | * @modules java.base/jdk.internal.jimage |
44 | | - * jdk.jlink/jdk.tools.jlink.internal |
45 | | - * jdk.jlink/jdk.tools.jmod |
46 | 44 | * jdk.jlink/jdk.tools.jimage |
47 | | - * jdk.compiler |
48 | | - * @build tests.* |
49 | | - * @build jdk.test.whitebox.WhiteBox |
50 | | - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox |
51 | | - * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. CDSPluginTest |
| 45 | + * @run testng AddSapMachineToolsTest |
52 | 46 | */ |
53 | 47 |
|
54 | 48 | public class AddSapMachineToolsTest { |
55 | | - public static void main(String[] args) throws Throwable { |
56 | 49 |
|
57 | | - Helper helper = Helper.newHelper(); |
58 | | - if (helper == null) { |
59 | | - System.err.println("Test not run"); |
| 50 | + private final String[] sapMachineTools = { |
| 51 | + "bin/asprof", |
| 52 | + "lib/" + System.mapLibraryName("asyncProfiler"), |
| 53 | + "lib/async-profiler.jar", |
| 54 | + "lib/converter.jar", |
| 55 | + "legal/async/CHANGELOG.md", |
| 56 | + "legal/async/LICENSE", |
| 57 | + "legal/async/README.md" |
| 58 | + }; |
| 59 | + |
| 60 | + @Test |
| 61 | + public void testSapMachineTools() throws IOException { |
| 62 | + boolean shouldHaveAsync = Platform.isOSX() || |
| 63 | + (Platform.isLinux() && (Platform.isAArch64() || Platform.isPPC() || Platform.isX64()) && !Platform.isMusl()); |
| 64 | + |
| 65 | + Path sourceJavaHome = Path.of(System.getProperty("java.home")); |
| 66 | + |
| 67 | + if (!shouldHaveAsync) { |
| 68 | + for (String tool : sapMachineTools) { |
| 69 | + assertFalse(Files.exists(sourceJavaHome.resolve(tool)), tool + " should not exist."); |
| 70 | + } |
| 71 | + System.out.println("No SapMachine tools files found, as expected."); |
60 | 72 | return; |
61 | 73 | } |
62 | 74 |
|
63 | | - var sourceJavaHome = Path.of(System.getProperty("java.home")); |
| 75 | + Helper helper = Helper.newHelper(); |
| 76 | + if (helper == null) { |
| 77 | + throw new SkippedException("JDK image is not suitable for this test."); |
| 78 | + } |
64 | 79 |
|
65 | | - if (!Files.exists(sourceJavaHome.resolve("lib/async-profiler.jar"))) { |
66 | | - System.err.println("Test not run, async-profiler not configured"); |
67 | | - return; |
| 80 | + for (String tool : sapMachineTools) { |
| 81 | + assertTrue(Files.exists(sourceJavaHome.resolve(tool)), tool + " must exist."); |
68 | 82 | } |
| 83 | + System.out.println("All SapMachine tools files found, as expected."); |
69 | 84 |
|
70 | 85 | var module = "sapmachine.tools"; |
71 | 86 | helper.generateDefaultJModule(module); |
72 | | - var image = helper.generateDefaultImage(new String[] { "--add-sapmachine-tools" }, |
73 | | - module) |
74 | | - .assertSuccess(); |
75 | | - |
76 | | - String subDir = "lib/server/"; |
| 87 | + var image = helper |
| 88 | + .generateDefaultImage(new String[] { "--add-sapmachine-tools" }, module) |
| 89 | + .assertSuccess(); |
77 | 90 |
|
78 | | - helper.checkImage(image, module, null, null, |
79 | | - new String[] { "lib/async-profiler.jar", "lib/converter.jar", |
80 | | - "lib/" + System.mapLibraryName("asyncProfiler")}); |
| 91 | + helper.checkImage(image, module, null, null, sapMachineTools); |
81 | 92 | } |
82 | 93 | } |
0 commit comments