[Git][NTPsec/ntpsec][master] 2 commits: revert 'libntp: make ntpcal_ntp64_to_date() static'

Eric S. Raymond gitlab at mg.gitlab.com
Fri May 26 21:08:15 UTC 2017


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
a2af9e65 by Trevor N at 2017-05-26T16:21:57-04:00
revert 'libntp: make ntpcal_ntp64_to_date() static'

function is needed for 'workaround for Trimble GPS week number rollover' patch

- - - - -
d74cf1e3 by Trevor N at 2017-05-26T16:21:57-04:00
refclock_trimble: workaround for GPS week number rollover

The Thunderbolt(fw version 3.00) will report GPS week number 936 on 30-Jul-2017 (week 1960), the Palisade (7.12) will report week number 1004 on
17-Nov-2018 (week 2027), the Acutime 2000 (2.02) will report week number 989 on 5-Aug-2018, and the Acutime Gold (1.12) will report week number 1567
after 1-Sep-2029.

* uses ntpcal_get_build_date() to adjust GPS week number

* move gpstolfp.c from libparse to libntp, add functions to: adjust week number, convert from GPS week&time-of-week to calendar time, convert from
calendar time to GPS week&time-of-week

* For devices with Thunderbolt-style packets: the reported week number, TOW, and UTC offset along with the week number of ntpd's build date are used to
calculate the day/hour/minute/second for refclock_process()
* For devices with Palisade-style packets: the reported date and time are used to calcuate a GPS week number and TOW since the week isn't contained in
packets available on port A

* tested with standard antenna using Thunderbolt, Palisade, Praecis Cf, Acutime 2000, Acutime Gold on amd64/Gentoo and sparc64/OpenBSD 6.1 (on the
sparc64 machine, a T5220, Thunderbolt offset varies from 100 to 900ms between ntpd startups with and without this patch)

* tested with GPS signal generator with +2 year and +19y5d offset in the navigation message and libntp:get_systime() using Thunderbolt, Palisade,
Acutime 2000, and Acutime Gold on: amd64 Gentoo, x86 Debian Jessie.

* a warning is logged if the receiver's adjusted week is more than 1000 weeks ahead of the build date

- - - - -


12 changed files:

- + include/gpstolfp.h
- include/ntp_calendar.h
- include/ntp_fp.h
- libparse/gpstolfp.c → libntp/gpstolfp.c
- libntp/ntp_calendar.c
- libntp/wscript
- libparse/clk_trimtsip.c
- libparse/wscript
- ntpd/refclock_trimble.c
- tests/common/tests_main.c
- + tests/libntp/gpstolfp.c
- tests/wscript


Changes:

=====================================
include/gpstolfp.h
=====================================
--- /dev/null
+++ b/include/gpstolfp.h
@@ -0,0 +1,11 @@
+#include "ntp_calendar.h"
+#include "ntp_fp.h"
+#include "parse.h"
+
+#define MIN_BUILD_GPSWEEK  (1900) /* minimum GPS week number of compile*/
+#define MAX_BUILD_GPSWEEK (6078) /* testcase limit */
+
+extern void gpstolfp (int weeks, int days, unsigned long seconds, l_fp *);
+extern void gpsweekadj (u_int * week, u_int build_week);
+extern void gpstocal (u_int week, u_int TOW, int UTC_offset, struct calendar *);
+extern void caltogps (const struct calendar *, int UTC_offset, u_int * week, u_int * TOW);
\ No newline at end of file


=====================================
include/ntp_calendar.h
=====================================
--- a/include/ntp_calendar.h
+++ b/include/ntp_calendar.h
@@ -183,6 +183,9 @@ ntpcal_periodic_extend(int32_t /* pivot */, int32_t /* value */,
 		       int32_t /* cycle */) __attribute__((const));
 
 extern int
+ntpcal_ntp64_to_date(struct calendar * /* jd */, const time64_t /* ntp */);
+
+extern int
 ntpcal_ntp_to_date(struct calendar * /* jd */,	uint32_t /* ntp */,
 		   const time_t * /* pivot */);
 


=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -164,7 +164,6 @@ extern	char *	mfptoa		(l_fp, short);
 extern	char *	mfptoms		(l_fp, short);
 
 extern	bool	hextolfp	(const char *, l_fp *);
-extern  void	gpstolfp	(int, int, unsigned long, l_fp *);
 extern	char *	prettydate	(const l_fp);
 extern	char *	gmprettydate	(const l_fp);
 extern	char *	rfc3339date	(const l_fp);


