4 #include "ntp_refclock.h"
9 /* Might need to be updated if a new refclock gets this id. */
10 static const int UNUSED_REFCLOCK_ID = 250;
13 void test_LocalClock(void);
14 void test_UnknownId(void);
27 test_LocalClock(void) {
28 #ifdef REFCLOCK /* clockname() is useless otherwise */
29 /* We test with a refclock address of type LOCALCLOCK.
32 u_int32 addr = REFCLOCK_ADDR;
33 addr |= REFCLK_LOCALCLOCK << 8;
37 address.sa4.sin_family = AF_INET;
38 address.sa4.sin_addr.s_addr = htonl(addr);
40 char stringStart[100]= "";
42 strcat(stringStart, clockname(REFCLK_LOCALCLOCK));
43 strcat(stringStart, "(8)");
45 char * expected = stringStart;
47 TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
49 TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST");
54 test_UnknownId(void) {
55 #ifdef REFCLOCK /* refnumtoa() is useless otherwise */
56 /* We test with a currently unused refclock ID */
57 u_int32 addr = REFCLOCK_ADDR;
58 addr |= UNUSED_REFCLOCK_ID << 8;
62 address.sa4.sin_family = AF_INET;
63 address.sa4.sin_addr.s_addr = htonl(addr);
65 char stringStart[100]= "REFCLK(";
67 snprintf(value, sizeof(value), "%d", UNUSED_REFCLOCK_ID);
68 strcat(stringStart,value);
69 strcat(stringStart,",4)");
70 char * expected = stringStart;
72 TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
74 TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST");