blob: 024c5021489efe30585ef81399989e197d1b4e31 [file] [log] [blame]
Philipp Schradere41ed9d2015-03-15 22:57:13 +00001#include <iostream>
2#include <getopt.h>
3
4#include "gtest/gtest.h"
5#include "aos/common/queue_testutils.h"
6
7GTEST_API_ int main(int argc, char **argv) {
8 static const struct option long_options[] = {
9 {"help", no_argument, 0, 'h'},
10 {"print-logs", no_argument, 0, 'p'},
11 {"log-file", required_argument, 0, 'o'},
12 {0, 0, 0, 0},
13 };
14
15 testing::InitGoogleTest(&argc, argv);
16
17 // The gtest library modifies argc and argv to remove all of its own command
18 // line switches etc. So after calling InitGoogleTest() we can parse our own
19 // command line options.
20 while (true) {
21 int c = getopt_long(argc, argv, "po:", long_options, nullptr);
22
23 if (c == -1) {
24 break;
25 }
26
27 switch (c) {
28 case 'h':
29 printf(
30 "\nFRC971 options:\n"
31 " -p, --print-logs\n"
32 " Print the log messages as they are being generated.\n"
33 " -o, --log-file=FILE\n"
34 " Print all log messages to FILE instead of standard output\n"
35 );
36 break;
37
38 case 'p':
39 aos::common::testing::ForcePrintLogsDuringTests();
40 break;
41
42 case 'o':
43 aos::common::testing::SetLogFileName(optarg);
44 break;
45
46 case '?':
47 abort();
48 }
49 }
50
51 return RUN_ALL_TESTS();
52}