]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Changes for <netof> tests
authorLokesh Walase <lokeshw24@ntp.org>
Mon, 15 Jun 2015 05:35:04 +0000 (11:05 +0530)
committerLokesh Walase <lokeshw24@ntp.org>
Mon, 15 Jun 2015 05:35:04 +0000 (11:05 +0530)
bk: 557e6408CQ2CNpUdCoQnmo4ZTu-m7g

tests/libntp/c_sockaddrtest.h [new file with mode: 0644]
tests/libntp/netof.c
tests/libntp/sockaddrtest.h

diff --git a/tests/libntp/c_sockaddrtest.h b/tests/libntp/c_sockaddrtest.h
new file mode 100644 (file)
index 0000000..f5cd6b3
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef TESTS_SOCKADDRTEST_H
+#define TESTS_SOCKADDRTEST_H
+
+#include "ntp.h"
+#include "ntp_stdlib.h"
+
+sockaddr_u CreateSockaddr4(const char* address, unsigned int port) {
+       sockaddr_u s;
+       s.sa4.sin_family = AF_INET;
+       s.sa4.sin_addr.s_addr = inet_addr(address);
+       SET_PORT(&s, port);
+
+       return s;
+}
+
+int IsEqual(const sockaddr_u expected, const sockaddr_u actual) {
+       struct in_addr in;
+       struct in6_addr in6;
+
+       if (expected.sa.sa_family != actual.sa.sa_family) {
+               return 1==2;
+       }
+
+       if (actual.sa.sa_family == AF_INET) { // IPv4
+               if (expected.sa4.sin_port == actual.sa4.sin_port &&
+                       memcmp(&expected.sa4.sin_addr, &actual.sa4.sin_addr,
+                                  sizeof( in )) == 0) {
+                       return 1==1;
+               } else {
+                       return 1==2;
+               }
+       } else if (actual.sa.sa_family == AF_INET6) { //IPv6
+               if (expected.sa6.sin6_port == actual.sa6.sin6_port &&
+                       memcmp(&expected.sa6.sin6_addr, &actual.sa6.sin6_addr,
+                                  sizeof(in6)) == 0) {
+                       return 1==1;
+               } else {
+                       return 1==2;
+               }
+       } else { // Unknown family
+               return 1==2;
+       }
+}
+
+
+#endif // TESTS_SOCKADDRTEST_H
+
+
+
index 0774d2ccf273d263c86d0caa58be96103bc245a4..c6434448d310f85b1fdfcbf9424765cde4d5b1d5 100644 (file)
@@ -5,7 +5,7 @@
 //#include "ntp.h"
 //#include "ntp_net.h"
 
-#include "sockaddrtest.h"
+#include "c_sockaddrtest.h"
 
 void test_ClassBAddress(void) {
        sockaddr_u input = CreateSockaddr4("172.16.2.1", NTP_PORT);
index 97581f49562fc33504cc89ea53d9585cc30244f9..fd3e4af8219e1a60e8118dfcc4b5bd5075932de1 100644 (file)
@@ -1,57 +1,6 @@
 #ifndef TESTS_SOCKADDRTEST_H
 #define TESTS_SOCKADDRTEST_H
 
-#include "ntp.h"
-#include "ntp_stdlib.h"
-
-sockaddr_u CreateSockaddr4(const char* address, unsigned int port) {
-       sockaddr_u s;
-       s.sa4.sin_family = AF_INET;
-       s.sa4.sin_addr.s_addr = inet_addr(address);
-       SET_PORT(&s, port);
-
-       return s;
-}
-
-int IsEqual(const sockaddr_u expected, const sockaddr_u actual) {
-       struct in_addr in;
-       struct in6_addr in6;
-
-       if (expected.sa.sa_family != actual.sa.sa_family) {
-               return 1==2;
-       }
-
-       if (actual.sa.sa_family == AF_INET) { // IPv4
-               if (expected.sa4.sin_port == actual.sa4.sin_port &&
-                       memcmp(&expected.sa4.sin_addr, &actual.sa4.sin_addr,
-                                  sizeof( in )) == 0) {
-                       return 1==1;
-               } else {
-                       return 1==2;
-               }
-       } else if (actual.sa.sa_family == AF_INET6) { //IPv6
-               if (expected.sa6.sin6_port == actual.sa6.sin6_port &&
-                       memcmp(&expected.sa6.sin6_addr, &actual.sa6.sin6_addr,
-                                  sizeof(in6)) == 0) {
-                       return 1==1;
-               } else {
-                       return 1==2;
-               }
-       } else { // Unknown family
-               return 1==2;
-       }
-}
-
-
-#endif // TESTS_SOCKADDRTEST_H
-
-
-
-
-/*
-#ifndef TESTS_SOCKADDRTEST_H
-#define TESTS_SOCKADDRTEST_H
-
 #include "libntptest.h"
 
 extern "C" {
@@ -108,4 +57,3 @@ protected:
 
 #endif // TESTS_SOCKADDRTEST_H
 
-*/