summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/tests/libntp/socktoa.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/tests/libntp/socktoa.c')
-rw-r--r--contrib/ntp/tests/libntp/socktoa.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/contrib/ntp/tests/libntp/socktoa.c b/contrib/ntp/tests/libntp/socktoa.c
index 8423106..e9be182 100644
--- a/contrib/ntp/tests/libntp/socktoa.c
+++ b/contrib/ntp/tests/libntp/socktoa.c
@@ -9,10 +9,8 @@
void setUp(void);
void test_IPv4AddressWithPort(void);
-//#ifdef ISC_PLATFORM_HAVEIPV6
void test_IPv6AddressWithPort(void);
void test_IgnoreIPv6Fields(void);
-//#endif /* ISC_PLATFORM_HAVEIPV6 */
void test_ScopedIPv6AddressWithPort(void);
void test_HashEqual(void);
void test_HashNotEqual(void);
@@ -22,13 +20,12 @@ void
setUp(void)
{
init_lib();
-
- return;
}
void
-test_IPv4AddressWithPort(void) {
+test_IPv4AddressWithPort(void)
+{
sockaddr_u input = CreateSockaddr4("192.0.2.10", 123);
TEST_ASSERT_EQUAL_STRING("192.0.2.10", socktoa(&input));
@@ -37,8 +34,8 @@ test_IPv4AddressWithPort(void) {
void
-test_IPv6AddressWithPort(void) {
-
+test_IPv6AddressWithPort(void)
+{
#ifdef ISC_PLATFORM_WANTIPV6
const struct in6_addr address = {
@@ -63,16 +60,18 @@ test_IPv6AddressWithPort(void) {
TEST_ASSERT_EQUAL_STRING(expected_port, sockporttoa(&input));
#else
+
TEST_IGNORE_MESSAGE("IPV6 disabled in build, skipping.");
#endif /* ISC_PLATFORM_HAVEIPV6 */
-
}
void
-test_ScopedIPv6AddressWithPort(void) {
+test_ScopedIPv6AddressWithPort(void)
+{
#ifdef ISC_PLATFORM_HAVESCOPEID
+
const struct in6_addr address = { { {
0xfe, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -95,12 +94,16 @@ test_ScopedIPv6AddressWithPort(void) {
TEST_ASSERT_EQUAL_STRING(expected, socktoa(&input));
TEST_ASSERT_EQUAL_STRING(expected_port, sockporttoa(&input));
#else
+
TEST_IGNORE_MESSAGE("Skipping because ISC_PLATFORM does not have Scope ID");
+
#endif
}
+
void
-test_HashEqual(void) {
+test_HashEqual(void)
+{
sockaddr_u input1 = CreateSockaddr4("192.00.2.2", 123);
sockaddr_u input2 = CreateSockaddr4("192.0.2.2", 123);
@@ -108,8 +111,10 @@ test_HashEqual(void) {
TEST_ASSERT_EQUAL(sock_hash(&input1), sock_hash(&input2));
}
+
void
-test_HashNotEqual(void) {
+test_HashNotEqual(void)
+{
/* These two addresses should not generate the same hash. */
sockaddr_u input1 = CreateSockaddr4("192.0.2.1", 123);
sockaddr_u input2 = CreateSockaddr4("192.0.2.2", 123);
@@ -120,15 +125,15 @@ test_HashNotEqual(void) {
void
-test_IgnoreIPv6Fields(void) {
-
+test_IgnoreIPv6Fields(void)
+{
#ifdef ISC_PLATFORM_WANTIPV6
const struct in6_addr address = {
0x20, 0x01, 0x0d, 0xb8,
- 0x85, 0xa3, 0x08, 0xd3,
- 0x13, 0x19, 0x8a, 0x2e,
- 0x03, 0x70, 0x73, 0x34
+ 0x85, 0xa3, 0x08, 0xd3,
+ 0x13, 0x19, 0x8a, 0x2e,
+ 0x03, 0x70, 0x73, 0x34
};
sockaddr_u input1, input2;
@@ -146,7 +151,8 @@ test_IgnoreIPv6Fields(void) {
TEST_ASSERT_EQUAL(sock_hash(&input1), sock_hash(&input2));
#else
+
TEST_IGNORE_MESSAGE("IPV6 disabled in build, skipping.");
+
#endif /* ISC_PLATFORM_HAVEIPV6 */
}
-
OpenPOWER on IntegriCloud