summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/tests/libntp/decodenetnum.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/tests/libntp/decodenetnum.c')
-rw-r--r--contrib/ntp/tests/libntp/decodenetnum.c54
1 files changed, 44 insertions, 10 deletions
diff --git a/contrib/ntp/tests/libntp/decodenetnum.c b/contrib/ntp/tests/libntp/decodenetnum.c
index 681b712..0e9bc34 100644
--- a/contrib/ntp/tests/libntp/decodenetnum.c
+++ b/contrib/ntp/tests/libntp/decodenetnum.c
@@ -1,12 +1,21 @@
#include "config.h"
#include "ntp_stdlib.h"
-#include "ntp_calendar.h"
+#include "sockaddrtest.h"
+
#include "unity.h"
-#include "sockaddrtest.h"
+extern void test_IPv4AddressOnly(void);
+extern void test_IPv4AddressWithPort(void);
+//#ifdef ISC_PLATFORM_HAVEIPV6
+extern void test_IPv6AddressOnly(void);
+extern void test_IPv6AddressWithPort(void);
+//#endif /* ISC_PLATFORM_HAVEIPV6 */
+extern void test_IllegalAddress(void);
+extern void test_IllegalCharInPort(void);
-void test_IPv4AddressOnly(void) {
+void
+test_IPv4AddressOnly(void) {
const char *str = "192.0.2.1";
sockaddr_u actual;
@@ -19,7 +28,8 @@ void test_IPv4AddressOnly(void) {
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_IPv4AddressWithPort(void) {
+void
+test_IPv4AddressWithPort(void) {
const char *str = "192.0.2.2:2000";
sockaddr_u actual;
@@ -32,10 +42,15 @@ void test_IPv4AddressWithPort(void) {
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_IPv6AddressOnly(void) {
+
+void
+test_IPv6AddressOnly(void) {
+
+//#ifdef ISC_PLATFORM_HAVEIPV6 //looks like HAVEIPV6 checks if system has IPV6 capabilies. WANTIPV6 can be changed with build --disable-ipv6
+#ifdef ISC_PLATFORM_WANTIPV6
const struct in6_addr address = {
0x20, 0x01, 0x0d, 0xb8,
- 0x85, 0xa3, 0x08, 0xd3,
+ 0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
};
@@ -50,12 +65,24 @@ void test_IPv6AddressOnly(void) {
TEST_ASSERT_TRUE(decodenetnum(str, &actual));
TEST_ASSERT_TRUE(IsEqual(expected, actual));
+
+#else
+ TEST_IGNORE_MESSAGE("IPV6 disabled in build, skipping.");
+#endif /* ISC_PLATFORM_HAVEIPV6 */
+
+
}
-void test_IPv6AddressWithPort(void) {
+
+
+void
+test_IPv6AddressWithPort(void) {
+
+#ifdef ISC_PLATFORM_WANTIPV6
+
const struct in6_addr address = {
0x20, 0x01, 0x0d, 0xb8,
- 0x85, 0xa3, 0x08, 0xd3,
+ 0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
};
@@ -70,16 +97,23 @@ void test_IPv6AddressWithPort(void) {
TEST_ASSERT_TRUE(decodenetnum(str, &actual));
TEST_ASSERT_TRUE(IsEqual(expected, actual));
+
+#else
+ TEST_IGNORE_MESSAGE("IPV6 disabled in build, skipping.");
+#endif /* ISC_PLATFORM_HAVEIPV6 */
}
-void test_IllegalAddress(void) {
+
+void
+test_IllegalAddress(void) {
const char *str = "192.0.2.270:2000";
sockaddr_u actual;
TEST_ASSERT_FALSE(decodenetnum(str, &actual));
}
-void test_IllegalCharInPort(void) {
+void
+test_IllegalCharInPort(void) {
/* An illegal port does not make the decodenetnum fail, but instead
* makes it use the standard port.
*/
OpenPOWER on IntegriCloud