diff options
Diffstat (limited to 'tools/testing/selftests/sysctl/sysctl.sh')
| -rw-r--r-- | tools/testing/selftests/sysctl/sysctl.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh index 6ec807576f7c..7ba3fa2bbd54 100644 --- a/tools/testing/selftests/sysctl/sysctl.sh +++ b/tools/testing/selftests/sysctl/sysctl.sh | |||
| @@ -31,6 +31,7 @@ TEST_FILE=$(mktemp) | |||
| 31 | # we have tons of space. | 31 | # we have tons of space. |
| 32 | ALL_TESTS="0001:1:1" | 32 | ALL_TESTS="0001:1:1" |
| 33 | ALL_TESTS="$ALL_TESTS 0002:1:1" | 33 | ALL_TESTS="$ALL_TESTS 0002:1:1" |
| 34 | ALL_TESTS="$ALL_TESTS 0003:1:1" | ||
| 34 | 35 | ||
| 35 | test_modprobe() | 36 | test_modprobe() |
| 36 | { | 37 | { |
| @@ -82,6 +83,9 @@ function check_production_sysctl_writes_strict() | |||
| 82 | if [ -z $MAX_DIGITS ]; then | 83 | if [ -z $MAX_DIGITS ]; then |
| 83 | MAX_DIGITS=$(($PAGE_SIZE/8)) | 84 | MAX_DIGITS=$(($PAGE_SIZE/8)) |
| 84 | fi | 85 | fi |
| 86 | if [ -z $INT_MAX ]; then | ||
| 87 | INT_MAX=$(getconf INT_MAX) | ||
| 88 | fi | ||
| 85 | } | 89 | } |
| 86 | 90 | ||
| 87 | test_reqs() | 91 | test_reqs() |
| @@ -122,6 +126,9 @@ reset_vals() | |||
| 122 | int_0001) | 126 | int_0001) |
| 123 | VAL="60" | 127 | VAL="60" |
| 124 | ;; | 128 | ;; |
| 129 | int_0002) | ||
| 130 | VAL="1" | ||
| 131 | ;; | ||
| 125 | string_0001) | 132 | string_0001) |
| 126 | VAL="(none)" | 133 | VAL="(none)" |
| 127 | ;; | 134 | ;; |
| @@ -296,6 +303,48 @@ run_limit_digit() | |||
| 296 | test_rc | 303 | test_rc |
| 297 | } | 304 | } |
| 298 | 305 | ||
| 306 | # You are using an int | ||
| 307 | run_limit_digit_int() | ||
| 308 | { | ||
| 309 | echo -n "Testing INT_MAX works ..." | ||
| 310 | reset_vals | ||
| 311 | TEST_STR="$INT_MAX" | ||
| 312 | echo -n $TEST_STR > $TARGET | ||
| 313 | |||
| 314 | if ! verify "${TARGET}"; then | ||
| 315 | echo "FAIL" >&2 | ||
| 316 | rc=1 | ||
| 317 | else | ||
| 318 | echo "ok" | ||
| 319 | fi | ||
| 320 | test_rc | ||
| 321 | |||
| 322 | echo -n "Testing INT_MAX + 1 will fail as expected..." | ||
| 323 | reset_vals | ||
| 324 | let TEST_STR=$INT_MAX+1 | ||
| 325 | echo -n $TEST_STR > $TARGET 2> /dev/null | ||
| 326 | |||
| 327 | if verify "${TARGET}"; then | ||
| 328 | echo "FAIL" >&2 | ||
| 329 | rc=1 | ||
| 330 | else | ||
| 331 | echo "ok" | ||
| 332 | fi | ||
| 333 | test_rc | ||
| 334 | |||
| 335 | echo -n "Testing negative values will work as expected..." | ||
| 336 | reset_vals | ||
| 337 | TEST_STR="-3" | ||
| 338 | echo -n $TEST_STR > $TARGET 2> /dev/null | ||
| 339 | if ! verify "${TARGET}"; then | ||
| 340 | echo "FAIL" >&2 | ||
| 341 | rc=1 | ||
| 342 | else | ||
| 343 | echo "ok" | ||
| 344 | fi | ||
| 345 | test_rc | ||
| 346 | } | ||
| 347 | |||
| 299 | run_stringtests() | 348 | run_stringtests() |
| 300 | { | 349 | { |
| 301 | echo -n "Writing entire sysctl in short writes ... " | 350 | echo -n "Writing entire sysctl in short writes ... " |
| @@ -389,6 +438,18 @@ sysctl_test_0002() | |||
| 389 | run_stringtests | 438 | run_stringtests |
| 390 | } | 439 | } |
| 391 | 440 | ||
| 441 | sysctl_test_0003() | ||
| 442 | { | ||
| 443 | TARGET="${SYSCTL}/int_0002" | ||
| 444 | reset_vals | ||
| 445 | ORIG=$(cat "${TARGET}") | ||
| 446 | TEST_STR=$(( $ORIG + 1 )) | ||
| 447 | |||
| 448 | run_numerictests | ||
| 449 | run_limit_digit | ||
| 450 | run_limit_digit_int | ||
| 451 | } | ||
| 452 | |||
| 392 | list_tests() | 453 | list_tests() |
| 393 | { | 454 | { |
| 394 | echo "Test ID list:" | 455 | echo "Test ID list:" |
| @@ -399,6 +460,7 @@ list_tests() | |||
| 399 | echo | 460 | echo |
| 400 | echo "0001 x $(get_test_count 0001) - tests proc_dointvec_minmax()" | 461 | echo "0001 x $(get_test_count 0001) - tests proc_dointvec_minmax()" |
| 401 | echo "0002 x $(get_test_count 0002) - tests proc_dostring()" | 462 | echo "0002 x $(get_test_count 0002) - tests proc_dostring()" |
| 463 | echo "0003 x $(get_test_count 0003) - tests proc_dointvec()" | ||
| 402 | } | 464 | } |
| 403 | 465 | ||
| 404 | test_reqs | 466 | test_reqs |
