[Git][NTPsec/ntpsec][master] Remove libntp/calyearstart.c - not used

Hal Murray gitlab at mg.gitlab.com
Sun Sep 25 03:22:57 UTC 2016


Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
30bb3542 by Hal Murray at 2016-09-24T20:22:16-07:00
Remove libntp/calyearstart.c - not used

- - - - -


6 changed files:

- − libntp/calyearstart.c
- libntp/wscript
- tests/common/tests_main.c
- tests/libntp/calendar.c
- − tests/libntp/calyearstart.c
- tests/wscript


Changes:

=====================================
libntp/calyearstart.c deleted
=====================================
--- a/libntp/calyearstart.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * calyearstart - determine the NTP time at midnight of January 1 in
- *		  the year of the given date.
- */
-#include <config.h>
-#include <sys/types.h>
-
-#include "ntp_types.h"
-#include "ntp_calendar.h"
-#include "ntp_stdlib.h"
-#include "ntp_assert.h"
-
-/*
- * Juergen Perlinger, 2010-05-02
- *
- * Redone in terms of the calendar functions. It's rather simple:
- * - expand the NTP time stamp
- * - split into days and seconds since midnight, dropping the partial day
- * - get full number of days before year start in NTP epoch
- * - convert to seconds, truncated to 32 bits.
- */
-uint32_t
-calyearstart(uint32_t ntptime, const time_t *pivot)
-{
-	uint32_t      ndays; /* elapsed days since NTP starts */
-	vint64       vlong;
-	ntpcal_split split;
-
-	vlong = ntpcal_ntp_to_ntp(ntptime, pivot);
-	split = ntpcal_daysplit(&vlong);
-	ndays = ntpcal_rd_to_ystart(split.hi + DAY_NTP_STARTS)
-	      - DAY_NTP_STARTS;
-
-	return (uint32_t)(ndays * SECSPERDAY);
-}
-
-/*
- * calmonthstart - get NTP time at midnight of the first day of the
- * current month.
- */
-uint32_t
-calmonthstart(uint32_t ntptime, const time_t *pivot)
-{
-	uint32_t      ndays; /* elapsed days since NTP starts */
-	vint64       vlong;
-	ntpcal_split split;
-
-	vlong = ntpcal_ntp_to_ntp(ntptime, pivot);
-	split = ntpcal_daysplit(&vlong);
-	ndays = ntpcal_rd_to_mstart(split.hi + DAY_NTP_STARTS)
-	      - DAY_NTP_STARTS;
-
-	return (uint32_t)(ndays * SECSPERDAY);
-}
-
-/*
- * calweekstart - get NTP time at midnight of the last monday on or
- * before the current date.
- */
-uint32_t
-calweekstart(uint32_t ntptime, const time_t *pivot)
-{
-	uint32_t      ndays; /* elapsed days since NTP starts */
-	vint64       vlong;
-	ntpcal_split split;
-
-	vlong = ntpcal_ntp_to_ntp(ntptime, pivot);
-	split = ntpcal_daysplit(&vlong);
-	ndays = ntpcal_weekday_le(split.hi + DAY_NTP_STARTS, CAL_MONDAY)
-	      - DAY_NTP_STARTS;
-
-	return (uint32_t)(ndays * SECSPERDAY);
-}
-
-/*
- * caldaystart - get NTP time at midnight of the current day.
- */
-uint32_t
-caldaystart(uint32_t ntptime, const time_t *pivot)
-{
-	vint64       vlong;
-	ntpcal_split split;
-
-	vlong = ntpcal_ntp_to_ntp(ntptime, pivot);
-	split = ntpcal_daysplit(&vlong);
-	
-	return ntptime - split.lo;
-}


=====================================
libntp/wscript
=====================================
--- a/libntp/wscript
+++ b/libntp/wscript
@@ -7,7 +7,7 @@ def build(ctx):
 		"authkeys.c",
 		"authreadkeys.c",
 		"authusekey.c",
-		"calyearstart.c",
+#		"calyearstart.c",
 		"clocktime.c",
 		"decodenetnum.c",
 		"dofptoa.c",


=====================================
tests/common/tests_main.c
=====================================
--- a/tests/common/tests_main.c
+++ b/tests/common/tests_main.c
@@ -42,7 +42,6 @@ static void RunAllTests(void)
 	RUN_TEST_GROUP(a_md5encrypt);
 	RUN_TEST_GROUP(authkeys);
 	RUN_TEST_GROUP(calendar);
-	RUN_TEST_GROUP(calyearstart);
 	RUN_TEST_GROUP(clocktime);
 	RUN_TEST_GROUP(decodenetnum);
 	RUN_TEST_GROUP(hextolfp);


=====================================
tests/libntp/calendar.c
=====================================
--- a/tests/libntp/calendar.c
+++ b/tests/libntp/calendar.c
@@ -250,68 +250,6 @@ TEST(calendar, RoundTripDate) {
 	}
 }
 
