From: Lokesh Walase Date: Sun, 14 Jun 2015 14:58:01 +0000 (+0530) Subject: Files related to test X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3cd8a7e2b4287c5e0c9120262f8670c0b896a2af;p=thirdparty%2Fntp.git Files related to test bk: 557d9679p4Soi7TFwgu5dhoET1wtzQ --- diff --git a/tests/libntp/Makefile.am b/tests/libntp/Makefile.am index e3af5f30e..c7ffbf2d7 100644 --- a/tests/libntp/Makefile.am +++ b/tests/libntp/Makefile.am @@ -7,7 +7,7 @@ run_unity = cd $(srcdir) && ruby ../../sntp/unity/auto/generate_test_runner.rb #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 @@ -64,7 +64,7 @@ tests_SOURCES = $(top_srcdir)/sntp/tests_main.cpp \ lfptostr.cpp \ g_modetoa.cpp \ msyslog.cpp \ - netof.cpp \ + g_netof.cpp \ g_numtoa.cpp \ g_numtohost.cpp \ g_octtoint.cpp \ @@ -188,6 +188,14 @@ test_hextolfp_LDADD = \ $(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 \ @@ -284,6 +292,12 @@ test_hextolfp_SOURCES = \ run-test-hextolfp.c \ $(NULL) +test_netof_SOURCES = \ + netof.c \ + run-test-netof.c \ + $(NULL) + + test_a_md5encrypt_SOURCES = \ a_md5encrypt.c \ @@ -337,6 +351,9 @@ $(srcdir)/run-test-octtoint.c: $(srcdir)/octtoint.c $(std_unity_list) $(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 diff --git a/tests/libntp/sockaddrtest.h b/tests/libntp/sockaddrtest.h index 4baac4dd7..97581f495 100644 --- a/tests/libntp/sockaddrtest.h +++ b/tests/libntp/sockaddrtest.h @@ -1,6 +1,57 @@ #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" { @@ -56,3 +107,5 @@ protected: }; #endif // TESTS_SOCKADDRTEST_H + +*/