1
0
mirror of https://frontier.innolan.net/rainlance/c-ares.git synced 2025-12-06 11:53:52 +00:00

test: Allow command line override of mock server port

This commit is contained in:
David Drysdale
2015-10-01 16:08:49 +01:00
parent 2aa07c7d02
commit 3907b6dc68
3 changed files with 7 additions and 6 deletions

View File

@ -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]);
}
}

View File

@ -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) {

View File

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