[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Add test deck support to runWithDirector
commit 6ec391c39893dddb56dfd9447c522005425b01c7
Author: aagbsn <aagbsn@xxxxxxxx>
Date: Sat Jan 19 15:22:37 2013 +0000
Add test deck support to runWithDirector
---
ooni/oonicli.py | 118 ++++++++++++++++++++-----------------------------------
1 files changed, 43 insertions(+), 75 deletions(-)
diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index 78389f4..e9c6b01 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -168,88 +168,56 @@ def runWithDirector():
test!
"""
global_options = parseOptions()
- config.cmd_line_options = global_options
-
log.start(global_options['logfile'])
-
- net_test_args = global_options.pop('subargs')
- net_test_file = global_options['test']
- net_test_loader = NetTestLoader(net_test_file, net_test_args)
-
- try:
- net_test_loader.checkOptions()
- except MissingRequiredOption, option_name:
- log.err('Missing required option: "%s"' % option_name)
- print net_test_loader.usageOptions().getUsage()
- sys.exit(2)
- except usage.UsageError, e:
- log.err(e)
- print net_test_loader.usageOptions().getUsage()
- sys.exit(2)
-
- # reporters = [YAMLReporter, OONIBReporter]
-
- yaml_reporter = YAMLReporter(net_test_loader.testDetails)
- reporters = [yaml_reporter]
-
- if global_options['collector']:
- try:
- oonib_reporter = OONIBReporter(net_test_loader.testDetails,
- global_options['collector'])
- reporters.append(oonib_reporter)
- except InvalidOONIBCollectorAddress:
- log.err("Invalid format for oonib collector address.")
- log.msg("Should be in the format http://<collector_address>:<port>")
- log.msg("for example: ooniprobe -c httpo://nkvphnp3p6agi5qq.onion")
- sys.exit(1)
-
- director = Director(reporters)
- d = director.start()
-
- d.addCallback(director.startNetTest, net_test_loader)
- d.addBoth(shutdown)
- reactor.run()
-
-def run():
- """
- Parses command line arguments of test.
- """
-
- if config.privacy.includepcap:
- log.msg("Starting")
- if not config.reports.pcap:
- config.generatePcapFilename()
- runner.startSniffing()
-
- resume = cmd_line_options['resume']
+ net_test_args = global_options.get('subargs')
# contains (test_cases, options, cmd_line_options)
test_list = []
- if cmd_line_options['testdeck']:
- test_deck = yaml.safe_load(open(cmd_line_options['testdeck']))
+ if global_options['testdeck']:
+ test_deck = yaml.safe_load(open(global_options['testdeck']))
for test in test_deck:
- del cmd_line_options
- cmd_line_options = test['options']
- if resume:
- cmd_line_options['resume'] = True
- else:
- cmd_line_options['resume'] = False
- test_list.append(runner.loadTest(cmd_line_options))
+ test_options = test['options']
+ test_file = test_options['test']
+ test_subargs = test_options['subargs']
+ test_list.append(NetTestLoader(test_file, test_subargs))
else:
log.debug("No test deck detected")
- del cmd_line_options['testdeck']
- test_list.append(runner.loadTest(cmd_line_options))
-
- if config.advanced.start_tor:
- log.msg("Starting Tor...")
- d = runner.startTor()
- d.addCallback(runTestList, test_list)
- d.addErrback(errorRunningTests)
- else:
- # We need to pass None as first argument because when the callback is
- # fired it will pass it's result to runTestCase.
- d = runTestList(None, test_list)
- d.addErrback(errorRunningTests)
+ test_list.append(NetTestLoader(global_options['test'], net_test_args))
+
+
+ director = Director()
+ d = director.start()
+
+ for net_test_loader in test_list:
+
+ try:
+ net_test_loader.checkOptions()
+ except MissingRequiredOption, option_name:
+ log.err('Missing required option: "%s"' % option_name)
+ print net_test_loader.usageOptions().getUsage()
+ sys.exit(2)
+ except usage.UsageError, e:
+ log.err(e)
+ print net_test_loader.usageOptions().getUsage()
+ sys.exit(2)
+
+ yaml_reporter = YAMLReporter(net_test_loader.testDetails)
+ reporters = [yaml_reporter]
+
+ if global_options['collector']:
+ try:
+ oonib_reporter = OONIBReporter(net_test_loader.testDetails,
+ global_options['collector'])
+ reporters.append(oonib_reporter)
+ except InvalidOONIBCollectorAddress:
+ log.err("Invalid format for oonib collector address.")
+ log.msg("Should be in the format http://<collector_address>:<port>")
+ log.msg("for example: ooniprobe -c httpo://nkvphnp3p6agi5qq.onion")
+ sys.exit(1)
+
+ #XXX add all the tests to be run sequentially
+ d.addCallback(director.startNetTest, net_test_loader, reporters)
+ d.addBoth(shutdown)
reactor.run()
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits