From c62812877398840dae0ba74b03e9e6a43cc56fc5 Mon Sep 17 00:00:00 2001 From: glebius Date: Mon, 26 Oct 2015 11:35:40 +0000 Subject: Upgrade NTP to 4.2.8p4. Security: FreeBSD-SA-15:25.ntp Security: CVE-2015-7871 Security: CVE-2015-7855 Security: CVE-2015-7854 Security: CVE-2015-7853 Security: CVE-2015-7852 Security: CVE-2015-7851 Security: CVE-2015-7850 Security: CVE-2015-7849 Security: CVE-2015-7848 Security: CVE-2015-7701 Security: CVE-2015-7703 Security: CVE-2015-7704, CVE-2015-7705 Security: CVE-2015-7691, CVE-2015-7692, CVE-2015-7702 --- contrib/ntp/tests/libntp/g_caljulian.cpp | 94 -------------------------------- 1 file changed, 94 deletions(-) delete mode 100644 contrib/ntp/tests/libntp/g_caljulian.cpp (limited to 'contrib/ntp/tests/libntp/g_caljulian.cpp') diff --git a/contrib/ntp/tests/libntp/g_caljulian.cpp b/contrib/ntp/tests/libntp/g_caljulian.cpp deleted file mode 100644 index 7ed38c4..0000000 --- a/contrib/ntp/tests/libntp/g_caljulian.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "g_libntptest.h" - -extern "C" { -#include "ntp_calendar.h" -} - -#include -#include - -class caljulianTest : public libntptest { -protected: - virtual void SetUp(); - virtual void TearDown(); - - std::string CalendarToString(const calendar &cal) { - std::ostringstream ss; - ss << cal.year << "-" << (u_int)cal.month << "-" << (u_int)cal.monthday - << " (" << cal.yearday << ") " << (u_int)cal.hour << ":" - << (u_int)cal.minute << ":" << (u_int)cal.second; - return ss.str(); - } - - ::testing::AssertionResult IsEqual(const calendar &expected, const calendar &actual) { - if (expected.year == actual.year && - (expected.yearday == actual.yearday || - (expected.month == actual.month && - expected.monthday == actual.monthday)) && - expected.hour == actual.hour && - expected.minute == actual.minute && - expected.second == actual.second) { - return ::testing::AssertionSuccess(); - } else { - return ::testing::AssertionFailure() - << "expected: " << CalendarToString(expected) << " but was " - << CalendarToString(actual); - } - } -}; - -void caljulianTest::SetUp() -{ - ntpcal_set_timefunc(timefunc); - settime(1970, 1, 1, 0, 0, 0); -} - -void caljulianTest::TearDown() -{ - ntpcal_set_timefunc(NULL); -} - - -TEST_F(caljulianTest, RegularTime) { - u_long testDate = 3485080800UL; // 2010-06-09 14:00:00 - calendar expected = {2010,160,6,9,14,0,0}; - - calendar actual; - - caljulian(testDate, &actual); - - EXPECT_TRUE(IsEqual(expected, actual)); -} - -TEST_F(caljulianTest, LeapYear) { - u_long input = 3549902400UL; // 2012-06-28 20:00:00Z - calendar expected = {2012, 179, 6, 28, 20, 0, 0}; - - calendar actual; - - caljulian(input, &actual); - - EXPECT_TRUE(IsEqual(expected, actual)); -} - -TEST_F(caljulianTest, uLongBoundary) { - u_long time = 4294967295UL; // 2036-02-07 6:28:15 - calendar expected = {2036,0,2,7,6,28,15}; - - calendar actual; - - caljulian(time, &actual); - - EXPECT_TRUE(IsEqual(expected, actual)); -} - -TEST_F(caljulianTest, uLongWrapped) { - u_long time = 0; - calendar expected = {2036,0,2,7,6,28,16}; - - calendar actual; - - caljulian(time, &actual); - - EXPECT_TRUE(IsEqual(expected, actual)); -} -- cgit v1.1