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;
12 void test_LocalClock(void);
13 void test_UnknownId(void);
17 test_LocalClock(void) {
18 #ifdef REFCLOCK /* clockname() is useless otherwise */
19 /* We test with a refclock address of type LOCALCLOCK.
22 u_int32 addr = REFCLOCK_ADDR;
23 addr |= REFCLK_LOCALCLOCK << 8;
27 address.sa4.sin_family = AF_INET;
28 address.sa4.sin_addr.s_addr = htonl(addr);
30 char stringStart[100]= "";
32 strcat(stringStart, clockname(REFCLK_LOCALCLOCK));
33 strcat(stringStart, "(8)");
35 char * expected = stringStart;
37 TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
39 TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST");
44 test_UnknownId(void) {
45 #ifdef REFCLOCK /* refnumtoa() is useless otherwise */
46 /* We test with a currently unused refclock ID */
47 u_int32 addr = REFCLOCK_ADDR;
48 addr |= UNUSED_REFCLOCK_ID << 8;
52 address.sa4.sin_family = AF_INET;
53 address.sa4.sin_addr.s_addr = htonl(addr);
55 char stringStart[100]= "REFCLK(";
57 snprintf(value, sizeof(value), "%d", UNUSED_REFCLOCK_ID);
58 strcat(stringStart,value);
59 strcat(stringStart,",4)");
60 char * expected = stringStart;
62 TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
64 TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST");