Skip to content

Commit 6d573a0

Browse files
ebiggerstorvalds
authored andcommitted
selftests: kmod: fix handling test numbers above 9
get_test_count() and get_test_enabled() were broken for test numbers above 9 due to awk interpreting a field specification like '$0010' as octal rather than decimal. Fix it by stripping the leading zeroes. Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Luis Chamberlain <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Jeff Vander Stoep <[email protected]> Cc: Jessica Yu <[email protected]> Cc: Kees Cook <[email protected]> Cc: NeilBrown <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 6e71582 commit 6d573a0

File tree

1 file changed

+9
-4
lines changed
  • tools/testing/selftests/kmod

1 file changed

+9
-4
lines changed

tools/testing/selftests/kmod/kmod.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,18 +505,23 @@ function test_num()
505505
fi
506506
}
507507

508-
function get_test_count()
508+
function get_test_data()
509509
{
510510
test_num $1
511-
TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$1'}')
511+
local field_num=$(echo $1 | sed 's/^0*//')
512+
echo $ALL_TESTS | awk '{print $'$field_num'}'
513+
}
514+
515+
function get_test_count()
516+
{
517+
TEST_DATA=$(get_test_data $1)
512518
LAST_TWO=${TEST_DATA#*:*}
513519
echo ${LAST_TWO%:*}
514520
}
515521

516522
function get_test_enabled()
517523
{
518-
test_num $1
519-
TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$1'}')
524+
TEST_DATA=$(get_test_data $1)
520525
echo ${TEST_DATA#*:*:}
521526
}
522527

0 commit comments

Comments
 (0)