Skip to content

Commit 758a9ee

Browse files
pmachataNipaLocal
authored andcommitted
selftests: forwarding: lib: Move require_command to net, generalize
This helper could be useful to more than just forwarding tests. Move it upstairs and port over to log_test_skip(). Split the function into two parts: the bit that actually checks and reports skip, which is in a new function check_command(). And a bit that exits the test script if the check fails. This allows users consistent checking behavior while giving an option to bail out from a single test without bailing out of the whole script. Signed-off-by: Petr Machata <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 11fea34 commit 758a9ee

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

tools/testing/selftests/net/forwarding/lib.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,6 @@ if [[ "$CHECK_TC" = "yes" ]]; then
291291
check_tc_version
292292
fi
293293

294-
require_command()
295-
{
296-
local cmd=$1; shift
297-
298-
if [[ ! -x "$(command -v "$cmd")" ]]; then
299-
echo "SKIP: $cmd not installed"
300-
exit $ksft_skip
301-
fi
302-
}
303-
304294
# IPv6 support was added in v3.0
305295
check_mtools_version()
306296
{

tools/testing/selftests/net/lib.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,25 @@ kill_process()
450450
{ kill $pid && wait $pid; } 2>/dev/null
451451
}
452452

453+
check_command()
454+
{
455+
local cmd=$1; shift
456+
457+
if [[ ! -x "$(command -v "$cmd")" ]]; then
458+
log_test_skip "$cmd not installed"
459+
return $EXIT_STATUS
460+
fi
461+
}
462+
463+
require_command()
464+
{
465+
local cmd=$1; shift
466+
467+
if ! check_command "$cmd"; then
468+
exit $EXIT_STATUS
469+
fi
470+
}
471+
453472
ip_link_add()
454473
{
455474
local name=$1; shift

0 commit comments

Comments
 (0)