# The logtime test is used to compare the kernel realtime # clock and the kernel monotonic clock, so that leap # second may be observed. diff -Naru old/tests/ntpd/logtime.c new/tests/ntpd/logtime.c --- old/tests/ntpd/logtime.c 1969-12-31 18:00:00.000000000 -0600 +++ new/tests/ntpd/logtime.c 2017-05-30 13:22:11.827179154 -0500 @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +/* + * Generate a log messages 4 times per second + * to verify leap second. The CLOCK_MONOTONIC_RAW + * is the time since boot unaffected by adjustments. + * + * CLOCK_REALTIME is the UTC clock, which is affected + * by leap seconds. + * + * Program does not exit. + * + */ +main() +{ + openlog("CTST",0,LOG_LOCAL2); + while(1) { + struct timespec ts,unused,ep; + if (clock_gettime(CLOCK_MONOTONIC,&ts) == 0) { + + if(ts.tv_nsec < 750000000) + ts.tv_nsec += 250000000; + else { + ts.tv_nsec -= 750000000; + ts.tv_sec += 1; + } + clock_nanosleep(CLOCK_MONOTONIC,TIMER_ABSTIME,&ts,&unused); + clock_gettime(CLOCK_MONOTONIC_RAW,&ts); + ts.tv_nsec /= 1000000; + clock_gettime(CLOCK_REALTIME,&ep); + ep.tv_nsec /= 1000000; + syslog(LOG_NOTICE,"epoch: %lu.%3.3ld boot: %lu.%3.3ld", + ep.tv_sec,ep.tv_nsec, + ts.tv_sec,ts.tv_nsec); + + } + + + } + +} diff -Naru old/tests/ntpd/Makefile.am new/tests/ntpd/Makefile.am --- old/tests/ntpd/Makefile.am 2017-05-30 13:31:45.124160267 -0500 +++ new/tests/ntpd/Makefile.am 2017-05-30 16:53:59.784755988 -0500 @@ -29,6 +29,7 @@ test-ntp_restrict \ test-ntp_scanner \ test-ntp_signd \ + logtime \ $(NULL) @@ -191,8 +192,8 @@ ## check-libntp.mf - automake fragment ## slightly adapted for deeper directory -BUILT_SOURCES += check-libntpd check-libntp check-libunity -CLEANFILES += check-libntpd check-libntp check-libunity +BUILT_SOURCES += check-libntpd check-libntp check-libunity logtime +CLEANFILES += check-libntpd check-libntp check-libunity logtime check-libntpd: ../../ntpd/libntpd.a @echo stamp > $@