Skip to content

Commit

Permalink
test: allow restriction to one IP address family
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddrysdale committed Dec 14, 2017
1 parent 7418cca commit d3d6c86
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 41 deletions.
6 changes: 6 additions & 0 deletions test/ares-test-main.cc
Expand Up @@ -11,6 +11,12 @@ int main(int argc, char* argv[]) {
} else if ((strcmp(argv[ii], "-p") == 0) && (ii + 1 < argc)) {
ii++;
ares::test::mock_port = atoi(argv[ii]);
} else if (strcmp(argv[ii], "-4") == 0) {
ares::test::families = ares::test::ipv4_family;
ares::test::families_modes = ares::test::ipv4_family_both_modes;
} else if (strcmp(argv[ii], "-6") == 0) {
ares::test::families = ares::test::ipv6_family;
ares::test::families_modes = ares::test::ipv6_family_both_modes;
} else {
gtest_argv.push_back(argv[ii]);
}
Expand Down
55 changes: 14 additions & 41 deletions test/ares-test-mock.cc
Expand Up @@ -1138,48 +1138,21 @@ TEST_P(NoRotateMultiMockTest, ThirdServer) {
CheckExample();
}

INSTANTIATE_TEST_CASE_P(AddressFamilies, MockChannelTest, ::testing::ValuesIn(ares::test::families_modes));

INSTANTIATE_TEST_CASE_P(AddressFamilies, MockChannelTest,
::testing::Values(std::make_pair<int, bool>(AF_INET, false),
std::make_pair<int, bool>(AF_INET, true),
std::make_pair<int, bool>(AF_INET6, false),
std::make_pair<int, bool>(AF_INET6, true)));

INSTANTIATE_TEST_CASE_P(AddressFamilies, MockUDPChannelTest,
::testing::Values(AF_INET, AF_INET6));

INSTANTIATE_TEST_CASE_P(AddressFamilies, MockTCPChannelTest,
::testing::Values(AF_INET, AF_INET6));

INSTANTIATE_TEST_CASE_P(AddressFamilies, MockExtraOptsTest,
::testing::Values(std::make_pair<int, bool>(AF_INET, false),
std::make_pair<int, bool>(AF_INET, true),
std::make_pair<int, bool>(AF_INET6, false),
std::make_pair<int, bool>(AF_INET6, true)));

INSTANTIATE_TEST_CASE_P(AddressFamilies, MockNoCheckRespChannelTest,
::testing::Values(std::make_pair<int, bool>(AF_INET, false),
std::make_pair<int, bool>(AF_INET, true),
std::make_pair<int, bool>(AF_INET6, false),
std::make_pair<int, bool>(AF_INET6, true)));

INSTANTIATE_TEST_CASE_P(AddressFamilies, MockEDNSChannelTest,
::testing::Values(std::make_pair<int, bool>(AF_INET, false),
std::make_pair<int, bool>(AF_INET, true),
std::make_pair<int, bool>(AF_INET6, false),
std::make_pair<int, bool>(AF_INET6, true)));

INSTANTIATE_TEST_CASE_P(TransportModes, RotateMultiMockTest,
::testing::Values(std::make_pair<int, bool>(AF_INET, false),
std::make_pair<int, bool>(AF_INET, true),
std::make_pair<int, bool>(AF_INET6, false),
std::make_pair<int, bool>(AF_INET6, true)));

INSTANTIATE_TEST_CASE_P(TransportModes, NoRotateMultiMockTest,
::testing::Values(std::make_pair<int, bool>(AF_INET, false),
std::make_pair<int, bool>(AF_INET, true),
std::make_pair<int, bool>(AF_INET6, false),
std::make_pair<int, bool>(AF_INET6, true)));
INSTANTIATE_TEST_CASE_P(AddressFamilies, MockUDPChannelTest, ::testing::ValuesIn(ares::test::families));

INSTANTIATE_TEST_CASE_P(AddressFamilies, MockTCPChannelTest, ::testing::ValuesIn(ares::test::families));

INSTANTIATE_TEST_CASE_P(AddressFamilies, MockExtraOptsTest, ::testing::ValuesIn(ares::test::families_modes));

INSTANTIATE_TEST_CASE_P(AddressFamilies, MockNoCheckRespChannelTest, ::testing::ValuesIn(ares::test::families_modes));

INSTANTIATE_TEST_CASE_P(AddressFamilies, MockEDNSChannelTest, ::testing::ValuesIn(ares::test::families_modes));

INSTANTIATE_TEST_CASE_P(TransportModes, RotateMultiMockTest, ::testing::ValuesIn(ares::test::families_modes));

INSTANTIATE_TEST_CASE_P(TransportModes, NoRotateMultiMockTest, ::testing::ValuesIn(ares::test::families_modes));

} // namespace test
} // namespace ares
23 changes: 23 additions & 0 deletions test/ares-test.cc
Expand Up @@ -31,6 +31,29 @@ namespace test {
bool verbose = false;
int mock_port = 5300;

const std::vector<int> both_families = {AF_INET, AF_INET6};
const std::vector<int> ipv4_family = {AF_INET};
const std::vector<int> ipv6_family = {AF_INET6};

const std::vector<std::pair<int, bool>> both_families_both_modes = {
std::make_pair<int, bool>(AF_INET, false),
std::make_pair<int, bool>(AF_INET, true),
std::make_pair<int, bool>(AF_INET6, false),
std::make_pair<int, bool>(AF_INET6, true)
};
const std::vector<std::pair<int, bool>> ipv4_family_both_modes = {
std::make_pair<int, bool>(AF_INET, false),
std::make_pair<int, bool>(AF_INET, true)
};
const std::vector<std::pair<int, bool>> ipv6_family_both_modes = {
std::make_pair<int, bool>(AF_INET6, false),
std::make_pair<int, bool>(AF_INET6, true)
};

// Which parameters to use in tests
std::vector<int> families = both_families;
std::vector<std::pair<int, bool>> families_modes = both_families_both_modes;

unsigned long long LibraryTest::fails_ = 0;
std::map<size_t, int> LibraryTest::size_fails_;

Expand Down
11 changes: 11 additions & 0 deletions test/ares-test.h
Expand Up @@ -36,6 +36,17 @@ namespace test {

extern bool verbose;
extern int mock_port;
extern const std::vector<int> both_families;
extern const std::vector<int> ipv4_family;
extern const std::vector<int> ipv6_family;

extern const std::vector<std::pair<int, bool>> both_families_both_modes;
extern const std::vector<std::pair<int, bool>> ipv4_family_both_modes;
extern const std::vector<std::pair<int, bool>> ipv6_family_both_modes;

// Which parameters to use in tests
extern std::vector<int> families;
extern std::vector<std::pair<int, bool>> families_modes;

// Process all pending work on ares-owned file descriptors, plus
// optionally the given set-of-FDs + work function.
Expand Down

0 comments on commit d3d6c86

Please sign in to comment.