mavsdk_tests: add wildcards for case filtering

This commit is contained in:
Julian Oes 2020-06-26 14:14:32 +02:00 committed by Daniel Agar
parent c4efcbf895
commit a05ad9c64c
1 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@
import argparse
import datetime
import fnmatch
import json
import math
import os
@ -32,7 +33,8 @@ def main() -> NoReturn:
parser.add_argument("--model", type=str, default='all',
help="only run tests for one model")
parser.add_argument("--case", type=str, default='all',
help="only run tests for one case")
help="only run tests for one case "
"(or multiple cases with wildcard '*')")
parser.add_argument("--debugger", default="",
help="choice from valgrind, callgrind, gdb, lldb")
parser.add_argument("--verbose", default=False, action='store_true',
@ -148,10 +150,15 @@ class Tester:
for key in test['cases'].keys():
test['cases'][key] = {
'selected': (test['selected'] and
(case == 'all' or case == key))}
(case == 'all' or
cls.wildcard_match(case, key)))}
return tests
@staticmethod
def wildcard_match(pattern: str, potential_match: str) -> bool:
return fnmatch.fnmatchcase(potential_match, pattern)
@staticmethod
def query_test_cases(filter: str) -> List[str]:
cmd = os.getcwd() + "/build/px4_sitl_default/mavsdk_tests/mavsdk_tests"