test/unit: follow chrony function naming convention
This commit is contained in:
parent
910663c37b
commit
80f4d75968
5 changed files with 14 additions and 14 deletions
|
@ -36,10 +36,10 @@ test_unit(void)
|
|||
for (j = 0; j < 1000; j++) {
|
||||
if (j % 2) {
|
||||
maxsub = 32;
|
||||
get_random_address(&ip, IPADDR_INET4, -1);
|
||||
TST_GetRandomAddress(&ip, IPADDR_INET4, -1);
|
||||
} else {
|
||||
maxsub = 128;
|
||||
get_random_address(&ip, IPADDR_INET6, -1);
|
||||
TST_GetRandomAddress(&ip, IPADDR_INET6, -1);
|
||||
}
|
||||
|
||||
DEBUG_LOG(0, "address %s", UTI_IPToString(&ip));
|
||||
|
@ -51,16 +51,16 @@ test_unit(void)
|
|||
TEST_CHECK(ADF_IsAllowed(table, &ip));
|
||||
|
||||
if (sub < maxsub) {
|
||||
swap_address_bit(&ip, sub);
|
||||
TST_SwapAddressBit(&ip, sub);
|
||||
TEST_CHECK(ADF_IsAllowed(table, &ip));
|
||||
}
|
||||
|
||||
if (sub > 0) {
|
||||
swap_address_bit(&ip, sub - 1);
|
||||
TST_SwapAddressBit(&ip, sub - 1);
|
||||
TEST_CHECK(!ADF_IsAllowed(table, &ip));
|
||||
if (sub % 4 != 1) {
|
||||
ADF_Deny(table, &ip, sub - 1);
|
||||
swap_address_bit(&ip, sub - 1);
|
||||
TST_SwapAddressBit(&ip, sub - 1);
|
||||
TEST_CHECK(!ADF_IsAllowed(table, &ip));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ test_unit(void)
|
|||
tv.tv_usec = 0;
|
||||
|
||||
for (j = 0; j < 1000; j++) {
|
||||
get_random_address(&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));
|
||||
|
||||
if (random() % 2) {
|
||||
|
|
|
@ -51,7 +51,7 @@ test_unit(void)
|
|||
|
||||
for (j = 0; j < sizeof (addrs) / sizeof (addrs[0]); j++) {
|
||||
do {
|
||||
get_random_address(&addrs[j].ip_addr, IPADDR_UNSPEC, -1);
|
||||
TST_GetRandomAddress(&addrs[j].ip_addr, IPADDR_UNSPEC, -1);
|
||||
} while (UTI_IPToHash(&addrs[j].ip_addr) % (1U << i) != hash % (1U << i));
|
||||
|
||||
addrs[j].port = random() % 1024;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "test.h"
|
||||
|
||||
void
|
||||
test_fail(int line)
|
||||
TST_Fail(int line)
|
||||
{
|
||||
printf("FAIL (on line %d)\n", line);
|
||||
exit(1);
|
||||
|
@ -69,7 +69,7 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
void
|
||||
get_random_address(IPAddr *ip, int family, int bits)
|
||||
TST_GetRandomAddress(IPAddr *ip, int family, int bits)
|
||||
{
|
||||
if (family != IPADDR_INET4 && family != IPADDR_INET6)
|
||||
family = random() % 2 ? IPADDR_INET4 : IPADDR_INET6;
|
||||
|
@ -104,7 +104,7 @@ get_random_address(IPAddr *ip, int family, int bits)
|
|||
}
|
||||
|
||||
void
|
||||
swap_address_bit(IPAddr *ip, unsigned int b)
|
||||
TST_SwapAddressBit(IPAddr *ip, unsigned int b)
|
||||
{
|
||||
if (ip->family == IPADDR_INET4) {
|
||||
assert(b < 32);
|
||||
|
|
|
@ -28,14 +28,14 @@ extern void test_unit(void);
|
|||
#define TEST_CHECK(expr) \
|
||||
do { \
|
||||
if (!(expr)) { \
|
||||
test_fail(__LINE__); \
|
||||
TST_Fail(__LINE__); \
|
||||
exit(1); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
extern void test_fail(int line);
|
||||
extern void TST_Fail(int line);
|
||||
|
||||
extern void get_random_address(IPAddr *ip, int family, int bits);
|
||||
extern void swap_address_bit(IPAddr *ip, unsigned int b);
|
||||
extern void TST_GetRandomAddress(IPAddr *ip, int family, int bits);
|
||||
extern void TST_SwapAddressBit(IPAddr *ip, unsigned int b);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue