1 #include <signal.h>
2 #include <stdlib.h>
3 
4 #include "ares-test.h"
5 
main(int argc,char * argv[])6 int 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 if (strcmp(argv[ii], "-4") == 0) {
15       ares::test::families = ares::test::ipv4_family;
16       ares::test::families_modes = ares::test::ipv4_family_both_modes;
17     } else if (strcmp(argv[ii], "-6") == 0) {
18       ares::test::families = ares::test::ipv6_family;
19       ares::test::families_modes = ares::test::ipv6_family_both_modes;
20     } else {
21       gtest_argv.push_back(argv[ii]);
22     }
23   }
24   int gtest_argc = gtest_argv.size();
25   gtest_argv.push_back(nullptr);
26   ::testing::InitGoogleTest(&gtest_argc, gtest_argv.data());
27 
28 #ifdef WIN32
29   WORD wVersionRequested = MAKEWORD(2, 2);
30   WSADATA wsaData;
31   WSAStartup(wVersionRequested, &wsaData);
32 #else
33   signal(SIGPIPE, SIG_IGN);
34 #endif
35 
36   int rc = RUN_ALL_TESTS();
37 
38 #ifdef WIN32
39   WSACleanup();
40 #endif
41 
42   return rc;
43 }
44