mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 02:16:53 +08:00
mavsdk_tests: add wildcards for case filtering
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import datetime
|
import datetime
|
||||||
|
import fnmatch
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
@@ -32,7 +33,8 @@ def main() -> NoReturn:
|
|||||||
parser.add_argument("--model", type=str, default='all',
|
parser.add_argument("--model", type=str, default='all',
|
||||||
help="only run tests for one model")
|
help="only run tests for one model")
|
||||||
parser.add_argument("--case", type=str, default='all',
|
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="",
|
parser.add_argument("--debugger", default="",
|
||||||
help="choice from valgrind, callgrind, gdb, lldb")
|
help="choice from valgrind, callgrind, gdb, lldb")
|
||||||
parser.add_argument("--verbose", default=False, action='store_true',
|
parser.add_argument("--verbose", default=False, action='store_true',
|
||||||
@@ -148,10 +150,15 @@ class Tester:
|
|||||||
for key in test['cases'].keys():
|
for key in test['cases'].keys():
|
||||||
test['cases'][key] = {
|
test['cases'][key] = {
|
||||||
'selected': (test['selected'] and
|
'selected': (test['selected'] and
|
||||||
(case == 'all' or case == key))}
|
(case == 'all' or
|
||||||
|
cls.wildcard_match(case, key)))}
|
||||||
|
|
||||||
return tests
|
return tests
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def wildcard_match(pattern: str, potential_match: str) -> bool:
|
||||||
|
return fnmatch.fnmatchcase(potential_match, pattern)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def query_test_cases(filter: str) -> List[str]:
|
def query_test_cases(filter: str) -> List[str]:
|
||||||
cmd = os.getcwd() + "/build/px4_sitl_default/mavsdk_tests/mavsdk_tests"
|
cmd = os.getcwd() + "/build/px4_sitl_default/mavsdk_tests/mavsdk_tests"
|
||||||
|
|||||||
Reference in New Issue
Block a user