def parse_arguments(): exper_options = get_experiment_option() parser = argparse.ArgumentParser(description='imalse') parser.add_argument('-e', '--experiment', default='TopoExperiment', help='specify the experiment. Avaliable experiments are [%s]'%(" |").join(exper_options) ) parser.add_argument('--mode', default='sim', help="specify the mode, can be ['netns3' | 'sim'], default is 'sim'. " ) parser.add_argument('--ehelp', action='store_true', help="print the help of a experiment" ) # Print Help when there is no argument if len(sys.argv) == 1: print '----------------Experment Selection Arguments------------------' parser.print_help() print '----------------Exeriment Options------------------------------' for experiment in exper_options: for mode in ['netns3','sim']: print '+++++++++Experiment:[%s] Mode:[%s]+++++++++++++++++++++++'%(experiment, mode) exper_class = experiments.experiment_factory(experiment, mode) exper = exper_class() exper.print_help() sys.exit(1) args, exper_args = parser.parse_known_args() if args.ehelp: print '+++++++++Experiment:[%s] Mode:[%s]+++++++++++++++++++++++'%(args.experiment, args.mode) exper.print_help() sys.exit(1) return args, exper_args
#!/usr/bin/env python """test all experiments and scenarios""" from subprocess import check_call, Popen from util import get_experiment_option, get_scenario_option exper_options = get_experiment_option() scenario_option = get_scenario_option() skip_expr = ['ImalseTopoHybridExperiment', 'ImalseHybridExperiment'] skip_scen = ['ddos_ping_flooding', 'infecting'] fid = open('test.out', 'w') for exper in exper_options: for scenario in scenario_option: if exper in skip_expr or scenario in skip_scen: print >> fid, 'skipping experiment: [%s], scenario:[%s]' % ( exper, scenario) continue print >> fid, '-' * 100 print >> fid, 'testing experiment: [%s], scenario:[%s]' % (exper, scenario) print >> fid, '-' * 100 check_call(['./simulate.py', '-e', exper, '-s', scenario]) # Popen(['./simulate.py', '-e', exper, '-s', scenario]) fid.close()
#!/usr/bin/env python """test all experiments and scenarios""" from subprocess import check_call, Popen from util import get_experiment_option, get_scenario_option exper_options = get_experiment_option() scenario_option = get_scenario_option() skip_expr = ['ImalseTopoHybridExperiment', 'ImalseHybridExperiment'] skip_scen = ['ddos_ping_flooding', 'infecting'] fid = open ('test.out', 'w') for exper in exper_options: for scenario in scenario_option: if exper in skip_expr or scenario in skip_scen: print >>fid, 'skipping experiment: [%s], scenario:[%s]'%(exper, scenario) continue print >>fid, '-' * 100 print >>fid, 'testing experiment: [%s], scenario:[%s]'%(exper, scenario) print >>fid, '-' * 100 check_call(['./simulate.py', '-e', exper, '-s', scenario]) # Popen(['./simulate.py', '-e', exper, '-s', scenario]) fid.close()