From 3b4720f5016c6be0265861b16ff0d386dab0c00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bl=C3=A4sing?= Date: Fri, 23 Feb 2024 20:27:37 +0100 Subject: [PATCH 1/2] Run tests on mac OS M1 --- .github/workflows/ci.yaml | 34 +++++++++++++++++++ .../com/sun/jna/platform/mac/IOKitTest.java | 5 +-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7272cda05..edf26770b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/contrib/platform/test/com/sun/jna/platform/mac/IOKitTest.java b/contrib/platform/test/com/sun/jna/platform/mac/IOKitTest.java index 8810d452e..e2c2ead78 100644 --- a/contrib/platform/test/com/sun/jna/platform/mac/IOKitTest.java +++ b/contrib/platform/test/com/sun/jna/platform/mac/IOKitTest.java @@ -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)); @@ -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(); From cc385762c9aded119a08dbff4faa1ab9f934a8b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bl=C3=A4sing?= Date: Fri, 23 Feb 2024 20:29:43 +0100 Subject: [PATCH 2/2] Add workflow to build native libraries for mac OS / darwin on github --- .github/workflows/native-libraries-macOS.yaml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/native-libraries-macOS.yaml diff --git a/.github/workflows/native-libraries-macOS.yaml b/.github/workflows/native-libraries-macOS.yaml new file mode 100644 index 000000000..a03cebd84 --- /dev/null +++ b/.github/workflows/native-libraries-macOS.yaml @@ -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 \ No newline at end of file