]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Update sntp test to use synch distance instead of root dispersion
authorHarlan Stenn <stenn@ntp.org>
Sat, 27 Aug 2011 07:18:26 +0000 (03:18 -0400)
committerHarlan Stenn <stenn@ntp.org>
Sat, 27 Aug 2011 07:18:26 +0000 (03:18 -0400)
bk: 4e589a42Nxxnrn9b5XhKiMlmjS_d-A

ChangeLog
sntp/tests/packetHandling.cpp

index d185fae4ad6e7985e4f20688b3d5e008cccba2cc..eb26da86c954e7b9aefc20bf9b4ad1cd40ecc012 100644 (file)
--- 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 <stenn@ntp.org>
 * Fix the CLOCK_MONOTONIC TRACE() message.
 (4.2.7p207) 2011/08/22 Released by Harlan Stenn <stenn@ntp.org>
index b9183c6cbc27729b103d9026d121d8b08e6e9f86..87d9eee1e3378d4870c433c8888f6ea1d433c50d 100644 (file)
@@ -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) {