From: Miroslav Lichvar Date: Mon, 5 Oct 2020 12:06:27 +0000 (+0200) Subject: test: improve sources unit test X-Git-Tag: 4.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1494ef1df34685d307b37549c1392655686dbae1;p=thirdparty%2Fchrony.git test: improve sources unit test --- diff --git a/test/unit/sources.c b/test/unit/sources.c index fdc70c01..621b79c3 100644 --- a/test/unit/sources.c +++ b/test/unit/sources.c @@ -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))); + } } }