| 31 | g_repeat = 1 |
| 32 | |
| 33 | def ParseArgs(): |
| 34 | global g_spew_level |
| 35 | global g_p2p_rendezvous_level |
| 36 | global g_setup_mock_ips |
| 37 | global g_cleanup_mock_ips |
| 38 | global g_repeat |
| 39 | |
| 40 | parser = argparse.ArgumentParser() |
| 41 | parser.add_argument( |
| 42 | '--spewlevel', |
| 43 | choices=[ 'msg', 'verbose', 'debug' ], |
| 44 | help='Control how much diagnostic spew is mirrored to stdio. More detailed output is always available in the per-process file logs.' |
| 45 | ) |
| 46 | parser.add_argument( |
| 47 | '--loglevel-p2prendezvous', |
| 48 | dest='loglevel_p2prendezvous', |
| 49 | choices=[ 'msg', 'verbose', 'debug' ], |
| 50 | help='Control detail level specifically for P2P rendezvous-related spew.' |
| 51 | ) |
| 52 | parser.add_argument( |
| 53 | '--setup-mock-ips', |
| 54 | action='store_true', |
| 55 | help='Add any addresses needed by the mock network that are not already bindable. Exits without running tests.' |
| 56 | ) |
| 57 | parser.add_argument( |
| 58 | '--cleanup-mock-ips', |
| 59 | action='store_true', |
| 60 | help='Remove addresses added by --setup-mock-ips. Exits without running tests.' |
| 61 | ) |
| 62 | parser.add_argument( |
| 63 | '--repeat', |
| 64 | type=int, |
| 65 | default=1, |
| 66 | metavar='N', |
| 67 | help='Repeat each connection N times (passed through to the test executable).' |
| 68 | ) |
| 69 | args = parser.parse_args() |
| 70 | g_spew_level = args.spewlevel |
| 71 | g_p2p_rendezvous_level = args.loglevel_p2prendezvous |
| 72 | g_setup_mock_ips = args.setup_mock_ips |
| 73 | g_cleanup_mock_ips = args.cleanup_mock_ips |
| 74 | g_repeat = args.repeat |
| 75 | |
| 76 | # Thread class that runs a process and captures its output |
| 77 | class RunProcessInThread(threading.Thread): |