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);
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
+#ifdef ISC_PLATFORM_HAVEIPV6
void
test_IPv6AddressOnly(void) {
const struct in6_addr address = {
TEST_ASSERT_TRUE(decodenetnum(str, &actual));
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
+#endif /* ISC_PLATFORM_HAVEIPV6 */
+#ifdef ISC_PLATFORM_HAVEIPV6
void
test_IPv6AddressWithPort(void) {
const struct in6_addr address = {
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
+#endif /* ISC_PLATFORM_HAVEIPV6 */
void
test_IllegalAddress(void) {
const char *str = "192.0.2.270:2000";
#include "unity.h"
#include "sockaddrtest.h"
+
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);
-void test_IgnoreIPv6Fields(void);
void
test_IPv4AddressWithPort(void) {
TEST_ASSERT_EQUAL_STRING("192.0.2.10:123", sockporttoa(&input));
}
+#ifdef ISC_PLATFORM_HAVEIPV6
void
test_IPv6AddressWithPort(void) {
const struct in6_addr address = {
TEST_ASSERT_EQUAL_STRING(expected, socktoa(&input));
TEST_ASSERT_EQUAL_STRING(expected_port, sockporttoa(&input));
}
+#endif /* ISC_PLATFORM_HAVEIPV6 */
void
test_ScopedIPv6AddressWithPort(void) {
TEST_ASSERT_FALSE(sock_hash(&input1) == sock_hash(&input2));
}
+#ifdef ISC_PLATFORM_HAVEIPV6
void
test_IgnoreIPv6Fields(void) {
const struct in6_addr address = {
TEST_ASSERT_EQUAL(sock_hash(&input1), sock_hash(&input2));
}
+#endif /* ISC_PLATFORM_HAVEIPV6 */
test-leapsec \
test-ntp_prio_q \
test-ntp_restrict \
+ test-ntp_util \
test-rc_cmdlength \
test-ntp_scanner \
$(NULL)
$(top_srcdir)/ntpd/ntp_leapsec.c \
$(top_srcdir)/ntpd/ntp_prio_q.c \
$(top_srcdir)/ntpd/ntp_restrict.c \
+ $(top_srcdir)/ntpd/ntp_util.c \
$(top_srcdir)/ntpd/rc_cmdlength.c \
$(top_srcdir)/ntpd/ntp_signd.c \
g_leapsec.cpp \
$(srcdir)/run-leapsec.c \
$(srcdir)/run-ntp_prio_q.c \
$(srcdir)/run-ntp_restrict.c \
+ $(srcdir)/run-ntp_util.c \
$(srcdir)/run-rc_cmdlength.c \
$(srcdir)/run-ntp_signd.c \
$(NULL)
noinst_HEADERS = g_ntpdtest.h \
$(srcdir)/../libntp/test-libntp.h \
+ sockaddrtest.h \
$(NULL)
###
$(run_unity) ntp_restrict.c run-ntp_restrict.c
+###
+test_ntp_util_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
+ $(NULL)
+
+test_ntp_util_LDADD = \
+ $(unity_tests_LDADD) \
+ $(NULL)
+
+test_ntp_util_SOURCES = \
+ ntp_util.c \
+ run-ntp_util.c \
+ $(srcdir)/../libntp/test-libntp.c \
+ $(NULL)
+
+$(srcdir)/run-ntp_util.c: $(srcdir)/ntp_util.c $(std_unity_list)
+ $(run_unity) ntp_util.c run-ntp_util.c
+
+
###
test_rc_cmdlength_CFLAGS = \
-I$(top_srcdir)/sntp/unity \
--- /dev/null
+#include "config.h"
+
+#include "ntp.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+#include "unity.h"
+#include "test-libntp.h"
+
+#include <time.h>
+#include <string.h>
+
+void test_mprintf_clock_stats(void){
+ char *one = "this";
+ char *two = "is";
+ char *three = "becoming a string";
+
+ int ret_value1 = mprintf_clock_stats(NULL, "%s", one) ;
+ int ret_value2 = mprintf_clock_stats(NULL, "%s %s %s", one, two, three) ;
+
+ TEST_ASSERT_EQUAL( strlen(one), ret_value1);
+ TEST_ASSERT_EQUAL(25, ret_value2);
+
+}
+
+
+void test_fstostr(void){
+ u_int32 ntp;
+ char *buf ;
+
+ ntp = 0;
+ buf = fstostr(ntp);
+ TEST_ASSERT_EQUAL_STRING("203602070628", buf);
+ //The output format of function fstostr() is : YYYY-MM-DD-HH-MI
+ //[ Year-Month-MonthDay-Hour-Minute ]
+
+ ntp += 60; //Increment by 60 secs ie 1 minute
+ buf = fstostr(ntp);
+ TEST_ASSERT_EQUAL_STRING("203602070629", buf);
+
+ ntp += 60; //Increment by 60 secs ie 1 minute
+ buf = fstostr(ntp);
+ TEST_ASSERT_EQUAL_STRING("203602070630", buf);
+
+ ntp += 3600; //Increment by 3600 secs ie 1 hour
+ buf = fstostr(ntp);
+ TEST_ASSERT_EQUAL_STRING("203602070730", buf);
+
+ ntp += 3600; //Increment by 3600 secs ie 1 hour
+ buf = fstostr(ntp);
+ TEST_ASSERT_EQUAL_STRING("203602070830", buf);
+
+ ntp += (24*60*60); //Increment by 1 day
+ buf = fstostr(ntp);
+ TEST_ASSERT_EQUAL_STRING("203602080830", buf);
+
+ ntp += (24*60*60); //Increment by 1 day
+ buf = fstostr(ntp);
+ TEST_ASSERT_EQUAL_STRING("203602090830", buf);
+
+ ntp += (10*24*60*60); //Increment by 10 days
+ buf = fstostr(ntp);
+ TEST_ASSERT_EQUAL_STRING("203602190830", buf);
+
+ ntp += (12*24*60*60); //Increment by 12 days
+ buf = fstostr(ntp);
+ TEST_ASSERT_EQUAL_STRING("203603020830", buf);
+
+ ntp += (31*24*60*60); //Increment by 1 month
+ buf = fstostr(ntp);
+ TEST_ASSERT_EQUAL_STRING("203604020830", buf);
+
+}
+