-// Roundtrip testing on calyearstart
-TEST(calendar, RoundTripYearStart) {
-	static const time_t pivot = 0;
-	u_int32_t ntp, expys, truys;
-	struct calendar date;
-
-	for (ntp = 0; ntp < 0xFFFFFFFFu - 30000000u; ntp += 30000000u) {
-		truys = calyearstart(ntp, &pivot);
-		ntpcal_ntp_to_date(&date, ntp, &pivot);
-		date.month = date.monthday = 1;
-		date.hour = date.minute = date.second = 0;
-		expys = ntpcal_date_to_ntp(&date);
-		TEST_ASSERT_EQUAL(expys, truys);
-	}
-}
-
-// Roundtrip testing on calymonthstart
-TEST(calendar, RoundTripMonthStart) {
-	static const time_t pivot = 0;
-	u_int32_t ntp, expms, trums;
-	struct calendar date;
-
-	for (ntp = 0; ntp < 0xFFFFFFFFu - 2000000u; ntp += 2000000u) {
-		trums = calmonthstart(ntp, &pivot);
-		ntpcal_ntp_to_date(&date, ntp, &pivot);
-		date.monthday = 1;
-		date.hour = date.minute = date.second = 0;
-		expms = ntpcal_date_to_ntp(&date);
-		TEST_ASSERT_EQUAL(expms, trums);
-	}
-}
-
-// Roundtrip testing on calweekstart
-TEST(calendar, RoundTripWeekStart) {
-	static const time_t pivot = 0;
-	u_int32_t ntp, expws, truws;
-	struct isodate date;
-
-	for (ntp = 0; ntp < 0xFFFFFFFFu - 600000u; ntp += 600000u) {
-		truws = calweekstart(ntp, &pivot);
-		isocal_ntp_to_date(&date, ntp, &pivot);
-		date.hour = date.minute = date.second = 0;
-		date.weekday = 1;
-		expws = isocal_date_to_ntp(&date);
-		TEST_ASSERT_EQUAL(expws, truws);
-	}
-}
-
-// Roundtrip testing on caldaystart
-TEST(calendar, RoundTripDayStart) {
-	static const time_t pivot = 0;
-	u_int32_t ntp, expds, truds;
-	struct calendar date;
-
-	for (ntp = 0; ntp < 0xFFFFFFFFu - 80000u; ntp += 80000u) {
-		truds = caldaystart(ntp, &pivot);
-		ntpcal_ntp_to_date(&date, ntp, &pivot);
-		date.hour = date.minute = date.second = 0;
-		expds = ntpcal_date_to_ntp(&date);
-		TEST_ASSERT_EQUAL(expds, truds);
-	}
-}
 
 TEST_GROUP_RUNNER(calendar) {
 	RUN_TEST_CASE(calendar, DaySplitMerge);
@@ -321,8 +259,4 @@ TEST_GROUP_RUNNER(calendar) {
 	RUN_TEST_CASE(calendar, LeapYears1);
 	RUN_TEST_CASE(calendar, LeapYears2);
 	RUN_TEST_CASE(calendar, RoundTripDate);
-	RUN_TEST_CASE(calendar, RoundTripYearStart);
-	RUN_TEST_CASE(calendar, RoundTripMonthStart);
-	RUN_TEST_CASE(calendar, RoundTripWeekStart);
-	RUN_TEST_CASE(calendar, RoundTripDayStart);
 }


=====================================
tests/libntp/calyearstart.c deleted
=====================================
--- a/tests/libntp/calyearstart.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "config.h"
-
-#include "unity.h"
-#include "unity_fixture.h"
-
-#include "ntp_stdlib.h"
-#include "ntp_calendar.h"
-#include "caltime.h"
-
-static time_t nowtime;
-
-TEST_GROUP(calyearstart);
-
-TEST_SETUP(calyearstart) {
-    ntpcal_set_timefunc(timefunc);
-    settime(1970, 1, 1, 0, 0, 0);
-}
-
-TEST_TEAR_DOWN(calyearstart) {
-    ntpcal_set_timefunc(NULL);
-}
-
-
-TEST(calyearstart, NoWrapInDateRange) {
-	const u_int32_t input = 3486372600UL; // 2010-06-24 12:50:00.
-	const u_int32_t expected = 3471292800UL; // 2010-01-01 00:00:00
-
-	TEST_ASSERT_EQUAL(expected, calyearstart(input, &nowtime));
-	TEST_ASSERT_EQUAL(expected, calyearstart(input, NULL));
-}
-
-TEST(calyearstart, NoWrapInDateRangeLeapYear) {
-	const u_int32_t input = 3549528000UL; // 2012-06-24 12:00:00
-	const u_int32_t expected = 3534364800UL; // 2012-01-01 00:00:00
-
-	TEST_ASSERT_EQUAL(expected, calyearstart(input, &nowtime));
-	TEST_ASSERT_EQUAL(expected, calyearstart(input, NULL));
-}
-
-TEST(calyearstart, WrapInDateRange) {
-	const u_int32_t input = 19904UL; // 2036-02-07 12:00:00
-	const u_int32_t expected = 4291747200UL; // 2036-01-01 00:00:00
-
-	TEST_ASSERT_EQUAL(expected, calyearstart(input, &nowtime));
-	TEST_ASSERT_EQUAL(expected, calyearstart(input, NULL));
-}
-
-TEST_GROUP_RUNNER(calyearstart) {
-	RUN_TEST_CASE(calyearstart, NoWrapInDateRange);
-	RUN_TEST_CASE(calyearstart, NoWrapInDateRangeLeapYear);
-	RUN_TEST_CASE(calyearstart, WrapInDateRange);
-}


=====================================
tests/wscript
=====================================
--- a/tests/wscript
+++ b/tests/wscript
@@ -53,7 +53,7 @@ def build(ctx):
 		"libntp/a_md5encrypt.c",
 		"libntp/authkeys.c",
 		"libntp/calendar.c",
-		"libntp/calyearstart.c",
+#		"libntp/calyearstart.c",
 		"libntp/clocktime.c",
 		"libntp/decodenetnum.c",
 		"libntp/hextolfp.c",



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/30bb3542ed13c03a0ef14878f70f3c209fecc3eb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160925/1a290e47/attachment.html>


More information about the vc mailing list