Skip to content

Commit ed7c34b

Browse files
fkistnertresf
authored andcommitted
Fix Library Load tests on Big Sur
Big Sur uses a shared dylib cache to lookup system libraries and frameworks. Checking existence in the file system will fail, but loading them will succeed nevertheless.
1 parent c388449 commit ed7c34b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

test/com/sun/jna/LibraryLoadTest.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,12 @@ public void testLoadLibraryWithLongName() throws Exception {
203203
public void testLoadFrameworkLibrary() {
204204
if (Platform.isMac()) {
205205
final String PATH = "/System/Library/Frameworks/CoreServices.framework";
206-
assertTrue("CoreServices not present on this setup, expected at " + PATH, new File(PATH).exists());
207206
try {
208207
NativeLibrary lib = NativeLibrary.getInstance("CoreServices");
209208
assertNotNull("CoreServices not found", lib);
210209
}
211210
catch(UnsatisfiedLinkError e) {
212-
fail("Should search /System/Library/Frameworks");
211+
failCoreServices("Should search /System/Library/Frameworks: ", e, PATH);
213212
}
214213
}
215214
}
@@ -218,31 +217,36 @@ public void testLoadFrameworkLibraryAbsolute() {
218217
if (Platform.isMac()) {
219218
final String PATH = "/System/Library/Frameworks/CoreServices";
220219
final String FRAMEWORK = PATH + ".framework";
221-
assertTrue("CoreServices not present on this setup, expected at " + FRAMEWORK, new File(FRAMEWORK).exists());
222220
try {
223221
NativeLibrary lib = NativeLibrary.getInstance(PATH);
224222
assertNotNull("CoreServices not found", lib);
225223
}
226224
catch(UnsatisfiedLinkError e) {
227-
fail("Should try FRAMEWORK.framework/FRAMEWORK if the absolute framework (truncated) path given exists: " + e);
225+
failCoreServices("Should try FRAMEWORK.framework/FRAMEWORK if the absolute framework (truncated) path given exists: ", e, FRAMEWORK);
228226
}
229227
}
230228
}
231229

232230
public void testLoadFrameworkLibraryAbsoluteFull() {
233231
if (Platform.isMac()) {
234232
final String PATH = "/System/Library/Frameworks/CoreServices.framework/CoreServices";
235-
assertTrue("CoreServices not present on this setup, expected at " + PATH, new File(PATH).exists());
236233
try {
237234
NativeLibrary lib = NativeLibrary.getInstance(PATH);
238235
assertNotNull("CoreServices not found", lib);
239236
}
240237
catch(UnsatisfiedLinkError e) {
241-
fail("Should try FRAMEWORK verbatim if the absolute path given exists: " + e);
238+
failCoreServices("Should try FRAMEWORK verbatim if the absolute path given exists: ", e, PATH);
242239
}
243240
}
244241
}
245242

243+
private void failCoreServices(String message, UnsatisfiedLinkError e, String expectedPath) {
244+
if (!new File(expectedPath).exists()) {
245+
message = "CoreServices not present on this setup, expected at " + expectedPath + "\n" + message;
246+
}
247+
fail(message + e);
248+
}
249+
246250
public void testHandleObjectMethods() {
247251
CLibrary lib = (CLibrary)load();
248252
String method = "toString";

0 commit comments

Comments
 (0)