]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: improve sources unit test
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 5 Oct 2020 12:06:27 +0000 (14:06 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 5 Oct 2020 16:56:37 +0000 (18:56 +0200)
test/unit/sources.c

index fdc70c01f5e8ddbe327884b7b725232fabd433f0..621b79c3b82d3f44d0de374005a1220dce22435a 100644 (file)
@@ -81,6 +81,9 @@ test_unit(void)
         sample.root_dispersion = sample.peer_dispersion;
         sample.stratum = 1;
 
+        if (random() % 2)
+          SRC_SetLeapStatus(srcs[j], random() % 4);
+
         DEBUG_LOG("source %d sample %d offset %f delay %f disp %f", j, k,
                   sample.offset, sample.peer_delay, sample.peer_dispersion);
 
@@ -132,6 +135,12 @@ test_unit(void)
         TEST_CHECK(!trusted || !passed || (passed_lo >= trusted_lo && passed_hi <= trusted_hi));
         TEST_CHECK(!passed || !trusted || trusted_passed >= 1);
         TEST_CHECK(!passed || !required || required_passed > 0);
+
+        for (l = 0; l <= j; l++) {
+          TEST_CHECK(sources[l]->leap_vote ==
+                     (sources[l]->status >= SRC_NONPREFERRED &&
+                      (!trusted || sources[l]->sel_options & SRC_SELECT_TRUST)));
+        }
       }
     }