Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <ebiggers@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Luis Chamberlain <mcgrof@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jeff Vander Stoep <jeffv@google.com>
Cc: Jessica Yu <jeyu@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: NeilBrown <neilb@suse.com>
Link: http://lkml.kernel.org/r/20200318230515.171692-5-ebiggers@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Eric Biggers and committed by
Linus Torvalds
6d573a07 6e715825

+9 -4
+9 -4
tools/testing/selftests/kmod/kmod.sh
··· 505 505 fi 506 506 } 507 507 508 - function get_test_count() 508 + function get_test_data() 509 509 { 510 510 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) 512 518 LAST_TWO=${TEST_DATA#*:*} 513 519 echo ${LAST_TWO%:*} 514 520 } 515 521 516 522 function get_test_enabled() 517 523 { 518 - test_num $1 519 - TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$1'}') 524 + TEST_DATA=$(get_test_data $1) 520 525 echo ${TEST_DATA#*:*:} 521 526 } 522 527