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

sysclt: Clarify the results of selftest run

In some cases the result of test were hidden inside the stdout and it
was difficult to identify when a test was skipped and why.

List of changes
1. Capitalize all the words that express a test result : "OK", "SKIPPED"
and "FAIL".
2. Place all test result text at the end of the message. This will
prevent the result from being hidden when stdout is verbose.
3. Any other explanation that comes after the result text will be placed
in a new line.
4. All failures are marked as "FAIL"
5. Pipped the failure to stderr in tests 8, 9, 10.
6. Replaced bogus "FAIL" with "SKIPPED" in test 0007
7. All "..." are prefixed and followed by a space.

Signed-off-by: Joel Granados <j.granados@samsung.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>

authored by

Joel Granados and committed by
Luis Chamberlain
ce023757 77774077

+62 -61
+62 -61
tools/testing/selftests/sysctl/sysctl.sh
··· 64 64 else 65 65 old_strict=$(cat ${WRITES_STRICT}) 66 66 if [ "$old_strict" = "1" ]; then 67 - echo "ok" 67 + echo "OK" 68 68 else 69 69 echo "FAIL, strict value is 0 but force to 1 to continue" >&2 70 70 echo "1" > ${WRITES_STRICT} ··· 226 226 echo "FAIL" >&2 227 227 exit 1 228 228 else 229 - echo "ok" 229 + echo "OK" 230 230 fi 231 231 232 232 echo -n "Checking sysctl is not set to test value ... " ··· 234 234 echo "FAIL" >&2 235 235 exit 1 236 236 else 237 - echo "ok" 237 + echo "OK" 238 238 fi 239 239 240 240 echo -n "Writing sysctl from shell ... " ··· 243 243 echo "FAIL" >&2 244 244 exit 1 245 245 else 246 - echo "ok" 246 + echo "OK" 247 247 fi 248 248 249 249 echo -n "Resetting sysctl to original value ... " ··· 252 252 echo "FAIL" >&2 253 253 exit 1 254 254 else 255 - echo "ok" 255 + echo "OK" 256 256 fi 257 257 258 258 # Now that we've validated the sanity of "set_test" and "set_orig", ··· 266 266 echo "FAIL" >&2 267 267 rc=1 268 268 else 269 - echo "ok" 269 + echo "OK" 270 270 fi 271 271 272 272 echo -n "Writing middle of sysctl after synchronized seek ... " ··· 276 276 echo "FAIL" >&2 277 277 rc=1 278 278 else 279 - echo "ok" 279 + echo "OK" 280 280 fi 281 281 282 282 echo -n "Writing beyond end of sysctl ... " ··· 286 286 echo "FAIL" >&2 287 287 rc=1 288 288 else 289 - echo "ok" 289 + echo "OK" 290 290 fi 291 291 292 292 echo -n "Writing sysctl with multiple long writes ... " ··· 297 297 echo "FAIL" >&2 298 298 rc=1 299 299 else 300 - echo "ok" 300 + echo "OK" 301 301 fi 302 302 test_rc 303 303 } 304 304 305 305 check_failure() 306 306 { 307 - echo -n "Testing that $1 fails as expected..." 307 + echo -n "Testing that $1 fails as expected ... " 308 308 reset_vals 309 309 TEST_STR="$1" 310 310 orig="$(cat $TARGET)" ··· 315 315 echo "FAIL" >&2 316 316 rc=1 317 317 else 318 - echo "ok" 318 + echo "OK" 319 319 fi 320 320 test_rc 321 321 } ··· 357 357 # Your test must accept digits 3 and 4 to use this 358 358 run_limit_digit() 359 359 { 360 - echo -n "Checking ignoring spaces up to PAGE_SIZE works on write ..." 360 + echo -n "Checking ignoring spaces up to PAGE_SIZE works on write ... " 361 361 reset_vals 362 362 363 363 LIMIT=$((MAX_DIGITS -1)) ··· 369 369 echo "FAIL" >&2 370 370 rc=1 371 371 else 372 - echo "ok" 372 + echo "OK" 373 373 fi 374 374 test_rc 375 375 376 - echo -n "Checking passing PAGE_SIZE of spaces fails on write ..." 376 + echo -n "Checking passing PAGE_SIZE of spaces fails on write ... " 377 377 reset_vals 378 378 379 379 LIMIT=$((MAX_DIGITS)) ··· 385 385 echo "FAIL" >&2 386 386 rc=1 387 387 else 388 - echo "ok" 388 + echo "OK" 389 389 fi 390 390 test_rc 391 391 } ··· 393 393 # You are using an int 394 394 run_limit_digit_int() 395 395 { 396 - echo -n "Testing INT_MAX works ..." 396 + echo -n "Testing INT_MAX works ... " 397 397 reset_vals 398 398 TEST_STR="$INT_MAX" 399 399 echo -n $TEST_STR > $TARGET ··· 402 402 echo "FAIL" >&2 403 403 rc=1 404 404 else 405 - echo "ok" 405 + echo "OK" 406 406 fi 407 407 test_rc 408 408 409 - echo -n "Testing INT_MAX + 1 will fail as expected..." 409 + echo -n "Testing INT_MAX + 1 will fail as expected ... " 410 410 reset_vals 411 411 let TEST_STR=$INT_MAX+1 412 412 echo -n $TEST_STR > $TARGET 2> /dev/null ··· 415 415 echo "FAIL" >&2 416 416 rc=1 417 417 else 418 - echo "ok" 418 + echo "OK" 419 419 fi 420 420 test_rc 421 421 422 - echo -n "Testing negative values will work as expected..." 422 + echo -n "Testing negative values will work as expected ... " 423 423 reset_vals 424 424 TEST_STR="-3" 425 425 echo -n $TEST_STR > $TARGET 2> /dev/null ··· 427 427 echo "FAIL" >&2 428 428 rc=1 429 429 else 430 - echo "ok" 430 + echo "OK" 431 431 fi 432 432 test_rc 433 433 } ··· 443 443 echo "FAIL" >&2 444 444 rc=1 445 445 else 446 - echo "ok" 446 + echo "OK" 447 447 fi 448 448 test_rc 449 449 ··· 460 460 echo "FAIL" >&2 461 461 rc=1 462 462 else 463 - echo "ok" 463 + echo "OK" 464 464 fi 465 465 test_rc 466 466 ··· 478 478 echo "FAIL" >&2 479 479 rc=1 480 480 else 481 - echo "ok" 481 + echo "OK" 482 482 fi 483 483 test_rc 484 484 ··· 495 495 echo "FAIL" >&2 496 496 rc=1 497 497 else 498 - echo "ok" 498 + echo "OK" 499 499 fi 500 500 test_rc 501 501 } ··· 503 503 # You are using an unsigned int 504 504 run_limit_digit_uint() 505 505 { 506 - echo -n "Testing UINT_MAX works ..." 506 + echo -n "Testing UINT_MAX works ... " 507 507 reset_vals 508 508 TEST_STR="$UINT_MAX" 509 509 echo -n $TEST_STR > $TARGET ··· 512 512 echo "FAIL" >&2 513 513 rc=1 514 514 else 515 - echo "ok" 515 + echo "OK" 516 516 fi 517 517 test_rc 518 518 519 - echo -n "Testing UINT_MAX + 1 will fail as expected..." 519 + echo -n "Testing UINT_MAX + 1 will fail as expected ... " 520 520 reset_vals 521 521 TEST_STR=$(($UINT_MAX+1)) 522 522 echo -n $TEST_STR > $TARGET 2> /dev/null ··· 525 525 echo "FAIL" >&2 526 526 rc=1 527 527 else 528 - echo "ok" 528 + echo "OK" 529 529 fi 530 530 test_rc 531 531 532 - echo -n "Testing negative values will not work as expected ..." 532 + echo -n "Testing negative values will not work as expected ... " 533 533 reset_vals 534 534 TEST_STR="-3" 535 535 echo -n $TEST_STR > $TARGET 2> /dev/null ··· 538 538 echo "FAIL" >&2 539 539 rc=1 540 540 else 541 - echo "ok" 541 + echo "OK" 542 542 fi 543 543 test_rc 544 544 } ··· 552 552 echo "FAIL" >&2 553 553 rc=1 554 554 else 555 - echo "ok" 555 + echo "OK" 556 556 fi 557 557 558 558 echo -n "Writing middle of sysctl after unsynchronized seek ... " ··· 562 562 echo "FAIL" >&2 563 563 rc=1 564 564 else 565 - echo "ok" 565 + echo "OK" 566 566 fi 567 567 568 568 echo -n "Checking sysctl maxlen is at least $MAXLEN ... " ··· 573 573 echo "FAIL" >&2 574 574 rc=1 575 575 else 576 - echo "ok" 576 + echo "OK" 577 577 fi 578 578 579 579 echo -n "Checking sysctl keeps original string on overflow append ... " ··· 584 584 echo "FAIL" >&2 585 585 rc=1 586 586 else 587 - echo "ok" 587 + echo "OK" 588 588 fi 589 589 590 590 echo -n "Checking sysctl stays NULL terminated on write ... " ··· 595 595 echo "FAIL" >&2 596 596 rc=1 597 597 else 598 - echo "ok" 598 + echo "OK" 599 599 fi 600 600 601 601 echo -n "Checking sysctl stays NULL terminated on overwrite ... " ··· 606 606 echo "FAIL" >&2 607 607 rc=1 608 608 else 609 - echo "ok" 609 + echo "OK" 610 610 fi 611 611 612 612 test_rc ··· 651 651 fi 652 652 done 653 653 654 - echo -n "Checking bitmap handler... " 654 + echo -n "Checking bitmap handler ... " 655 655 TEST_FILE=$(mktemp) 656 656 echo -n "$TEST_STR" > $TEST_FILE 657 657 ··· 666 666 echo "FAIL" >&2 667 667 rc=1 668 668 else 669 - echo "ok" 669 + echo "OK" 670 670 rc=0 671 671 fi 672 672 test_rc ··· 743 743 sysctl_test_0007() 744 744 { 745 745 TARGET="${SYSCTL}/$(get_test_target 0007)" 746 + echo -n "Testing if $TARGET is set to 1 ... " 747 + 746 748 if [ ! -f $TARGET ]; then 747 - echo "Skipping test for $TARGET as it is not present ..." 749 + echo -e "SKIPPING\n$TARGET is not present" 748 750 return $ksft_skip 749 751 fi 750 752 751 753 if [ -d $DIR ]; then 752 - echo "Boot param test only possible sysctl_test is built-in, not module:" 754 + echo -e "SKIPPING\nTest only possible if sysctl_test is built-in, not module:" 753 755 cat $TEST_DIR/config >&2 754 756 return $ksft_skip 755 757 fi 756 758 757 - echo -n "Testing if $TARGET is set to 1 ..." 758 759 ORIG=$(cat "${TARGET}") 759 760 760 761 if [ x$ORIG = "x1" ]; then 761 - echo "ok" 762 + echo "OK" 762 763 return 0 763 764 fi 764 - echo "FAIL" 765 - echo "Checking if /proc/cmdline contains setting of the expected parameter ..." 765 + 766 766 if [ ! -f /proc/cmdline ]; then 767 - echo "/proc/cmdline does not exist, test inconclusive" 768 - return 0 767 + echo -e "SKIPPING\nThere is no /proc/cmdline to check for paramter" 768 + return $ksft_skip 769 769 fi 770 770 771 771 FOUND=$(grep -c "sysctl[./]debug[./]test_sysctl[./]boot_int=1" /proc/cmdline) 772 772 if [ $FOUND = "1" ]; then 773 - echo "Kernel param found but $TARGET is not 1, TEST FAILED" 773 + echo -e "FAIL\nKernel param found but $TARGET is not 1." >&2 774 774 rc=1 775 775 test_rc 776 776 fi 777 777 778 - echo "Skipping test, expected kernel parameter missing." 779 - echo "To perform this test, make sure kernel is booted with parameter: sysctl.debug.test_sysctl.boot_int=1" 778 + echo -e "SKIPPING\nExpected kernel parameter missing." 779 + echo "Kernel must be booted with parameter: sysctl.debug.test_sysctl.boot_int=1" 780 780 return $ksft_skip 781 781 } 782 782 783 783 sysctl_test_0008() 784 784 { 785 785 TARGET="${SYSCTL}/$(get_test_target 0008)" 786 + echo -n "Testing if $TARGET is matched in kernel ... " 787 + 786 788 if [ ! -f $TARGET ]; then 787 - echo "Skipping test for $TARGET as it is not present ..." 789 + echo -e "SKIPPING\n$TARGET is not present" 788 790 return $ksft_skip 789 791 fi 790 792 791 - echo -n "Testing if $TARGET is matched in kernel" 792 793 ORIG_VALUE=$(cat "${TARGET}") 793 794 794 795 if [ $ORIG_VALUE -ne 1 ]; then 795 - echo "TEST FAILED" 796 + echo "FAIL" >&2 796 797 rc=1 797 798 test_rc 798 799 fi 799 800 800 - echo "ok" 801 + echo "OK" 801 802 return 0 802 803 } 803 804 804 805 sysctl_test_0009() 805 806 { 806 807 TARGET="${SYSCTL}/$(get_test_target 0009)" 807 - echo -n "Testing if $TARGET unregistered correctly ..." 808 + echo -n "Testing if $TARGET unregistered correctly ... " 808 809 if [ -d $TARGET ]; then 809 - echo "TEST FAILED" 810 + echo "FAIL" >&2 810 811 rc=1 811 812 test_rc 812 813 fi 813 814 814 - echo "ok" 815 + echo "OK" 815 816 return 0 816 817 } 817 818 818 819 sysctl_test_0010() 819 820 { 820 821 TARGET="${SYSCTL}/$(get_test_target 0010)" 821 - echo -n "Testing that $TARGET was not created ..." 822 + echo -n "Testing that $TARGET was not created ... " 822 823 if [ -d $TARGET ]; then 823 - echo "TEST FAILED" 824 + echo "FAIL" >&2 824 825 rc=1 825 826 test_rc 826 827 fi 827 828 828 - echo "ok" 829 + echo "OK" 829 830 return 0 830 831 } 831 832 ··· 958 957 if target_exists $TEST_TARGET $TEST_ID; then 959 958 TEST_SKIP=$(get_test_skip_no_target $TEST_ID) 960 959 if [[ $TEST_SKIP -eq "1" ]]; then 961 - echo "Target for test $TEST_ID: $TEST_TARGET not exist, skipping test ..." 960 + echo "Target $TEST_TARGET for test $TEST_ID does not exist ... SKIPPING" 962 961 return 0 963 962 fi 964 963 fi