Skip to content

Commit

Permalink
Improve test stability on AIX (exclude tests that are expected to fail)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasblaesing committed Jun 14, 2022
1 parent c1565fb commit f58b0f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 7 additions & 2 deletions contrib/platform/test/com/sun/jna/platform/unix/LibCTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package com.sun.jna.platform.unix;

import com.sun.jna.Native;
import com.sun.jna.Platform;
import java.sql.Date;
import java.util.Map;

Expand Down Expand Up @@ -64,6 +65,10 @@ public void testSetenv() {

@Test
public void testGetLoadAvg() {
if (Platform.isAIX()) {
System.out.println("Skip testGetLoadAvg - getloadavg is not implemented on AIX");
return;
}
double[] loadavg = new double[3];
int retval = LibC.INSTANCE.getloadavg(loadavg, 3);
assertEquals(retval, 3);
Expand All @@ -79,10 +84,10 @@ public void testGethostnameGetdomainname() {
LibC.INSTANCE.gethostname(buffer, buffer.length);
String hostname = Native.toString(buffer);
System.out.println("Hostname: " + hostname);
assertTrue(hostname.length() > 0);
assertNotNull(hostname);
LibC.INSTANCE.getdomainname(buffer, buffer.length);
String domainname = Native.toString(buffer);
System.out.println("Domainname: " + domainname);
assertTrue(domainname.length() > 0);
assertNotNull(domainname);
}
}
5 changes: 5 additions & 0 deletions test/com/sun/jna/DirectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
}

public void testRegisterMethods() throws Exception {
if (Platform.isAIX()) {
// https://stackoverflow.com/questions/8961441/java-system-loadlibrarym-fails-on-aix-6-1
System.out.println("Skip " + getName() + " - libm can't be dynamically linked on AIX");
return;
}
assertEquals("Math library call failed", 1., MathLibrary.cos(0), .01);
assertTrue("Library not registered",
Native.registered(MathLibrary.class));
Expand Down
3 changes: 3 additions & 0 deletions test/com/sun/jna/JNALoadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ protected void assertJarExists() {
protected void assertLibraryExists() {
String osPrefix = Platform.getNativeLibraryResourcePrefix();
String name = System.mapLibraryName("jnidispatch").replace(".dylib", ".jnilib");
if(Platform.isAIX()) {
name = name.replaceAll(".so$", ".a");
}
File lib = new File(CLASSES + "/com/sun/jna/" + osPrefix + "/" + name);
if (!lib.exists()) {
throw new Error("Expected JNA library at " + lib + " is missing");
Expand Down

0 comments on commit f58b0f8

Please sign in to comment.