From: Harlan Stenn Date: Sat, 27 Aug 2011 07:18:26 +0000 (-0400) Subject: Update sntp test to use synch distance instead of root dispersion X-Git-Tag: NTP_4_2_7P209~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df75e7f7ec6d17568b5185b24f2b41de87b24d6f;p=thirdparty%2Fntp.git Update sntp test to use synch distance instead of root dispersion bk: 4e589a42Nxxnrn9b5XhKiMlmjS_d-A --- diff --git a/ChangeLog b/ChangeLog index d185fae4a..eb26da86c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ * [Bug 2001] add ntpq -c timerstats like ntpdc -c timerstats. * [Bug 2001] from 4.2.6p4-RC3: ntpdc timerstats reports overruns as handled. +* Update sntp tests to track the change of root dispersion to + synchronization distance. (4.2.7p208) 2011/08/24 Released by Harlan Stenn * Fix the CLOCK_MONOTONIC TRACE() message. (4.2.7p207) 2011/08/22 Released by Harlan Stenn diff --git a/sntp/tests/packetHandling.cpp b/sntp/tests/packetHandling.cpp index b9183c6cb..87d9eee1e 100644 --- a/sntp/tests/packetHandling.cpp +++ b/sntp/tests/packetHandling.cpp @@ -7,6 +7,8 @@ extern "C" { #include "ntp.h" }; +#define CALC_SYNCH_DISTANCE(a, b) ((a + b)/2.0) + class mainTest : public sntptest { protected: ::testing::AssertionResult LfpEquality(const l_fp &expected, const l_fp &actual) { @@ -90,6 +92,7 @@ TEST_F(mainTest, OffsetCalculationPositiveOffset) { rpkt.precision = -16; // 0,000015259 rpkt.rootdelay = HTONS_FP(DTOUFP(0.125)); rpkt.rootdisp = HTONS_FP(DTOUFP(0.25)); // + double x_synchDist = CALC_SYNCH_DISTANCE(0.125, 0.25); l_fp reftime; get_systime(&reftime); HTONL_FP(&reftime, &rpkt.reftime); @@ -118,12 +121,12 @@ TEST_F(mainTest, OffsetCalculationPositiveOffset) { TSTOTV(&tmp, &dst); dst.tv_sec -= JAN_1970; - double offset, precision, root_disp; - offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &root_disp); + double offset, precision, synch_distance; + offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &synch_distance); EXPECT_DOUBLE_EQ(1.25, offset); EXPECT_DOUBLE_EQ(1. / ULOGTOD(16), precision); - EXPECT_DOUBLE_EQ(0.25, root_disp); + EXPECT_DOUBLE_EQ(CALC_SYNCH_DISTANCE(0.125, 0.25), synch_distance); } TEST_F(mainTest, OffsetCalculationNegativeOffset) { @@ -132,6 +135,7 @@ TEST_F(mainTest, OffsetCalculationNegativeOffset) { rpkt.precision = -1; rpkt.rootdelay = HTONS_FP(DTOUFP(0.5)); rpkt.rootdisp = HTONS_FP(DTOUFP(0.5)); + double x_synchDist = CALC_SYNCH_DISTANCE(0.5, 0.5); l_fp reftime; get_systime(&reftime); HTONL_FP(&reftime, &rpkt.reftime); @@ -160,12 +164,12 @@ TEST_F(mainTest, OffsetCalculationNegativeOffset) { TSTOTV(&tmp, &dst); dst.tv_sec -= JAN_1970; - double offset, precision, root_disp; - offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &root_disp); + double offset, precision, synch_distance; + offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &synch_distance); EXPECT_DOUBLE_EQ(-1, offset); EXPECT_DOUBLE_EQ(1. / ULOGTOD(1), precision); - EXPECT_DOUBLE_EQ(0.5, root_disp); + EXPECT_DOUBLE_EQ(CALC_SYNCH_DISTANCE(0.5, 0.5), synch_distance); } TEST_F(mainTest, HandleUnusableServer) {