Skip to content

Commit

Permalink
Merge branch 'master' into add_jdk25_to_triage
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfarley authored Dec 12, 2024
2 parents 9cd3e71 + 957c2d3 commit 4a91cc5
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/init@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -68,7 +68,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/autobuild@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -81,6 +81,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/analyze@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/ossf-scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ jobs:
name: SARIF file
path: results.sarif
retention-days: 5
- uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v2.13.4
- uses: github/codeql-action/upload-sarif@babb554ede22fd5605947329c4d04d8e7a0b8155 # v2.13.4
with:
sarif_file: results.sarif
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* ********************************************************************************
* Copyright (c) 2021 Contributors to the Eclipse Foundation
* Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) with this work for additional
* information regarding copyright ownership.
Expand All @@ -15,20 +15,27 @@

package net.adoptium.test;

import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.logging.Logger;
import java.util.regex.Pattern;

import static net.adoptium.test.JdkPlatform.Architecture;
import static net.adoptium.test.JdkPlatform.OperatingSystem;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import net.adoptium.test.JdkPlatform.Architecture;
import net.adoptium.test.JdkPlatform.OperatingSystem;

/**
* Tests the availability of various features like garbage collectors, flight recorder, that need to be enabled via
Expand Down Expand Up @@ -104,6 +111,68 @@ public void testLinkableRuntimeJDK24Plus() {
}
}

/**
* Tests whether basic jlink works using the default module path. The only
* included module in the output image is {@code java.base}.
*/
@Test
public void testJlinkJdk11AndBetter() throws IOException {
// Only JDK 11 (JDK 9, really) and better have jlink
if (jdkVersion.isNewerOrEqual(11)) {
Path output = Paths.get("java.base-image");
ensureOutputDirectoryDeleted(output);
List<String> command = new ArrayList<>();
command.add(String.format("%s/bin/jlink", testJdkHome));
command.add("--add-modules");
command.add("java.base");
command.add("--output");
command.add(output.toString());
command.add("--verbose");

try {
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.inheritIO();
Process process = processBuilder.start();

if (process.waitFor() != 0) {
throw new AssertionError("Basic jlink smoke test failed! " + command);
}
LOGGER.info("Basic jlink smoke test passed. Command was: " + command);
} catch (InterruptedException | IOException e) {
throw new RuntimeException("Failed to launch JVM", e);
} finally {
ensureOutputDirectoryDeleted(output);
}
}
}

private static void ensureOutputDirectoryDeleted(final Path path) throws IOException {
if (Files.exists(path)) {
deleteDirRecursively(path);
}
}

private static void deleteDirRecursively(final Path path) throws IOException {
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {

@Override
public FileVisitResult postVisitDirectory(final Path dir, final IOException e) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}

@Override
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
if (Files.isDirectory(file)) {
// deleted in post-visit
return FileVisitResult.CONTINUE;
}
Files.delete(file);
return FileVisitResult.CONTINUE;
}
});
}

private boolean isVendorAdoptium() {
return System.getProperty("java.vendor", "").toLowerCase(Locale.US).contains("adoptium");
}
Expand Down

0 comments on commit 4a91cc5

Please sign in to comment.