#include "test.h"
static SRC_Instance
-create_source(SRC_Type type, int authenticated, int sel_options)
+create_source(SRC_Type type, IPAddr *addr, int authenticated, int sel_options)
{
- static IPAddr addr;
+ TST_GetRandomAddress(addr, IPADDR_UNSPEC, -1);
- TST_GetRandomAddress(&addr, IPADDR_UNSPEC, -1);
-
- return SRC_CreateNewInstance(UTI_IPToRefid(&addr), type, authenticated, sel_options,
- type == SRC_NTP ? &addr : NULL,
+ return SRC_CreateNewInstance(UTI_IPToRefid(addr), type, authenticated, sel_options,
+ type == SRC_NTP ? addr : NULL,
SRC_DEFAULT_MINSAMPLES, SRC_DEFAULT_MAXSAMPLES, 0.0, 1.0);
}
{
SRC_AuthSelectMode sel_mode;
SRC_Instance srcs[16];
+ IPAddr addrs[16];
RPT_SourceReport report;
NTP_Sample sample;
int i, j, k, l, n1, n2, n3, n4, samples, sel_options;
SRC_SELECT_TRUST | SRC_SELECT_REQUIRE);
DEBUG_LOG("added source %d options %d", j, sel_options);
- srcs[j] = create_source(SRC_NTP, 0, sel_options);
+ srcs[j] = create_source(SRC_NTP, &addrs[j], 0, sel_options);
SRC_UpdateReachability(srcs[j], 1);
samples = (i + j) % 5 + 3;
}
}
- DEBUG_LOG("sources %d passed %d trusted %d/%d required %d/%d", j, passed,
+ DEBUG_LOG("sources %d passed %d trusted %d/%d required %d/%d", j + 1, passed,
trusted_passed, trusted, required_passed, required);
TEST_CHECK(!trusted || !passed || (passed_lo >= trusted_lo && passed_hi <= trusted_hi));
assert(n1 + n2 + n3 < sizeof (srcs) / sizeof (srcs[0]));
for (j = 0; j < n1; j++)
- srcs[j] = create_source(SRC_REFCLOCK, random() % 2, sel_options);
+ srcs[j] = create_source(SRC_REFCLOCK, &addrs[j], random() % 2, sel_options);
for (; j < n1 + n2; j++)
- srcs[j] = create_source(SRC_NTP, 1, sel_options);
+ srcs[j] = create_source(SRC_NTP, &addrs[j], 1, sel_options);
for (; j < n1 + n2 + n3; j++)
- srcs[j] = create_source(SRC_NTP, 0, sel_options);
+ srcs[j] = create_source(SRC_NTP, &addrs[j], 0, sel_options);
for (; j < n1 + n2 + n3 + n4; j++)
- srcs[j] = create_source(random() % 2 ? SRC_REFCLOCK : SRC_NTP,
+ srcs[j] = create_source(random() % 2 ? SRC_REFCLOCK : SRC_NTP, &addrs[j],
random() % 2, sel_options | SRC_SELECT_NOSELECT);
switch (sel_mode) {
for (j = n1 + n2 + n3; j < n1 + n2 + n3 + n4; j++)
TEST_CHECK(srcs[j]->sel_options == (sel_options | SRC_SELECT_NOSELECT));
- for (j = n1 + n2 + n3 - 1; j >= 0; j--) {
+ for (j = n1 + n2 + n3 + n4 - 1; j >= 0; j--) {
if (j < n1 + n2)
TEST_CHECK(srcs[j]->sel_options == sel_options);
SRC_DestroyInstance(srcs[j]);