File tree Expand file tree Collapse file tree 2 files changed +32
-31
lines changed
tools/testing/selftests/net/mptcp Expand file tree Collapse file tree 2 files changed +32
-31
lines changed Original file line number Diff line number Diff line change @@ -438,3 +438,33 @@ mptcp_lib_print_title() {
438
438
# shellcheck disable=SC2059 # the format is in a variable
439
439
printf " ${MPTCP_LIB_TEST_FORMAT} " " $(( ++ MPTCP_LIB_TEST_COUNTER)) " " ${* } "
440
440
}
441
+
442
+ # $1: var name ; $2: prev ret
443
+ mptcp_lib_check_expected_one () {
444
+ local var=" ${1} "
445
+ local exp=" e_${var} "
446
+ local prev_ret=" ${2} "
447
+
448
+ if [ " ${! var} " = " ${! exp} " ]; then
449
+ return 0
450
+ fi
451
+
452
+ if [ " ${prev_ret} " = " 0" ]; then
453
+ mptcp_lib_pr_fail
454
+ fi
455
+
456
+ mptcp_lib_print_err " Expected value for '${var} ': '${! exp} ', got '${! var} '."
457
+ return 1
458
+ }
459
+
460
+ # $@: all var names to check
461
+ mptcp_lib_check_expected () {
462
+ local rc=0
463
+ local var
464
+
465
+ for var in " ${@ } " ; do
466
+ mptcp_lib_check_expected_one " ${var} " " ${rc} " || rc=1
467
+ done
468
+
469
+ return " ${rc} "
470
+ }
Original file line number Diff line number Diff line change 5
5
# code but we accept it.
6
6
# shellcheck disable=SC2086
7
7
8
- # Some variables are used below but indirectly, see check_expected_one ()
8
+ # Some variables are used below but indirectly, see verify_*_event ()
9
9
# shellcheck disable=SC2034
10
10
11
11
. " $( dirname " ${0} " ) /mptcp_lib.sh"
@@ -228,39 +228,10 @@ make_connection()
228
228
fi
229
229
}
230
230
231
- # $1: var name ; $2: prev ret
232
- check_expected_one ()
233
- {
234
- local var=" ${1} "
235
- local exp=" e_${var} "
236
- local prev_ret=" ${2} "
237
-
238
- if [ " ${! var} " = " ${! exp} " ]
239
- then
240
- return 0
241
- fi
242
-
243
- if [ " ${prev_ret} " = " 0" ]
244
- then
245
- mptcp_lib_pr_fail
246
- fi
247
-
248
- mptcp_lib_print_err " \tExpected value for '${var} ': '${! exp} ', got '${! var} '."
249
- return 1
250
- }
251
-
252
231
# $@: all var names to check
253
232
check_expected ()
254
233
{
255
- local rc=0
256
- local var
257
-
258
- for var in " ${@ } "
259
- do
260
- check_expected_one " ${var} " " ${rc} " || rc=1
261
- done
262
-
263
- if [ ${rc} -eq 0 ]
234
+ if mptcp_lib_check_expected " ${@ } "
264
235
then
265
236
test_pass
266
237
return 0
You can’t perform that action at this time.
0 commit comments