Skip to content

Commit

Permalink
Merge pull request #1502 from matthiasblaesing/disable_unload_test_on…
Browse files Browse the repository at this point in the history
…_macos

Disable NativeLibraryTest#testAvoidDumplicateLoads
  • Loading branch information
matthiasblaesing authored Feb 2, 2023
2 parents 8f9886f + 5cf43c9 commit 195ebb4
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions test/com/sun/jna/NativeLibraryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,22 @@ public void testGCNativeLibrary() throws Exception {
}

public void testAvoidDuplicateLoads() throws Exception {
NativeLibrary.disposeAll();
// Give the system a moment to unload the library; on OSX we
// occasionally get the same library handle back on subsequent dlopen
Thread.sleep(2);

TestLibrary lib = Native.load("testlib", TestLibrary.class);
assertEquals("Library should be newly loaded after explicit dispose of all native libraries",
1, lib.callCount());
if (lib.callCount() <= 1) {
fail("Library should not be reloaded without dispose");
// This test basicly tests whether unloading works. It relies on the
// runtime to unload the library when dlclose is called. This is not
// required by POSIX and dt time of writing macOS is known to be flaky
// in that regard.
//
// This test causes false test failures
if (!Platform.isMac()) {
NativeLibrary.disposeAll();
Thread.sleep(2);

TestLibrary lib = Native.load("testlib", TestLibrary.class);
assertEquals("Library should be newly loaded after explicit dispose of all native libraries",
1, lib.callCount());
if (lib.callCount() <= 1) {
fail("Library should not be reloaded without dispose");
}
}
}

Expand Down

0 comments on commit 195ebb4

Please sign in to comment.