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>
This commit is contained in:
Joel Granados 2023-11-21 12:02:20 +01:00 committed by Luis Chamberlain
parent 777740779e
commit ce02375784

View File

@ -64,7 +64,7 @@ function check_production_sysctl_writes_strict()
else
old_strict=$(cat ${WRITES_STRICT})
if [ "$old_strict" = "1" ]; then
echo "ok"
echo "OK"
else
echo "FAIL, strict value is 0 but force to 1 to continue" >&2
echo "1" > ${WRITES_STRICT}
@ -226,7 +226,7 @@ run_numerictests()
echo "FAIL" >&2
exit 1
else
echo "ok"
echo "OK"
fi
echo -n "Checking sysctl is not set to test value ... "
@ -234,7 +234,7 @@ run_numerictests()
echo "FAIL" >&2
exit 1
else
echo "ok"
echo "OK"
fi
echo -n "Writing sysctl from shell ... "
@ -243,7 +243,7 @@ run_numerictests()
echo "FAIL" >&2
exit 1
else
echo "ok"
echo "OK"
fi
echo -n "Resetting sysctl to original value ... "
@ -252,7 +252,7 @@ run_numerictests()
echo "FAIL" >&2
exit 1
else
echo "ok"
echo "OK"
fi
# Now that we've validated the sanity of "set_test" and "set_orig",
@ -266,7 +266,7 @@ run_numerictests()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
echo -n "Writing middle of sysctl after synchronized seek ... "
@ -276,7 +276,7 @@ run_numerictests()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
echo -n "Writing beyond end of sysctl ... "
@ -286,7 +286,7 @@ run_numerictests()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
echo -n "Writing sysctl with multiple long writes ... "
@ -297,7 +297,7 @@ run_numerictests()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
}
@ -315,7 +315,7 @@ check_failure()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
}
@ -369,7 +369,7 @@ run_limit_digit()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
@ -385,7 +385,7 @@ run_limit_digit()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
}
@ -402,7 +402,7 @@ run_limit_digit_int()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
@ -415,7 +415,7 @@ run_limit_digit_int()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
@ -427,7 +427,7 @@ run_limit_digit_int()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
}
@ -443,7 +443,7 @@ run_limit_digit_int_array()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
@ -460,7 +460,7 @@ run_limit_digit_int_array()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
@ -478,7 +478,7 @@ run_limit_digit_int_array()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
@ -495,7 +495,7 @@ run_limit_digit_int_array()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
}
@ -512,7 +512,7 @@ run_limit_digit_uint()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
@ -525,7 +525,7 @@ run_limit_digit_uint()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
@ -538,7 +538,7 @@ run_limit_digit_uint()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
}
@ -552,7 +552,7 @@ run_stringtests()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
echo -n "Writing middle of sysctl after unsynchronized seek ... "
@ -562,7 +562,7 @@ run_stringtests()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
echo -n "Checking sysctl maxlen is at least $MAXLEN ... "
@ -573,7 +573,7 @@ run_stringtests()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
echo -n "Checking sysctl keeps original string on overflow append ... "
@ -584,7 +584,7 @@ run_stringtests()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
echo -n "Checking sysctl stays NULL terminated on write ... "
@ -595,7 +595,7 @@ run_stringtests()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
echo -n "Checking sysctl stays NULL terminated on overwrite ... "
@ -606,7 +606,7 @@ run_stringtests()
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
fi
test_rc
@ -666,7 +666,7 @@ run_bitmaptest() {
echo "FAIL" >&2
rc=1
else
echo "ok"
echo "OK"
rc=0
fi
test_rc
@ -743,61 +743,62 @@ sysctl_test_0006()
sysctl_test_0007()
{
TARGET="${SYSCTL}/$(get_test_target 0007)"
echo -n "Testing if $TARGET is set to 1 ... "
if [ ! -f $TARGET ]; then
echo "Skipping test for $TARGET as it is not present ..."
echo -e "SKIPPING\n$TARGET is not present"
return $ksft_skip
fi
if [ -d $DIR ]; then
echo "Boot param test only possible sysctl_test is built-in, not module:"
echo -e "SKIPPING\nTest only possible if sysctl_test is built-in, not module:"
cat $TEST_DIR/config >&2
return $ksft_skip
fi
echo -n "Testing if $TARGET is set to 1 ..."
ORIG=$(cat "${TARGET}")
if [ x$ORIG = "x1" ]; then
echo "ok"
echo "OK"
return 0
fi
echo "FAIL"
echo "Checking if /proc/cmdline contains setting of the expected parameter ..."
if [ ! -f /proc/cmdline ]; then
echo "/proc/cmdline does not exist, test inconclusive"
return 0
echo -e "SKIPPING\nThere is no /proc/cmdline to check for paramter"
return $ksft_skip
fi
FOUND=$(grep -c "sysctl[./]debug[./]test_sysctl[./]boot_int=1" /proc/cmdline)
if [ $FOUND = "1" ]; then
echo "Kernel param found but $TARGET is not 1, TEST FAILED"
echo -e "FAIL\nKernel param found but $TARGET is not 1." >&2
rc=1
test_rc
fi
echo "Skipping test, expected kernel parameter missing."
echo "To perform this test, make sure kernel is booted with parameter: sysctl.debug.test_sysctl.boot_int=1"
echo -e "SKIPPING\nExpected kernel parameter missing."
echo "Kernel must be booted with parameter: sysctl.debug.test_sysctl.boot_int=1"
return $ksft_skip
}
sysctl_test_0008()
{
TARGET="${SYSCTL}/$(get_test_target 0008)"
echo -n "Testing if $TARGET is matched in kernel ... "
if [ ! -f $TARGET ]; then
echo "Skipping test for $TARGET as it is not present ..."
echo -e "SKIPPING\n$TARGET is not present"
return $ksft_skip
fi
echo -n "Testing if $TARGET is matched in kernel"
ORIG_VALUE=$(cat "${TARGET}")
if [ $ORIG_VALUE -ne 1 ]; then
echo "TEST FAILED"
echo "FAIL" >&2
rc=1
test_rc
fi
echo "ok"
echo "OK"
return 0
}
@ -806,12 +807,12 @@ sysctl_test_0009()
TARGET="${SYSCTL}/$(get_test_target 0009)"
echo -n "Testing if $TARGET unregistered correctly ... "
if [ -d $TARGET ]; then
echo "TEST FAILED"
echo "FAIL" >&2
rc=1
test_rc
fi
echo "ok"
echo "OK"
return 0
}
@ -820,12 +821,12 @@ sysctl_test_0010()
TARGET="${SYSCTL}/$(get_test_target 0010)"
echo -n "Testing that $TARGET was not created ... "
if [ -d $TARGET ]; then
echo "TEST FAILED"
echo "FAIL" >&2
rc=1
test_rc
fi
echo "ok"
echo "OK"
return 0
}
@ -957,7 +958,7 @@ function skip_test()
if target_exists $TEST_TARGET $TEST_ID; then
TEST_SKIP=$(get_test_skip_no_target $TEST_ID)
if [[ $TEST_SKIP -eq "1" ]]; then
echo "Target for test $TEST_ID: $TEST_TARGET not exist, skipping test ..."
echo "Target $TEST_TARGET for test $TEST_ID does not exist ... SKIPPING"
return 0
fi
fi