(TESTFILE, OUTPUTFILE, PREEXEC, NUM, KW_OK, KW_KO, DUMP, DOCS,
FORMAT, VERB, ONLYFAILED, CRC, INTERPRETER,
autorun_func, theme, pos_begin=0,
scapy_ses=None)
| 882 | # MAIN # |
| 883 | |
| 884 | def execute_campaign(TESTFILE, OUTPUTFILE, PREEXEC, NUM, KW_OK, KW_KO, DUMP, DOCS, |
| 885 | FORMAT, VERB, ONLYFAILED, CRC, INTERPRETER, |
| 886 | autorun_func, theme, pos_begin=0, |
| 887 | scapy_ses=None): # noqa: E501 |
| 888 | # Parse test file |
| 889 | try: |
| 890 | test_campaign = parse_campaign_file(TESTFILE) |
| 891 | except ValueError as ex: |
| 892 | print( |
| 893 | theme.red("Error while parsing '%s': '%s'" % (TESTFILE.name, ex)) |
| 894 | ) |
| 895 | sys.exit(1) |
| 896 | |
| 897 | # Report parameters |
| 898 | if PREEXEC: |
| 899 | test_campaign.preexec = PREEXEC |
| 900 | |
| 901 | # Compute campaign CRC and SHA |
| 902 | if CRC: |
| 903 | compute_campaign_digests(test_campaign) |
| 904 | |
| 905 | # Filter out unwanted tests |
| 906 | filter_tests_on_numbers(test_campaign, NUM) |
| 907 | for k in KW_OK: |
| 908 | filter_tests_keep_on_keywords(test_campaign, k) |
| 909 | for k in KW_KO: |
| 910 | filter_tests_remove_on_keywords(test_campaign, k) |
| 911 | |
| 912 | remove_empty_testsets(test_campaign) |
| 913 | |
| 914 | # Dump campaign |
| 915 | if DUMP: |
| 916 | dump_campaign(test_campaign) |
| 917 | if DUMP > 1: |
| 918 | sys.exit() |
| 919 | |
| 920 | # Dump campaign as reStructuredText |
| 921 | if DOCS: |
| 922 | docs_campaign(test_campaign) |
| 923 | sys.exit() |
| 924 | |
| 925 | # Run tests |
| 926 | test_campaign.output_file = OUTPUTFILE |
| 927 | result = run_campaign( |
| 928 | test_campaign, autorun_func[FORMAT], theme, |
| 929 | drop_to_interpreter=INTERPRETER, |
| 930 | verb=VERB, |
| 931 | scapy_ses=scapy_ses |
| 932 | ) |
| 933 | |
| 934 | # Shrink passed |
| 935 | if ONLYFAILED: |
| 936 | for t in test_campaign.all_tests(): |
| 937 | if t: |
| 938 | t.expand = 0 |
| 939 | else: |
| 940 | t.expand = 2 |
| 941 |
no test coverage detected
searching dependent graphs…