blob: f7e90cb49faf440dce93a8ab870070e8bd993434 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <signal.h>
2#include <stdlib.h>
3
4#include "ares-test.h"
5
6int main(int argc, char* argv[]) {
7 std::vector<char*> gtest_argv = {argv[0]};
8 for (int ii = 1; ii < argc; ii++) {
9 if (strcmp(argv[ii], "-v") == 0) {
10 ares::test::verbose = true;
11 } else if ((strcmp(argv[ii], "-p") == 0) && (ii + 1 < argc)) {
12 ii++;
13 ares::test::mock_port = atoi(argv[ii]);
14 } else {
15 gtest_argv.push_back(argv[ii]);
16 }
17 }
18 int gtest_argc = gtest_argv.size();
19 gtest_argv.push_back(nullptr);
20 ::testing::InitGoogleTest(&gtest_argc, gtest_argv.data());
21
22#ifdef WIN32
23 WORD wVersionRequested = MAKEWORD(2, 2);
24 WSADATA wsaData;
25 WSAStartup(wVersionRequested, &wsaData);
26#else
27 signal(SIGPIPE, SIG_IGN);
28#endif
29
30 int rc = RUN_ALL_TESTS();
31
32#ifdef WIN32
33 WSACleanup();
34#endif
35
36 return rc;
37}