=====================================
libparse/gpstolfp.c → libntp/gpstolfp.c
=====================================
--- a/libparse/gpstolfp.c
+++ b/libntp/gpstolfp.c
@@ -8,7 +8,7 @@
 #include "config.h"
 #include "ntp_fp.h"
 #include "ntp_calendar.h"
-#include "parse.h"
+#include "gpstolfp.h"
 
 #define GPSORIGIN       2524953600u  /* GPS origin - NTP origin in seconds */
 
@@ -33,6 +33,55 @@ gpstolfp(
   setlfpfrac(*lfp, 0);
 }
 
+
+void
+gpsweekadj(
+	u_int * week,
+	u_int build_week
+	)
+{
+	/* adjust for rollover */
+	while (*week < build_week)
+		*week += GPSWEEKS;
+}
+
+
+void
+gpstocal(
+	u_int week,
+	u_int TOW,
+	int UTC_offset,
+	struct calendar * out
+	)
+{
+	time64_t t;
+	
+	t = (time64_t)((int64_t)GPSORIGIN - UTC_offset);
+	t += (time64_t)week * SECSPERWEEK;
+	t += TOW;
+
+	ntpcal_ntp64_to_date(out, t);
+}
+
+
+void
+caltogps(
+	const struct calendar * in,
+	int UTC_offset,
+	u_int * week,
+	u_int * TOW
+	)
+{
+	time64_t t;
+
+	t = ntpcal_dayjoin(ntpcal_date_to_rd(in) - DAY_NTP_STARTS, 
+	                             ntpcal_date_to_daysec(in));
+	t -= (uint64_t)((int64_t)GPSORIGIN - UTC_offset);
+	*week = t / SECSPERWEEK;
+	if (NULL != TOW)
+		*TOW = t % SECSPERWEEK;
+}
+
 /*
  * History:
  *


=====================================
libntp/ntp_calendar.c
=====================================
--- a/libntp/ntp_calendar.c
+++ b/libntp/ntp_calendar.c
@@ -25,9 +25,6 @@
 static systime_func_ptr systime_func = &time;
 static inline time_t now(void);
 
-static int
-ntpcal_ntp64_to_date(struct calendar * /* jd */, const time64_t /* ntp */);
-
 static ntpcal_split
 ntpcal_days_in_months(int32_t /* months */);
 
@@ -872,7 +869,7 @@ ntpcal_date_to_time(
 }
 
 
-static int
+int
 ntpcal_ntp64_to_date(
 	struct calendar *jd,
 	const time64_t  ntp


=====================================
libntp/wscript
=====================================
--- a/libntp/wscript
+++ b/libntp/wscript
@@ -8,6 +8,7 @@ def build(ctx):
         "decodenetnum.c",
         "dolfptoa.c",
         "getopt.c",
+        "gpstolfp.c",
         "initnetwork.c",
         "macencrypt.c",
         "netof.c",


=====================================
libparse/clk_trimtsip.c
=====================================
--- a/libparse/clk_trimtsip.c
+++ b/libparse/clk_trimtsip.c
@@ -24,6 +24,7 @@
 #include "binio.h"
 #include "ieee754io.h"
 #include "trimble.h"
+#include "gpstolfp.h"
 
 /*
  * Trimble low level TSIP parser / time converter


=====================================
libparse/wscript
=====================================
--- a/libparse/wscript
+++ b/libparse/wscript
@@ -14,7 +14,6 @@ def build(ctx):
         "clk_varitext.c",
         "clk_wharton.c",
         "data_mbg.c",
-        "gpstolfp.c",
         "ieee754io.c",
         "info_trimble.c",
         "parse.c",


=====================================
ntpd/refclock_trimble.c
=====================================
--- a/ntpd/refclock_trimble.c
+++ b/ntpd/refclock_trimble.c
@@ -60,6 +60,7 @@
 #include "ntp_refclock.h"
 #include "ntp_stdlib.h"
 #include "timespecops.h"
+#include "gpstolfp.h"
 
 /*
  * GPS Definitions
@@ -153,7 +154,11 @@ struct trimble_unit {
 	size_t 		rpt_cnt;	/* TSIP packet length so far */
 	char 		rpt_buf[BMAX]; 	/* packet assembly buffer */
 	int		type;		/* Clock mode type */
-	int		month;		/* for LEAP filter */
+	u_int		week;		/* GPS week number */
+	u_int		TOW;		/* GPS time of week */
+	int		UTC_offset;	/* GPS-UTC offset */
+	struct calendar	date;		/* calendar to avoid leap early announce */
+	u_int		build_week;	/* GPS week number of ntpd build date */
 };
 
 /*
@@ -170,10 +175,7 @@ int 		TSIP_decode		(struct peer *);
 long		HW_poll			(struct refclockproc *);
 static	double	getdbl 			(uint8_t *);
 static	short	getint 			(uint8_t *);
-#ifdef DEBUG		
 static	int32_t	getlong			(uint8_t *);
-#endif
-
 #ifdef __UNUSED__
 static  void	sendcmd			(struct packettx *buffer, int c);
 #endif
@@ -184,12 +186,6 @@ static  int	sendetx			(struct packettx *buffer, int fd);
 static  void	init_thunderbolt	(int fd);
 static  void	init_acutime		(int fd);
 
-
-/* Table to get from month to day of the year */
-static const int days_of_year [12] = {
-	0,  31,  59,  90, 120, 151, 181, 212, 243, 273, 304, 334
-};
-
 #ifdef DEBUG
 const char * Tracking_Status[15][15] = { 
 	{ "Doing Fixes\0" }, { "Good 1SV\0" }, { "Approx. 1SV\0" },
@@ -212,8 +208,6 @@ struct refclock refclock_trimble = {
 	NULL			/* timer - not used */
 };
 
-static int day_of_year (char *dt) __attribute__((pure));
-
 /* Extract the clock type from the mode setting */
 #define CLK_TYPE(x) ((int)(((x)->ttl) & 0x7F))
 
@@ -377,6 +371,7 @@ trimble_start (
 	int fd;
 	char gpsdev[20];
 	struct termios tio;
+	struct calendar build_date;
 
 	snprintf(gpsdev, sizeof(gpsdev), DEVICE, unit);
 
@@ -480,6 +475,21 @@ trimble_start (
 	up->rpt_status = TSIP_PARSED_EMPTY;
 	up->rpt_cnt = 0;
 
+	if (ntpcal_get_build_date(&build_date)) {
+		caltogps(&build_date, 0, &up->build_week, NULL);
+		up->build_week -= 2; /* timezone, UTC offset, build machine clock */
+	} else {
+		up->build_week = 0;
+	}
+	if (up->build_week < MIN_BUILD_GPSWEEK || up->build_week > MAX_BUILD_GPSWEEK) {
+		msyslog(LOG_ERR, "Trimble(%d) ntpcal_get_build_date() failed: %u",
+		        unit, up->build_week);
+		close(fd);
+		pp->io.fd = -1;
+		free(up);
+		return false;
+	}
+
 	if (up->type == CLK_THUNDERBOLT)
 		init_thunderbolt(fd);
 	if (up->type == CLK_ACUTIME)
@@ -512,34 +522,6 @@ trimble_shutdown (
 }
 
 
-
-/* 
- * unpack_date - get day and year from date
- */
-static int
-day_of_year (
-	char * dt
-	)
-{
-	int day, mon, year;
-
-	mon = dt[1];
-	/* Check month is inside array bounds */
-	if ((mon < 1) || (mon > 12)) 
-		return -1;
-
-	day = dt[0] + days_of_year[mon - 1];
-	year = getint((uint8_t *) (dt + 2)); 
-
-	if ( !(year % 4) && ((year % 100) || 
-			     (!(year % 100) && !(year%400)))
-	     &&(mon > 2))
-		day ++; /* leap year and March or later */
-
-	return day;
-}
-
-
 /* 
  * TSIP_decode - decode the TSIP data packets 
  */
@@ -589,8 +571,6 @@ TSIP_decode (
 		/* 
 		 * Superpackets
 		 */
-		int GPS_UTC_Offset;
-
 		event = (unsigned short) (getint((uint8_t *) &mb(1)) & 0xffff);
 		if (!((pp->sloppyclockflag & CLK_FLAG2) || event)) 
 			/* Ignore Packet */
@@ -599,12 +579,12 @@ TSIP_decode (
 		switch (mb(0) & 0xff) {
 
 		    case PACKET_8F0B: 
+			if (up->rpt_cnt != LENCODE_8F0B)  /* check length */
+				break;
 
+			up->UTC_offset = getint((uint8_t *) &mb(16));
 			if (up->polled <= 0)
 				return 0;
-
-			if (up->rpt_cnt != LENCODE_8F0B)  /* check length */
-				break;
 		
 #ifdef DEBUG
 			if (debug > 1) {
@@ -627,8 +607,7 @@ TSIP_decode (
 			}
 #endif
 
-			GPS_UTC_Offset = getint((uint8_t *) &mb(16));  
-			if (GPS_UTC_Offset == 0) { /* Check UTC offset */ 
+			if (up->UTC_offset == 0) { /* Check UTC offset */ 
 #ifdef DEBUG
 				printf("TSIP_decode: UTC Offset Unknown\n");
 #endif
@@ -642,21 +621,24 @@ TSIP_decode (
 			pp->nsec = (long) (secfrac * NS_PER_S);
 
 			secint %= SECSPERDAY;    /* Only care about today */
-			pp->hour = (int)(secint / SECSPERHR);
+			up->date.hour = (int)(secint / SECSPERHR);
 			secint %= SECSPERHR;
-			pp->minute = (int)(secint / 60);
+			up->date.minute = (int)(secint / 60);
 			secint %= 60;
-			pp->second = secint % 60;
-		
-			if ((pp->day = day_of_year(&mb(11))) < 0) break;
-
-			pp->year = getint((uint8_t *) &mb(13)); 
-
+			up->date.second = secint % 60;
+			up->date.monthday = (uint8_t)mb(11);
+			up->date.month = (uint8_t)mb(12);
+			up->date.year = (uint16_t)getint((uint8_t *) &mb(13));
+			up->date.yearday = 0;
+			caltogps(&up->date, up->UTC_offset, &up->week, &up->TOW);
+			gpsweekadj(&up->week, up->build_week);
+			gpstocal(up->week, up->TOW, up->UTC_offset, &up->date);
 #ifdef DEBUG
 			if (debug > 1)
 				printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d UTC %02d\n",
-				       up->unit, (u_int)(mb(0) & 0xff), event, pp->hour, pp->minute, 
-				       pp->second, pp->nsec, mb(12), mb(11), pp->year, GPS_UTC_Offset);
+				       up->unit, (u_int)(mb(0) & 0xff), event,
+				       up->date.hour, up->date.minute, up->date.second, pp->nsec,
+				       up->date.month, up->date.monthday, up->date.year, up->UTC_offset);
 #endif
 			/* Only use this packet when no
 			 * 8F-AD's are being received
@@ -681,6 +663,16 @@ TSIP_decode (
 			if (up->polled  <= 0) 
 				return 0;
 				
+			/* Praecis reports only 8f-ad with UTC offset applied */
+			if (up->type == CLK_PRAECIS) {
+				up->UTC_offset = 0;
+			} else if (up->UTC_offset == 0) {
+#ifdef DEBUG
+				printf("TSIP_decode 8f-ad: need UTC offset from 8f-0b\n");
+#endif
+				return 0;
+			}
+
 			/* Check Tracking Status */
 			st = mb(18);
 			if (st < 0 || st > 14)
@@ -696,10 +688,9 @@ TSIP_decode (
 				break;
 			}
 
-			up->month = mb(15);
 			if ( (up->leap_status & TRIMBLE_LEAP_PENDING) &&
 			/* Avoid early announce: https://bugs.ntp.org/2773 */
-				(6 == up->month || 12 == up->month) ) {
+				(6 == up->date.month || 12 == up->date.month) ) {
 				if (up->leap_status & TRIMBLE_UTC_TIME)  
 					pp->leap = LEAP_ADDSECOND;
 				else
@@ -721,22 +712,23 @@ TSIP_decode (
 				return 0;
 			}
 
-			pp->nsec = (long) (getdbl((uint8_t *) &mb(3))
-					   * 1000000000);
-
-			if ((pp->day = day_of_year(&mb(14))) < 0) 
-				break;
-			pp->year = getint((uint8_t *) &mb(16)); 
-			pp->hour = mb(11);
-			pp->minute = mb(12);
-			pp->second = mb(13);
-			up->month = mb(14);  /* Save for LEAP check */
-
+			pp->nsec = (long) (getdbl((uint8_t *) &mb(3)) * NS_PER_S);
+			up->date.year = (uint16_t)getint((uint8_t *) &mb(16)); 
+			up->date.hour = (uint8_t)mb(11);
+			up->date.minute = (uint8_t)mb(12);
+			up->date.second = (uint8_t)mb(13);
+			up->date.month = (uint8_t)mb(15);
+			up->date.monthday = (uint8_t)mb(14);
+			caltogps(&up->date, up->UTC_offset, &up->week, &up->TOW);
+			gpsweekadj(&up->week, up->build_week);
+			gpstocal(up->week, up->TOW, up->UTC_offset, &up->date);
+			up->UTC_offset = 0; /* don't re-use offset */
 #ifdef DEBUG
 			if (debug > 1)
 				printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d UTC %02x %s\n",
-				       up->unit, (u_int)(mb(0) & 0xff), event, pp->hour, pp->minute, 
-				       pp->second, pp->nsec, mb(15), mb(14), pp->year,
+				       up->unit, (u_int)(mb(0) & 0xff), event,
+				       up->date.hour, up->date.minute, up->date.second, pp->nsec,
+				       up->date.month, up->date.monthday, up->date.year,
 				       (u_int)mb(19), *Tracking_Status[st]);
 #endif
 			return 1;
@@ -763,7 +755,7 @@ TSIP_decode (
 #endif
 			if ( (getint((uint8_t *) &mb(10)) & 0x80) &&
 			/* Avoid early announce: https://bugs.ntp.org/2773 */
-			    (6 == up->month || 12 == up->month) )
+			    (6 == up->date.month || 12 == up->date.month) )
 				pp->leap = LEAP_ADDSECOND;  /* we ASSUME addsecond */
 			else 
 				pp->leap = LEAP_NOWARNING;
@@ -816,9 +808,8 @@ TSIP_decode (
 			if (up->polled  <= 0)
 				return 0;
 
-			GPS_UTC_Offset = getint((uint8_t *) &mb(7));
-
-			if (GPS_UTC_Offset == 0){ /* Check UTC Offset */
+			up->UTC_offset = getint((uint8_t *) &mb(7));
+			if (up->UTC_offset == 0){ /* Check UTC Offset */
 #ifdef DEBUG
 				printf("TSIP_decode: UTC Offset Unknown\n");
 #endif
@@ -862,28 +853,18 @@ TSIP_decode (
 				printf ("	Time is from GPS\n\n");	
 #endif		
 
-			if ((pp->day = day_of_year(&mb(13))) < 0)
-				break;
+			up->TOW = (uint32_t)getlong((uint8_t *) &mb(1));
+			up->week = (uint32_t)getint((uint8_t *) &mb(5));
+			gpsweekadj(&up->week, up->build_week);
+			gpstocal(up->week, up->TOW, up->UTC_offset, &up->date);
 #ifdef DEBUG		
 			if (debug > 1) {
-				long tow = getlong((uint8_t *) &mb(1));
-				printf("pp->day: %d\n", pp->day); 
-				printf("TOW: %ld\n", tow);
-				printf("DAY: %d\n", mb(13));
+				printf("TSIP_decode: unit %d: %02X #%d TOW: %u  week: %u  adj.t: %02d:%02d:%02d.0 %02d/%02d/%04d\n",
+				        up->unit, (u_int)(mb(0) & 0xff), event, up->TOW, up->week, 
+					up->date.hour, up->date.minute, up->date.second,
+					up->date.month, up->date.monthday, up->date.year);
 			}
 #endif
-			pp->year = getint((uint8_t *) &mb(15));
-			pp->hour = mb(12);
-			pp->minute = mb(11);
-			pp->second = mb(10);
-
-
-#ifdef DEBUG
-			if (debug > 1)
-				printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d ",
-				        up->unit, (u_int)(mb(0) & 0xff), event,
-				        pp->hour, pp->minute, pp->second, pp->nsec, mb(14), mb(13), pp->year);
-#endif
 			return 1;
 			break;
 
@@ -1029,6 +1010,11 @@ trimble_receive (
 
 	up->polled = 0;  /* Poll reply received */
 	pp->lencode = 0; /* clear time code */
+	
+	pp->day = up->date.yearday;
+	pp->hour = up->date.hour;
+	pp->minute = up->date.minute;
+	pp->second = up->date.second;
 #ifdef DEBUG
 	if (debug) 
 		printf(
@@ -1066,6 +1052,10 @@ trimble_receive (
 		printf("trimble_receive: unit %d: %s\n",
 		       up->unit, prettydate(pp->lastrec));
 #endif
+	if (pp->hour == 0 && up->week > up->build_week + 1000)
+		msyslog(LOG_WARNING, "Trimble(%d) current GPS week number (%u) is more than 1000 weeks past ntpd's build date (%u), please update",
+		        up->unit, up->week, up->build_week);
+
 	pp->lastref = pp->lastrec;
 	refclock_receive(peer);
 }
@@ -1357,7 +1347,7 @@ getint (
 	return (short)ntohs(us);
 }
 
-#ifdef DEBUG		
+
 /*
  * copy/swap a big-endian palisade 32-bit int into a host 32-bit int
  */
@@ -1370,6 +1360,4 @@ getlong(
 
 	memcpy(&u32, bp, sizeof(u32));
 	return (int32_t)(uint32_t)ntohl(u32);
-}
-#endif
-
+}
\ No newline at end of file


=====================================
tests/common/tests_main.c
=====================================
--- a/tests/common/tests_main.c
+++ b/tests/common/tests_main.c
@@ -43,6 +43,7 @@ static void RunAllTests(void)
 	RUN_TEST_GROUP(calendar);
 	RUN_TEST_GROUP(clocktime);
 	RUN_TEST_GROUP(decodenetnum);
+	RUN_TEST_GROUP(gpstolfp);
 	RUN_TEST_GROUP(hextolfp);
 	RUN_TEST_GROUP(humandate);
 	RUN_TEST_GROUP(lfpfunc);


=====================================
tests/libntp/gpstolfp.c
=====================================
--- /dev/null
+++ b/tests/libntp/gpstolfp.c
@@ -0,0 +1,53 @@
+#include "gpstolfp.h"
+#include "ntp_types.h"
+
+#include "unity.h"
+#include "unity_fixture.h"
+
+#include "config.h"
+#include "ntp_stdlib.h"
+
+TEST_GROUP(gpstolfp);
+
+TEST_SETUP(gpstolfp){};
+TEST_TEAR_DOWN(gpstolfp){};
+
+TEST(gpstolfp, check) {
+	uint64_t build_t, gps_t;
+	struct calendar in, out;
+	u_int build_week, week, TOW;
+
+	u_int bw[] = {MIN_BUILD_GPSWEEK, 2048, MAX_BUILD_GPSWEEK};
+	uint16_t by[] = {2016, 2019, 2096};
+	uint8_t bm[] = {6, 4,  7};
+	uint8_t bd[] = {5, 7, 1};
+
+	for (int i = 0; i < 3; i++) {
+		ZERO(in);
+		in.year=by[i];
+		in.month=bm[i];
+		in.monthday = bd[i];
+		caltogps(&in, 0, &week, &TOW);
+		TEST_ASSERT_TRUE(week == bw[i] && TOW == 0);
+	}
+	
+	for (uint32_t b = MIN_BUILD_GPSWEEK; b <= MAX_BUILD_GPSWEEK; b++) {
+		build_week = b;
+		week = b;
+		gpstocal(week, 0, 0, &out);
+		build_t = ntpcal_dayjoin(ntpcal_date_to_rd(&out) - DAY_NTP_STARTS,
+		       ntpcal_date_to_daysec(&out));
+		for (week = 0; week < GPSWEEKS; week++) {
+			gpsweekadj(&week, build_week);
+			ZERO(out);
+			gpstocal(week, 0, 0, &out);
+			gps_t = ntpcal_dayjoin(ntpcal_date_to_rd(&out) - DAY_NTP_STARTS,
+			       ntpcal_date_to_daysec(&out));
+			TEST_ASSERT_FALSE(build_t > gps_t);
+		}
+	}
+}
+
+TEST_GROUP_RUNNER(gpstolfp) {
+	RUN_TEST_CASE(gpstolfp, check);
+}
\ No newline at end of file


=====================================
tests/wscript
=====================================
--- a/tests/wscript
+++ b/tests/wscript
@@ -30,6 +30,7 @@ def build(ctx):
         "libntp/calendar.c",
         "libntp/clocktime.c",
         "libntp/decodenetnum.c",
+        "libntp/gpstolfp.c",
         "libntp/hextolfp.c",
         "libntp/humandate.c",
         "libntp/lfpfunc.c",



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/7da8b11fc07b8470fe9ab93895aab9bb56544c4b...d74cf1e39c0b48c4a5f0c26f4cb07e7bef15937e

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/7da8b11fc07b8470fe9ab93895aab9bb56544c4b...d74cf1e39c0b48c4a5f0c26f4cb07e7bef15937e
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170526/79ef2e0b/attachment.html>


More information about the vc mailing list