#removed test-libntp
check_PROGRAMS = test-modetoa test-uglydate test-ymd2yd test-statestr test-numtoa test-numtohost \
test-hextoint test-atoint test-atouint test-authkeys test-a_md5encrypt test-lfpfunc test-octtoint \
-test-hextolfp
+test-hextolfp test-netof
if GTEST_AVAILABLE
check_PROGRAMS += tests
lfptostr.cpp \
g_modetoa.cpp \
msyslog.cpp \
- netof.cpp \
+ g_netof.cpp \
g_numtoa.cpp \
g_numtohost.cpp \
g_octtoint.cpp \
$(unity_tests_LDADD)
$(NULL)
+test_netof_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
+ $(NULL)
+
+test_netof_LDADD = \
+ $(unity_tests_LDADD)
+ $(NULL)
+
test_a_md5encrypt_CFLAGS = \
-I$(top_srcdir)/sntp/unity \
run-test-hextolfp.c \
$(NULL)
+test_netof_SOURCES = \
+ netof.c \
+ run-test-netof.c \
+ $(NULL)
+
+
test_a_md5encrypt_SOURCES = \
a_md5encrypt.c \
$(srcdir)/run-test-hextolfp.c: $(srcdir)/hextolfp.c $(std_unity_list)
$(run_unity) hextolfp.c run-test-hextolfp.c
+$(srcdir)/run-test-netof.c: $(srcdir)/netof.c $(std_unity_list)
+ $(run_unity) netof.c run-test-netof.c
+
$(srcdir)/run-test-a_md5encrypt.c: $(srcdir)/a_md5encrypt.c $(std_unity_list)
$(run_unity) a_md5encrypt.c run-test-a_md5encrypt.c
#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" {
};
#endif // TESTS_SOCKADDRTEST_H
+
+*/