diff --git a/test/ares-test-main.cc b/test/ares-test-main.cc index 9a5a325..09283b9 100644 --- a/test/ares-test-main.cc +++ b/test/ares-test-main.cc @@ -1,8 +1,4 @@ -#include -#include -#include -#include -#include +#include #include "ares-test.h" @@ -11,6 +7,9 @@ int main(int argc, char* argv[]) { for (int ii = 1; ii < argc; ii++) { if (strcmp(argv[ii], "-v") == 0) { ares::test::verbose = true; + } else if ((strcmp(argv[ii], "-p") == 0) && (ii + 1 < argc)) { + ii++; + ares::test::mock_port = atoi(argv[ii]); } } diff --git a/test/ares-test.cc b/test/ares-test.cc index f3cb71f..0bd857c 100644 --- a/test/ares-test.cc +++ b/test/ares-test.cc @@ -56,6 +56,7 @@ void ProcessWork(ares_channel channel, } // namespace bool verbose = false; +int mock_port = 5300; unsigned long LibraryTest::fails_ = 0; std::map LibraryTest::size_fails_; @@ -218,7 +219,7 @@ void MockServer::ProcessRequest(struct sockaddr_storage* addr, int addrlen, MockChannelOptsTest::MockChannelOptsTest(struct ares_options* givenopts, int optmask) - : server_(5300), channel_(nullptr) { + : server_(mock_port), channel_(nullptr) { // Set up channel options. struct ares_options opts; if (givenopts) { diff --git a/test/ares-test.h b/test/ares-test.h index 7838a77..a9d5a2e 100644 --- a/test/ares-test.h +++ b/test/ares-test.h @@ -21,6 +21,7 @@ typedef unsigned char byte; namespace test { extern bool verbose; +extern int mock_port; // Test fixture that ensures library initialization, and allows // memory allocations to be failed.