History

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.

Eric Biggers committed 6 years ago

Commit 6d573a01 parent 6e715821 file · +9 −4Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t