test: Allow command line override of mock server port

pull/34/head
David Drysdale 10 years ago
parent 2aa07c7d02
commit 3907b6dc68
  1. 9
      test/ares-test-main.cc
  2. 3
      test/ares-test.cc
  3. 1
      test/ares-test.h

@ -1,8 +1,4 @@
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
#include <pwd.h>
#include <iostream>
#include <stdlib.h>
#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]);
}
}

@ -56,6 +56,7 @@ void ProcessWork(ares_channel channel,
} // namespace
bool verbose = false;
int mock_port = 5300;
unsigned long LibraryTest::fails_ = 0;
std::map<size_t, int> 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) {

@ -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.

Loading…
Cancel
Save