| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 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 |
} |