diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-04-26 15:57:19 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-04-26 15:57:19 +0200 |
commit | de15df29bf5957fb3d983ed42adcaaab6d22415d (patch) | |
tree | 9fcb669f462ed4dd7068ebe063fc80064a6a7c11 | |
parent | 3208eab19ba40546708378280d6ed00ff90c3fd4 (diff) |
Consider glibc version when testing
3 files changed, 16 insertions, 2 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/nativec/GLibcVersion.java b/vespajlib/src/main/java/com/yahoo/nativec/GLibcVersion.java index b404e5b00df..03e419a943e 100644 --- a/vespajlib/src/main/java/com/yahoo/nativec/GLibcVersion.java +++ b/vespajlib/src/main/java/com/yahoo/nativec/GLibcVersion.java @@ -6,9 +6,16 @@ public class GLibcVersion { return initException; } private final String version; + private final int major; + private final int minor; public GLibcVersion() { version = gnu_get_libc_version(); + String [] parts = version.split("."); + major = parts.length > 0 ? Integer.valueOf(parts[0]) : -1; + minor = parts.length > 0 ? Integer.valueOf(parts[1]) : -1; } private native static String gnu_get_libc_version(); public String version() { return version; } + public int major() { return major; } + public int minor() { return minor; } } diff --git a/vespajlib/src/test/java/com/yahoo/nativec/GlibCTestCase.java b/vespajlib/src/test/java/com/yahoo/nativec/GlibCTestCase.java index 25ff67182f6..3a37116f606 100644 --- a/vespajlib/src/test/java/com/yahoo/nativec/GlibCTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/nativec/GlibCTestCase.java @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class GlibCTestCase { @Test @@ -21,7 +22,10 @@ public class GlibCTestCase { public void requireGlibcVersionIsDetected() { if (Platform.isLinux()) { assertNull(GLibcVersion.init()); - assertNotEquals("", new GLibcVersion().version()); + GLibcVersion version = new GLibcVersion(); + assertNotEquals("", version.version()); + assertTrue(version.major() >= 2); + assertTrue((version.major() >= 3) || ((version.major() == 2) && (version.minor() >= 17))); } else { assertEquals("Platform is unsúpported. Only supported on linux.", PosixFAdvise.init().getMessage()); } diff --git a/vespajlib/src/test/java/com/yahoo/nativec/MallInfoTestCase.java b/vespajlib/src/test/java/com/yahoo/nativec/MallInfoTestCase.java index 378e994fe84..e6b3e1cbf85 100644 --- a/vespajlib/src/test/java/com/yahoo/nativec/MallInfoTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/nativec/MallInfoTestCase.java @@ -10,7 +10,10 @@ public class MallInfoTestCase { @Test public void requireThatMallInfo2IsDetected() { if (Platform.isLinux()) { - assertNull(MallInfo2.init()); + GLibcVersion version = new GLibcVersion(); + if ((version.major() >= 3) || ((version.major() == 2) && (version.minor() >= 33))) { + assertNull(MallInfo2.init()); + } } else { assertEquals("Platform is unsúpported. Only supported on linux.", MallInfo2.init().getMessage()); } |