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
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

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