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));
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));
}
}
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) {
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;
#include "test.h"
void
-test_fail(int line)
+TST_Fail(int line)
{
printf("FAIL (on line %d)\n", line);
exit(1);
}
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;
}
void
-swap_address_bit(IPAddr *ip, unsigned int b)
+TST_SwapAddressBit(IPAddr *ip, unsigned int b)
{
if (ip->family == IPADDR_INET4) {
assert(b < 32);
#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