[Git][NTPsec/ntpsec][master] Setup to help testing leap seconds

Hal Murray gitlab at mg.gitlab.com
Sat Mar 18 06:44:05 UTC 2017


Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
9e4d6438 by Hal Murray at 2017-03-17T23:39:36-07:00
Setup to help testing leap seconds

contrib/make-leap-seconds.py makes valid leap second files
default is to leap at midnight.

--enable-leap-testing to waf configure
allows leaps at other than 1st day of a month

- - - - -


3 changed files:

- ntpd/ntp_leapsec.c
- wafhelpers/configure.py
- wafhelpers/options.py


Changes:

=====================================
ntpd/ntp_leapsec.c
=====================================
--- a/ntpd/ntp_leapsec.c
+++ b/ntpd/ntp_leapsec.c
@@ -783,13 +783,14 @@ leapsec_add(
 	/* To guard against dangling leap flags: do not accept leap
 	 * second request on the 1st hour of the 1st day of the month.
 	 */
+#ifndef ENABLE_LEAP_TESTING
 	if (fts.tm_mday == 1 && fts.tm_hour == 0) {
 		errno = EINVAL;
 		return false;
 	}
+#endif
 
 	/* Ok, do the remaining calculations */
-	fts.tm_mday = 1;
 	fts.tm_hour = 0;
 	fts.tm_min  = 0;
 	fts.tm_sec  = 0;
@@ -831,11 +832,13 @@ leapsec_raw(
 	}
 
 	gmtime_r(&ttime, &fts);
+#ifndef ENABLE_LEAP_TESTING
 	/* If this does not match the exact month start, bail out. */
 	if (fts.tm_mday != 1 || fts.tm_hour || fts.tm_min || fts.tm_sec) {
 		errno = EINVAL;
 		return false;
 	}
+#endif
 	/* Start 28 days earler.  Avoids month arithmetic.  */
 	starttime = ttime - 28*SECSPERDAY;
 	li.ttime = ttime;


=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -222,6 +222,13 @@ def cmd_configure(ctx, config):
     if ctx.check_endianness() == "big":
         ctx.define("WORDS_BIGENDIAN", 1)
 
+    if ctx.options.enable_leap_testing:
+        ctx.define("ENABLE_LEAP_TESTING", 1,
+                   comment="Enable leap seconds on other than 1st of month.")
+    if ctx.options.enable_leap_smear:
+        ctx.define("ENABLE_LEAP_SMEAR", 1,
+                   comment="Enable experimental leap smearing code")
+
     cc_test_flags = [
         ('PIC', '-fPIC'),
         ('PIE', '-pie -fPIE'),


=====================================
wafhelpers/options.py
=====================================
--- a/wafhelpers/options.py
+++ b/wafhelpers/options.py
@@ -48,6 +48,8 @@ def options_cmd(ctx, config):
     grp = ctx.add_option_group("NTP configure features")
     grp.add_option('--enable-leap-smear', action='store_true',
                    default=False, help="Enable Leap Smearing.")
+    grp.add_option('--enable-leap-testing', action='store_true',
+                   default=False, help="Enable leaps on other than 1st of month.")
     grp.add_option('--enable-mssntp', action='store_true',
                    default=False, help="Enable Samba MS SNTP support.")
     grp.add_option('--enable-lockclock', action='store_true',



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/9e4d64381e49caf10d08a11df2d0ee20e45761c5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170318/cbc1c13f/attachment.html>


More information about the vc mailing list