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

Improve Testing / native libarary building for darwin/mac OS #1594

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,37 @@ jobs:
run: |
ant test
ant test-platform

test-m1:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [21]
# macos-14 is documented to run on m1
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
os: [macos-14]
# Run all tests even if one fails
fail-fast: true
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
- name: Linux requirements
if: contains(matrix.os, 'ubuntu')
run: sudo apt-get -y install texinfo
- name: macOS requirements
if: contains(matrix.os, 'macos')
run: |
brew update
brew install automake --force
brew install libtool --force
brew install texinfo --force
- name: Run test
run: |
ant test
ant test-platform
42 changes: 42 additions & 0 deletions .github/workflows/native-libraries-macOS.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Build native library for mac OS
name: mac OS native libraries

on:
workflow_dispatch:

permissions:
contents: read

jobs:
build-native-darwin:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [21]
os: [macos-latest]
name: Build native libraries for mac OS / darwin

steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
- name: macOS requirements
if: contains(matrix.os, 'macos')
run: |
brew update
brew install automake --force
brew install libtool --force
- name: Build native code
run: |
ant -Dos.prefix=darwin-aarch64
ant -Dos.prefix=darwin-x86-64
- name: Upload mac OS binaries
uses: actions/upload-artifact@v4
with:
name: darwin-native
path: |
lib/native/darwin-aarch64.jar
lib/native/darwin-x86-64.jar
5 changes: 3 additions & 2 deletions contrib/platform/test/com/sun/jna/platform/mac/IOKitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public void testMatching() {
String serialNumberViaUtil = platformExpert.getStringProperty("IOPlatformSerialNumber");
assertEquals(serialNumber, serialNumberViaUtil);

assertEquals(12, serialNumber.length());
assertTrue("Known serial number lengths are 10 and 12, was: " + serialNumber.length(),
serialNumber.length() == 12 || serialNumber.length() == 10);
// Get all the keys
dict = platformExpert.createCFProperties();
assertNotEquals(0, dict.getValueIfPresent(serialKey, null));
Expand Down Expand Up @@ -214,7 +215,7 @@ public void testIOConnect() {
int masterPort = IOKitUtil.getMasterPort();

IOService smcService = IOKitUtil.getMatchingService("AppleSMC");
assertNotNull(smcService);
assumeTrue(smcService != null); // Service is not available on github M1 runners

PointerByReference connPtr = new PointerByReference();
int taskSelf = SYS.mach_task_self();
Expand Down
Loading