Debian Codegraph @

Xpjproject/pjsip/src/test/main.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #include "test.h"
20 #include <stdio.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include <pj/argparse.h>
24
25 extern const char *system_name;
26
27 static void warn(void)
28 {
29 puts("********************************************************************");
30 puts("** W A R N I N G **");
31 puts("********************************************************************");
32 puts("** Due to centralized event processing in PJSIP, events may be **");
33 puts("** read by different thread than the test's thread. This may **");
34 puts("** cause logs to be saved by the wrong test when multithreaded **");
35 puts("** testing is used. The test results are correct, but the log **");
36 puts("** may not be accurate. **");
37 puts("** For debugging with correct logging, use \"-w 0 --log-no-cache\" **");
38 puts("********************************************************************");
39 }
40
41 static void usage(void)
42 {
43 puts("Usage:");
44 puts(" pjsip-test [OPTIONS] [test_to_run] [test to run] [..]");
45 puts("");
46 puts("where OPTIONS:");
47 puts("");
48 puts(" -h,--help Show this screen");
49
50 ut_usage();
51
52 puts(" -i,--interractive Key input at the end.");
53 puts(" -n,--no-trap Let signals be handled by the OS");
54 puts(" --log-level N Set log level (0-6)");
55 puts(" -s,--system NAME Set system name to NAME");
56 }
57
58 int main(int argc, char *argv[])
59 {
60 int interractive = 0;
61 int retval;
62
63 warn();
64
65 if (pj_argparse_get_bool(&argc, argv, "-h") ||
66 pj_argparse_get_bool(&argc, argv, "--help"))
67 {
68 usage();
69 return 0;
70 }
71
72 ut_app_init0(&test_app.ut_app);
73
74 interractive = pj_argparse_get_bool(&argc, argv, "-i");
75 if (pj_argparse_get_str(&argc, argv, "-s", (char**)&system_name) ||
76 pj_argparse_get_str(&argc, argv, "--system", (char**)&system_name))
77 {
78 usage();
79 return 1;
80 }
81
82 if (pj_argparse_get_int(&argc, argv, "--log-level", &log_level)) {
83 usage();
84 return 1;
85 }
86
87 if (ut_parse_args(&test_app.ut_app, &argc, argv))
88 return 1;
89
90 retval = test_main(argc, argv);
91
92 if (interractive) {
93 char s[10];
94 printf("<Press ENTER to quit>\n"); fflush(stdout);
95 if (fgets(s, sizeof(s), stdin) == NULL)
96 return retval;
97 }
98
99 return retval;
100 }