test: fix DEBUG_LOG use in unit tests
This was missing in commit f282856c72
.
This commit is contained in:
parent
3a635fc51f
commit
d3a30142e5
8 changed files with 17 additions and 17 deletions
|
@ -42,7 +42,7 @@ test_unit(void)
|
||||||
TST_GetRandomAddress(&ip, IPADDR_INET6, -1);
|
TST_GetRandomAddress(&ip, IPADDR_INET6, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(0, "address %s", UTI_IPToString(&ip));
|
DEBUG_LOG("address %s", UTI_IPToString(&ip));
|
||||||
|
|
||||||
sub = random() % (maxsub + 1);
|
sub = random() % (maxsub + 1);
|
||||||
|
|
||||||
|
|
|
@ -42,14 +42,14 @@ test_unit(void)
|
||||||
TEST_CHECK(ARR_GetSize(records) == 16);
|
TEST_CHECK(ARR_GetSize(records) == 16);
|
||||||
|
|
||||||
for (i = 0; i < 500; i++) {
|
for (i = 0; i < 500; i++) {
|
||||||
DEBUG_LOG(0, "iteration %d", i);
|
DEBUG_LOG("iteration %d", i);
|
||||||
|
|
||||||
ts.tv_sec = (time_t)random() & 0x0fffffff;
|
ts.tv_sec = (time_t)random() & 0x0fffffff;
|
||||||
ts.tv_nsec = 0;
|
ts.tv_nsec = 0;
|
||||||
|
|
||||||
for (j = 0; j < 1000; j++) {
|
for (j = 0; j < 1000; j++) {
|
||||||
TST_GetRandomAddress(&ip, IPADDR_UNSPEC, i % 8 ? -1 : i / 8 % 9);
|
TST_GetRandomAddress(&ip, IPADDR_UNSPEC, i % 8 ? -1 : i / 8 % 9);
|
||||||
DEBUG_LOG(0, "address %s", UTI_IPToString(&ip));
|
DEBUG_LOG("address %s", UTI_IPToString(&ip));
|
||||||
|
|
||||||
if (random() % 2) {
|
if (random() % 2) {
|
||||||
index = CLG_LogNTPAccess(&ip, &ts);
|
index = CLG_LogNTPAccess(&ip, &ts);
|
||||||
|
@ -65,7 +65,7 @@ test_unit(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(0, "records %d", ARR_GetSize(records));
|
DEBUG_LOG("records %d", ARR_GetSize(records));
|
||||||
TEST_CHECK(ARR_GetSize(records) == 64);
|
TEST_CHECK(ARR_GetSize(records) == 64);
|
||||||
|
|
||||||
for (i = j = 0; i < 10000; i++) {
|
for (i = j = 0; i < 10000; i++) {
|
||||||
|
@ -76,7 +76,7 @@ test_unit(void)
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(0, "requests %u responses %u", i, j);
|
DEBUG_LOG("requests %u responses %u", i, j);
|
||||||
TEST_CHECK(j * 4 < i && j * 6 > i);
|
TEST_CHECK(j * 4 < i && j * 6 > i);
|
||||||
|
|
||||||
CLG_Finalise();
|
CLG_Finalise();
|
||||||
|
|
|
@ -39,7 +39,7 @@ test_unit(void)
|
||||||
UTI_AddDoubleToTimespec(&start_hw_ts, TST_GetRandomDouble(0.0, 1e9), &start_hw_ts);
|
UTI_AddDoubleToTimespec(&start_hw_ts, TST_GetRandomDouble(0.0, 1e9), &start_hw_ts);
|
||||||
UTI_AddDoubleToTimespec(&start_local_ts, TST_GetRandomDouble(0.0, 1e9), &start_local_ts);
|
UTI_AddDoubleToTimespec(&start_local_ts, TST_GetRandomDouble(0.0, 1e9), &start_local_ts);
|
||||||
|
|
||||||
DEBUG_LOG(0, "iteration %d", i);
|
DEBUG_LOG("iteration %d", i);
|
||||||
|
|
||||||
freq = TST_GetRandomDouble(0.9, 1.1);
|
freq = TST_GetRandomDouble(0.9, 1.1);
|
||||||
jitter = TST_GetRandomDouble(10.0e-9, 1000.0e-9);
|
jitter = TST_GetRandomDouble(10.0e-9, 1000.0e-9);
|
||||||
|
|
|
@ -98,7 +98,7 @@ test_unit(void)
|
||||||
KEY_Initialise();
|
KEY_Initialise();
|
||||||
|
|
||||||
for (i = 0; i < 100; i++) {
|
for (i = 0; i < 100; i++) {
|
||||||
DEBUG_LOG(0, "iteration %d", i);
|
DEBUG_LOG("iteration %d", i);
|
||||||
|
|
||||||
if (i) {
|
if (i) {
|
||||||
generate_key_file(KEYFILE, keys);
|
generate_key_file(KEYFILE, keys);
|
||||||
|
|
|
@ -249,7 +249,7 @@ test_unit(void)
|
||||||
has_updated = 0;
|
has_updated = 0;
|
||||||
|
|
||||||
for (j = 0; j < 50; j++) {
|
for (j = 0; j < 50; j++) {
|
||||||
DEBUG_LOG(0, "iteration %d, %d", i, j);
|
DEBUG_LOG("iteration %d, %d", i, j);
|
||||||
|
|
||||||
interleaved = random() % 2;
|
interleaved = random() % 2;
|
||||||
authenticated = random() % 2;
|
authenticated = random() % 2;
|
||||||
|
|
|
@ -47,7 +47,7 @@ test_unit(void)
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
TEST_CHECK(ARR_GetSize(records) == 1);
|
TEST_CHECK(ARR_GetSize(records) == 1);
|
||||||
|
|
||||||
DEBUG_LOG(0, "collision mod %u", 1U << i);
|
DEBUG_LOG("collision mod %u", 1U << i);
|
||||||
|
|
||||||
for (j = 0; j < sizeof (addrs) / sizeof (addrs[0]); j++) {
|
for (j = 0; j < sizeof (addrs) / sizeof (addrs[0]); j++) {
|
||||||
do {
|
do {
|
||||||
|
@ -59,7 +59,7 @@ test_unit(void)
|
||||||
if (!j)
|
if (!j)
|
||||||
hash = UTI_IPToHash(&addrs[j].ip_addr);
|
hash = UTI_IPToHash(&addrs[j].ip_addr);
|
||||||
|
|
||||||
DEBUG_LOG(0, "adding source %s hash %"PRIu32, UTI_IPToString(&addrs[j].ip_addr),
|
DEBUG_LOG("adding source %s hash %"PRIu32, UTI_IPToString(&addrs[j].ip_addr),
|
||||||
UTI_IPToHash(&addrs[j].ip_addr) % (1U << i));
|
UTI_IPToHash(&addrs[j].ip_addr) % (1U << i));
|
||||||
|
|
||||||
NSR_AddSource(&addrs[j], random() % 2 ? NTP_SERVER : NTP_PEER, ¶ms);
|
NSR_AddSource(&addrs[j], random() % 2 ? NTP_SERVER : NTP_PEER, ¶ms);
|
||||||
|
@ -79,7 +79,7 @@ test_unit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < sizeof (addrs) / sizeof (addrs[0]); j++) {
|
for (j = 0; j < sizeof (addrs) / sizeof (addrs[0]); j++) {
|
||||||
DEBUG_LOG(0, "removing source %s", UTI_IPToString(&addrs[j].ip_addr));
|
DEBUG_LOG("removing source %s", UTI_IPToString(&addrs[j].ip_addr));
|
||||||
NSR_RemoveSource(&addrs[j]);
|
NSR_RemoveSource(&addrs[j]);
|
||||||
|
|
||||||
for (k = 0; k < sizeof (addrs) / sizeof (addrs[0]); k++) {
|
for (k = 0; k < sizeof (addrs) / sizeof (addrs[0]); k++) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ test_unit(void)
|
||||||
UTI_ZeroTimespec(&ts);
|
UTI_ZeroTimespec(&ts);
|
||||||
SMT_Reset(&ts);
|
SMT_Reset(&ts);
|
||||||
|
|
||||||
DEBUG_LOG(0, "iteration %d", i);
|
DEBUG_LOG("iteration %d", i);
|
||||||
|
|
||||||
offset = (random() % 1000000 - 500000) / 1.0e6;
|
offset = (random() % 1000000 - 500000) / 1.0e6;
|
||||||
freq = (random() % 1000000 - 500000) / 1.0e9;
|
freq = (random() % 1000000 - 500000) / 1.0e9;
|
||||||
|
|
|
@ -41,7 +41,7 @@ test_unit(void)
|
||||||
REF_SetMode(REF_ModeIgnore);
|
REF_SetMode(REF_ModeIgnore);
|
||||||
|
|
||||||
for (i = 0; i < 1000; i++) {
|
for (i = 0; i < 1000; i++) {
|
||||||
DEBUG_LOG(0, "iteration %d", i);
|
DEBUG_LOG("iteration %d", i);
|
||||||
|
|
||||||
for (j = 0; j < sizeof (srcs) / sizeof (srcs[0]); j++) {
|
for (j = 0; j < sizeof (srcs) / sizeof (srcs[0]); j++) {
|
||||||
TEST_CHECK(n_sources == j);
|
TEST_CHECK(n_sources == j);
|
||||||
|
@ -51,7 +51,7 @@ test_unit(void)
|
||||||
sel_options = i & random() & (SRC_SELECT_NOSELECT | SRC_SELECT_PREFER |
|
sel_options = i & random() & (SRC_SELECT_NOSELECT | SRC_SELECT_PREFER |
|
||||||
SRC_SELECT_TRUST | SRC_SELECT_REQUIRE);
|
SRC_SELECT_TRUST | SRC_SELECT_REQUIRE);
|
||||||
|
|
||||||
DEBUG_LOG(0, "added source %d options %d", j, sel_options);
|
DEBUG_LOG("added source %d options %d", j, sel_options);
|
||||||
srcs[j] = SRC_CreateNewInstance(UTI_IPToRefid(&addr), SRC_NTP, sel_options, &addr,
|
srcs[j] = SRC_CreateNewInstance(UTI_IPToRefid(&addr), SRC_NTP, sel_options, &addr,
|
||||||
SRC_DEFAULT_MINSAMPLES, SRC_DEFAULT_MAXSAMPLES);
|
SRC_DEFAULT_MINSAMPLES, SRC_DEFAULT_MAXSAMPLES);
|
||||||
SRC_UpdateReachability(srcs[j], 1);
|
SRC_UpdateReachability(srcs[j], 1);
|
||||||
|
@ -68,7 +68,7 @@ test_unit(void)
|
||||||
delay = TST_GetRandomDouble(1.0e-6, 1.0e-1);
|
delay = TST_GetRandomDouble(1.0e-6, 1.0e-1);
|
||||||
disp = TST_GetRandomDouble(1.0e-6, 1.0e-1);
|
disp = TST_GetRandomDouble(1.0e-6, 1.0e-1);
|
||||||
|
|
||||||
DEBUG_LOG(0, "source %d sample %d offset %f delay %f disp %f", j, k,
|
DEBUG_LOG("source %d sample %d offset %f delay %f disp %f", j, k,
|
||||||
offset, delay, disp);
|
offset, delay, disp);
|
||||||
|
|
||||||
SRC_AccumulateSample(srcs[j], &ts, offset, delay, disp, delay, disp,
|
SRC_AccumulateSample(srcs[j], &ts, offset, delay, disp, delay, disp,
|
||||||
|
@ -81,7 +81,7 @@ test_unit(void)
|
||||||
double passed_lo = DBL_MAX, passed_hi = DBL_MIN;
|
double passed_lo = DBL_MAX, passed_hi = DBL_MIN;
|
||||||
|
|
||||||
SRC_SelectSource(srcs[k]);
|
SRC_SelectSource(srcs[k]);
|
||||||
DEBUG_LOG(0, "source %d status %d", k, sources[k]->status);
|
DEBUG_LOG("source %d status %d", k, sources[k]->status);
|
||||||
|
|
||||||
for (l = 0; l <= j; l++) {
|
for (l = 0; l <= j; l++) {
|
||||||
TEST_CHECK(sources[l]->status > SRC_OK && sources[l]->status <= SRC_SELECTED);
|
TEST_CHECK(sources[l]->status > SRC_OK && sources[l]->status <= SRC_SELECTED);
|
||||||
|
@ -114,7 +114,7 @@ test_unit(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(0, "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, passed,
|
||||||
trusted_passed, trusted, required_passed, required);
|
trusted_passed, trusted, required_passed, required);
|
||||||
|
|
||||||
TEST_CHECK(!trusted || !passed || (passed_lo >= trusted_lo && passed_hi <= trusted_hi));
|
TEST_CHECK(!trusted || !passed || (passed_lo >= trusted_lo && passed_hi <= trusted_hi));
|
||||||
|
|
Loading…
Reference in a new issue