#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-vi64ops
+test-hextoint test-atoint test-atouint test-authkeys test-a_md5encrypt test-lfpfunc test-vi64ops \
+test-refnumtoa
if GTEST_AVAILABLE
check_PROGRAMS += tests
octtoint.cpp \
prettydate.cpp \
recvbuff.cpp \
- refnumtoa.cpp \
+ g_refnumtoa.cpp \
sfptostr.cpp \
socktoa.cpp \
ssl_init.cpp \
$(unity_tests_LDADD) \
$(NULL)
+test_refnumtoa_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
+ $(NULL)
+
+test_refnumtoa_LDADD = \
+ $(LDADD) \
+ $(top_builddir)/sntp/unity/libunity.a \
+ $(NULL)
+
#removed one combined test, because unity devs suggested we use one program per test
#test_libntp_SOURCES = \
run-test-vi64ops.c \
$(NULL)
+test_refnumtoa_SOURCES = \
+ refnumtoa.c \
+ run-test-refnumtoa.c \
+ $(NULL)
$(srcdir)/run-test-modetoa.c: $(srcdir)/modetoa.c $(std_unity_list)
$(run_unity) modetoa.c run-test-modetoa.c
$(srcdir)/run-test-vi64ops.c: $(srcdir)/vi64ops.c $(std_unity_list)
$(run_unity) vi64ops.c run-test-vi64ops.c
+$(srcdir)/run-test-refnumtoa.c: $(srcdir)/refnumtoa.c $(std_unity_list)
+ $(run_unity) refnumtoa.c run-test-refnumtoa.c
+
TESTS =
--- /dev/null
+#include "config.h"
+#include "ntp_net.h"
+#include "ntp_refclock.h"
+
+#include "unity.h"
+
+
+/* Might need to be updated if a new refclock gets this id. */
+static const int UNUSED_REFCLOCK_ID = 250;
+
+
+void test_LocalClock() {
+#ifdef REFCLOCK /* clockname() is useless otherwise */
+ /* We test with a refclock address of type LOCALCLOCK.
+ * with id 8
+ */
+ u_int32 addr = REFCLOCK_ADDR;
+ addr |= REFCLK_LOCALCLOCK << 8;
+ addr |= 0x8;
+
+ sockaddr_u address;
+ address.sa4.sin_family = AF_INET;
+ address.sa4.sin_addr.s_addr = htonl(addr);
+
+ char stringStart [100]= "";
+
+ strcat(stringStart,clockname(REFCLK_LOCALCLOCK));
+ strcat(stringStart,"(8)");
+
+ char * expected = stringStart;
+
+ TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
+#else
+ TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST");
+#endif /* REFCLOCK */
+}
+
+
+
+void test_UnknownId() {
+#ifdef REFCLOCK /* refnumtoa() is useless otherwise */
+ /* We test with a currently unused refclock ID */
+ u_int32 addr = REFCLOCK_ADDR;
+ addr |= UNUSED_REFCLOCK_ID << 8;
+ addr |= 0x4;
+
+ sockaddr_u address;
+ address.sa4.sin_family = AF_INET;
+ address.sa4.sin_addr.s_addr = htonl(addr);
+
+ char stringStart [100]= "REFCLK(";
+ char value [100] ;
+ snprintf(value, sizeof(value), "%d", UNUSED_REFCLOCK_ID);
+ strcat(stringStart,value);
+ strcat(stringStart,",4)");
+ char * expected = stringStart;
+
+ TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
+#else
+ TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST");
+#endif /* REFCLOCK */
+}
+
--- /dev/null
+/* AUTOGENERATED FILE. DO NOT EDIT. */
+
+//=======Test Runner Used To Run Each Test Below=====
+#define RUN_TEST(TestFunc, TestLineNum) \
+{ \
+ Unity.CurrentTestName = #TestFunc; \
+ Unity.CurrentTestLineNumber = TestLineNum; \
+ Unity.NumberOfTests++; \
+ if (TEST_PROTECT()) \
+ { \
+ setUp(); \
+ TestFunc(); \
+ } \
+ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
+ { \
+ tearDown(); \
+ } \
+ UnityConcludeTest(); \
+}
+
+//=======Automagically Detected Files To Include=====
+#include "unity.h"
+#include <setjmp.h>
+#include <stdio.h>
+
+//=======External Functions This Runner Calls=====
+extern void setUp(void);
+extern void tearDown(void);
+extern void test_LocalClock();
+extern void test_UnknownId();
+
+
+//=======Test Reset Option=====
+void resetTest()
+{
+ tearDown();
+ setUp();
+}
+
+char *progname;
+
+
+//=======MAIN=====
+int main(int argc, char *argv[])
+{
+ progname = argv[0];
+ Unity.TestFile = "refnumtoa.c";
+ UnityBegin("refnumtoa.c");
+ RUN_TEST(test_LocalClock, 12);
+ RUN_TEST(test_UnknownId, 40);
+
+ return (UnityEnd());
+}
--- /dev/null
+/* AUTOGENERATED FILE. DO NOT EDIT. */
+
+//=======Test Runner Used To Run Each Test Below=====
+#define RUN_TEST(TestFunc, TestLineNum) \
+{ \
+ Unity.CurrentTestName = #TestFunc; \
+ Unity.CurrentTestLineNumber = TestLineNum; \
+ Unity.NumberOfTests++; \
+ if (TEST_PROTECT()) \
+ { \
+ setUp(); \
+ TestFunc(); \
+ } \
+ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
+ { \
+ tearDown(); \
+ } \
+ UnityConcludeTest(); \
+}
+
+//=======Automagically Detected Files To Include=====
+#include "unity.h"
+#include <setjmp.h>
+#include <stdio.h>
+
+//=======External Functions This Runner Calls=====
+extern void setUp(void);
+extern void tearDown(void);
+extern void test_ParseVUI64_pos();
+extern void test_ParseVUI64_neg();
+extern void test_ParseVUI64_case();
+
+
+//=======Test Reset Option=====
+void resetTest()
+{
+ tearDown();
+ setUp();
+}
+
+char *progname;
+
+
+//=======MAIN=====
+int main(int argc, char *argv[])
+{
+ progname = argv[0];
+ Unity.TestFile = "vi64ops.c";
+ UnityBegin("vi64ops.c");
+ RUN_TEST(test_ParseVUI64_pos, 33);
+ RUN_TEST(test_ParseVUI64_neg, 47);
+ RUN_TEST(test_ParseVUI64_case, 60);
+
+ return (UnityEnd());
+}