File tree 2 files changed +20
-2
lines changed
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 16
16
* executed t1 test cases.
17
17
18
18
19
- ### Run a single test case ###
19
+ ### Run all tests in a single test file ###
20
20
* ./run_tests.sh -d <dut_name> -n <testbed_name> [ -s <list of test cases or files to skip >] -u -c platform_tests/test_link_flap.py
21
21
* execute link flap test case.
22
22
* when specifying test cast list, no need to specify topology with -t.
23
23
24
+ ### Run test cases in a single test file with filter ###
25
+ * ./run_tests.sh -d <dut_name> -n <testbed_name> [ -s <list of test cases or files to skip >] -u -c arp/test_arpall.py -C garp
26
+ * execute all tests that has garp in the name in arp/test_arpall.py
27
+ * ./run_tests.sh -d <dut_name> -n <testbed_name> [ -s <list of test cases or files to skip >] -u -c arp/test_arpall.py -C "garp or unicast"
28
+ * execute all tests that has garp or unicast in the name in arp/test_arpall.py
29
+ * ./run_tests.sh -d <dut_name> -n <testbed_name> [ -s <list of test cases or files to skip >] -u -c arp/test_arpall.py -C "not garp"
30
+ * execute all tests that don't have garp in the name in arp/test_arpall.py
31
+ * For more information on the filter, please refer to the [ pytest documentation] ( https://docs.pytest.org/en/latest/example/markers.html#using-k-expr-to-select-tests-based-on-their-name )
32
+
24
33
### Run scripts under a folder ###
25
34
* ./run_tests.sh -d <dut_name> -n <testbed_name> -u -c "snmp/test_ * .py" -s "snmp/test_snmp_cpu.py"
26
35
* execute all the scripts under ` snmp ` , skip script ` snmp/test_snmp_cpu.py ` .
Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ function setup_environment()
103
103
SKIP_FOLDERS=" ptftests acstests saitests scripts k8s sai_qualify"
104
104
TESTBED_FILE=" ${BASE_PATH} /ansible/testbed.yaml"
105
105
TEST_CASES=" "
106
+ TEST_FILTER=" "
106
107
TEST_INPUT_ORDER=" False"
107
108
TEST_METHOD=' group'
108
109
TEST_MAX_FAIL=0
@@ -193,6 +194,10 @@ function setup_test_options()
193
194
fi
194
195
done
195
196
197
+ if [[ ! -z $TEST_FILTER ]]; then
198
+ PYTEST_COMMON_OPTS=" ${PYTEST_COMMON_OPTS} -k ${TEST_FILTER} "
199
+ fi
200
+
196
201
if [[ -d ${LOG_PATH} ]]; then
197
202
rm -rf ${LOG_PATH}
198
203
fi
@@ -245,6 +250,7 @@ function run_debug_tests()
245
250
echo " SKIP_SCRIPTS: ${SKIP_SCRIPTS} "
246
251
echo " SKIP_FOLDERS: ${SKIP_FOLDERS} "
247
252
echo " TEST_CASES: ${TEST_CASES} "
253
+ echo " TEST_FILTER: ${TEST_FILTER} "
248
254
echo " TEST_INPUT_ORDER: ${TEST_INPUT_ORDER} "
249
255
echo " TEST_MAX_FAIL: ${TEST_MAX_FAIL} "
250
256
echo " TEST_METHOD: ${TEST_METHOD} "
@@ -348,7 +354,7 @@ function run_individual_tests()
348
354
setup_environment
349
355
350
356
351
- while getopts " h?a:b:c:d:e:Ef:i:I:k:l:m:n:oOp:q:rs:S:t:ux" opt; do
357
+ while getopts " h?a:b:c:C: d:e:Ef:i:I:k:l:m:n:oOp:q:rs:S:t:ux" opt; do
352
358
case ${opt} in
353
359
h|\? )
354
360
show_help_and_exit 0
@@ -363,6 +369,9 @@ while getopts "h?a:b:c:d:e:Ef:i:I:k:l:m:n:oOp:q:rs:S:t:ux" opt; do
363
369
c )
364
370
TEST_CASES=" ${TEST_CASES} ${OPTARG} "
365
371
;;
372
+ C )
373
+ TEST_FILTER=" ${TEST_FILTER} ${OPTARG} "
374
+ ;;
366
375
d )
367
376
DUT_NAME=${OPTARG}
368
377
;;
You can’t perform that action at this time.
0 commit comments