mirror of
https://frontier.innolan.net/rainlance/c-ares.git
synced 2025-12-06 12:41:46 +00:00
test: Allow command line override of mock server port
This commit is contained in:
@ -1,8 +1,4 @@
|
|||||||
#include <sys/types.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "ares-test.h"
|
#include "ares-test.h"
|
||||||
|
|
||||||
@ -11,6 +7,9 @@ int main(int argc, char* argv[]) {
|
|||||||
for (int ii = 1; ii < argc; ii++) {
|
for (int ii = 1; ii < argc; ii++) {
|
||||||
if (strcmp(argv[ii], "-v") == 0) {
|
if (strcmp(argv[ii], "-v") == 0) {
|
||||||
ares::test::verbose = true;
|
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
|
} // namespace
|
||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
|
int mock_port = 5300;
|
||||||
|
|
||||||
unsigned long LibraryTest::fails_ = 0;
|
unsigned long LibraryTest::fails_ = 0;
|
||||||
std::map<size_t, int> LibraryTest::size_fails_;
|
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,
|
MockChannelOptsTest::MockChannelOptsTest(struct ares_options* givenopts,
|
||||||
int optmask)
|
int optmask)
|
||||||
: server_(5300), channel_(nullptr) {
|
: server_(mock_port), channel_(nullptr) {
|
||||||
// Set up channel options.
|
// Set up channel options.
|
||||||
struct ares_options opts;
|
struct ares_options opts;
|
||||||
if (givenopts) {
|
if (givenopts) {
|
||||||
|
|||||||
@ -21,6 +21,7 @@ typedef unsigned char byte;
|
|||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
extern bool verbose;
|
extern bool verbose;
|
||||||
|
extern int mock_port;
|
||||||
|
|
||||||
// Test fixture that ensures library initialization, and allows
|
// Test fixture that ensures library initialization, and allows
|
||||||
// memory allocations to be failed.
|
// memory allocations to be failed.
|
||||||
|
|||||||
Reference in New Issue
Block a user