Skip to content

Commit

Permalink
Fix tests on FreeBSD (ignore addrtuple, add missing include)
Browse files Browse the repository at this point in the history
  • Loading branch information
valpackett authored and agoode committed Apr 1, 2020
1 parent e292240 commit 905af16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/nss-test.c
Expand Up @@ -26,6 +26,9 @@
#include <sys/socket.h>
#include <string.h>
#include <arpa/inet.h>
#ifdef __FreeBSD__
#include <netinet/in.h>
#endif

static int gai(const char* node) {
struct addrinfo hints;
Expand Down
6 changes: 6 additions & 0 deletions tests/check_util.c
Expand Up @@ -546,6 +546,7 @@ static query_address_result_t create_address_result(int offset, int af) {
return result;
}

#ifndef __FreeBSD__
static void validate_addrtuples(struct gaih_addrtuple* pat,
const char* expected_name, int expected_count) {
int i = 0;
Expand Down Expand Up @@ -573,6 +574,7 @@ static void validate_addrtuples(struct gaih_addrtuple* pat,
}
ck_assert_int_eq(i, expected_count);
}
#endif

static userdata_t create_address_userdata(int num_addresses, int af) {
ck_assert_int_le(num_addresses, MAX_ENTRIES);
Expand Down Expand Up @@ -629,6 +631,7 @@ static void validate_hostent(struct hostent* hostent, const char* name, int af,

// Tests for convert_userdata_to_addrtuple.

#ifndef __FreeBSD__
START_TEST(test_userdata_to_addrtuple_returns_tuples) {
userdata_t u = create_address_userdata(16, AF_UNSPEC);
struct gaih_addrtuple* pat = NULL;
Expand Down Expand Up @@ -709,6 +712,7 @@ START_TEST(test_userdata_to_addrtuple_nonnull_pat_is_used) {
validate_addrtuples(&tuple, "example.local", 16);
}
END_TEST
#endif

// Tests for convert_userdata_for_name_to_hostent.

Expand Down Expand Up @@ -973,6 +977,7 @@ static Suite* util_suite(void) {
tcase_add_test(tc_buffer, test_buffer_alloc_returns_zeroed_memory);
suite_add_tcase(s, tc_buffer);

#ifndef __FreeBSD__
TCase* tc_userdata_to_addrtuple = tcase_create("userdata_to_addrtuple");
tcase_add_test(tc_userdata_to_addrtuple,
test_userdata_to_addrtuple_returns_tuples);
Expand All @@ -983,6 +988,7 @@ static Suite* util_suite(void) {
tcase_add_test(tc_userdata_to_addrtuple,
test_userdata_to_addrtuple_nonnull_pat_is_used);
suite_add_tcase(s, tc_userdata_to_addrtuple);
#endif

TCase* tc_userdata_for_name_to_hostent =
tcase_create("userdata_for_name_to_hostent");
Expand Down

0 comments on commit 905af16

Please sign in to comment.