Skip to content

Commit 195ebb4

Browse files
Merge pull request #1502 from matthiasblaesing/disable_unload_test_on_macos
Disable NativeLibraryTest#testAvoidDumplicateLoads
2 parents 8f9886f + 5cf43c9 commit 195ebb4

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

test/com/sun/jna/NativeLibraryTest.java

+16-10
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,22 @@ public void testGCNativeLibrary() throws Exception {
8282
}
8383

8484
public void testAvoidDuplicateLoads() throws Exception {
85-
NativeLibrary.disposeAll();
86-
// Give the system a moment to unload the library; on OSX we
87-
// occasionally get the same library handle back on subsequent dlopen
88-
Thread.sleep(2);
89-
90-
TestLibrary lib = Native.load("testlib", TestLibrary.class);
91-
assertEquals("Library should be newly loaded after explicit dispose of all native libraries",
92-
1, lib.callCount());
93-
if (lib.callCount() <= 1) {
94-
fail("Library should not be reloaded without dispose");
85+
// This test basicly tests whether unloading works. It relies on the
86+
// runtime to unload the library when dlclose is called. This is not
87+
// required by POSIX and dt time of writing macOS is known to be flaky
88+
// in that regard.
89+
//
90+
// This test causes false test failures
91+
if (!Platform.isMac()) {
92+
NativeLibrary.disposeAll();
93+
Thread.sleep(2);
94+
95+
TestLibrary lib = Native.load("testlib", TestLibrary.class);
96+
assertEquals("Library should be newly loaded after explicit dispose of all native libraries",
97+
1, lib.callCount());
98+
if (lib.callCount() <= 1) {
99+
fail("Library should not be reloaded without dispose");
100+
}
95101
}
96102
}
97103

0 commit comments

Comments
 (0)