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() {
14 #ifdef REFCLOCK /* clockname() is useless otherwise */
15 /* We test with a refclock address of type LOCALCLOCK.
18 u_int32 addr = REFCLOCK_ADDR;
19 addr |= REFCLK_LOCALCLOCK << 8;
23 address.sa4.sin_family = AF_INET;
24 address.sa4.sin_addr.s_addr = htonl(addr);
26 char stringStart [100]= "";
28 strcat(stringStart,clockname(REFCLK_LOCALCLOCK));
29 strcat(stringStart,"(8)");
31 char * expected = stringStart;
33 TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
35 TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST");
41 void test_UnknownId() {
42 #ifdef REFCLOCK /* refnumtoa() is useless otherwise */
43 /* We test with a currently unused refclock ID */
44 u_int32 addr = REFCLOCK_ADDR;
45 addr |= UNUSED_REFCLOCK_ID << 8;
49 address.sa4.sin_family = AF_INET;
50 address.sa4.sin_addr.s_addr = htonl(addr);
52 char stringStart [100]= "REFCLK(";
54 snprintf(value, sizeof(value), "%d", UNUSED_REFCLOCK_ID);
55 strcat(stringStart,value);
56 strcat(stringStart,",4)");
57 char * expected = stringStart;
59 TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
61 TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST");