Lines Matching +full:proc +full:- +full:id

12 # under the terms of copyleft-next (version 0.3.1 or later) as published
13 # at http://copyleft-next.org/.
15 # This performs a series tests against the proc sysctl interface.
17 # Kselftest framework requirement - SKIP code is 4.
29 # TEST_ID: is the test id number
34 # Once these are enabled please leave them as-is. Write your own test,
46 if [ -z $DIR ]; then
49 if [ -z $DEFAULT_NUM_TESTS ]; then
52 if [ -z $SYSCTL ]; then
53 SYSCTL="/proc/sys/debug/test_sysctl"
55 if [ -z $PROD_SYSCTL ]; then
56 PROD_SYSCTL="/proc/sys"
58 if [ -z $WRITES_STRICT ]; then
65 echo -n "Checking production write strict setting ... "
66 if [ ! -e ${WRITES_STRICT} ]; then
78 if [ -z $PAGE_SIZE ]; then
81 if [ -z $MAX_DIGITS ]; then
84 if [ -z $INT_MAX ]; then
87 if [ -z $UINT_MAX ]; then
94 uid=$(id -u)
95 if [ $uid -ne 0 ]; then
116 if [ ! -d $SYSCTL ]; then
117 if ! modprobe -q -n $TEST_DRIVER; then
123 if [ $? -ne 0 ]; then
153 echo -n $VAL > $TARGET
158 if [ ! -z $TARGET ] && [ ! -z $ORIG ]; then
159 if [ -f ${TARGET} ]; then
180 # proc files get read a page at a time, which can confuse diff,
181 # and get you incorrect results on proc files with long data. To use
189 if ! diff -w -q $TMP_DUMP_FILE $2; then
198 echo "$TEST_STR" | diff -q -w -u - $1 > /dev/null
213 rm -f "${TEST_FILE}"
215 if [ ! -z ${old_strict} ]; then
227 echo -n "Writing test file ... "
236 echo -n "Checking sysctl is not set to test value ... "
244 echo -n "Writing sysctl from shell ... "
253 echo -n "Resetting sysctl to original value ... "
266 echo -n "Writing entire sysctl in single write ... "
276 echo -n "Writing middle of sysctl after synchronized seek ... "
286 echo -n "Writing beyond end of sysctl ... "
296 echo -n "Writing sysctl with multiple long writes ... "
298 (perl -e 'print "A" x 50;'; echo "${TEST_STR}") | \
311 echo -n "Testing that $1 fails as expected..."
315 echo -n "$TEST_STR" > $TARGET 2> /dev/null
332 # none of these values fit in 32 bits, writing them to an int- or
333 # uint-typed sysctl should fail.
335 # common boundary-condition values (zero, +1, -1, INT_MIN,
344 # these look like negatives, but without a leading '-' are
346 # despite being zero/+1/-1/INT_MIN/INT_MAX in the lower 32)
354 for sign in '' '-'; do
364 echo -n "Checking ignoring spaces up to PAGE_SIZE works on write ..."
367 LIMIT=$((MAX_DIGITS -1))
369 (perl -e 'print " " x '$LIMIT';'; echo "${TEST_STR}") | \
380 echo -n "Checking passing PAGE_SIZE of spaces fails on write ..."
385 (perl -e 'print " " x '$LIMIT';'; echo "${TEST_STR}") | \
400 echo -n "Testing INT_MAX works ..."
403 echo -n $TEST_STR > $TARGET
413 echo -n "Testing INT_MAX + 1 will fail as expected..."
416 echo -n $TEST_STR > $TARGET 2> /dev/null
426 echo -n "Testing negative values will work as expected..."
428 TEST_STR="-3"
429 echo -n $TEST_STR > $TARGET 2> /dev/null
442 echo -n "Testing array works as expected ... "
444 echo -n $TEST_STR > $TARGET
454 echo -n "Testing skipping trailing array elements works ... "
458 echo -n $TEST_STR > $TARGET
471 echo -n "Testing PAGE_SIZE limit on array works ... "
475 LIMIT=$((MAX_DIGITS -1))
477 (perl -e 'print " " x '$LIMIT';'; echo "${TEST_STR}") | \
489 echo -n "Testing exceeding PAGE_SIZE limit fails as expected ... "
494 (perl -e 'print " " x '$LIMIT';'; echo "${TEST_STR}") | \
510 echo -n "Testing UINT_MAX works ..."
513 echo -n $TEST_STR > $TARGET
523 echo -n "Testing UINT_MAX + 1 will fail as expected..."
526 echo -n $TEST_STR > $TARGET 2> /dev/null
536 echo -n "Testing negative values will not work as expected ..."
538 TEST_STR="-3"
539 echo -n $TEST_STR > $TARGET 2> /dev/null
552 echo -n "Writing entire sysctl in short writes ... "
562 echo -n "Writing middle of sysctl after unsynchronized seek ... "
572 echo -n "Checking sysctl maxlen is at least $MAXLEN ... "
574 perl -e 'print "A" x ('"${MAXLEN}"'-2), "B";' | \
576 if ! grep -q B "${TARGET}"; then
583 echo -n "Checking sysctl keeps original string on overflow append ... "
585 perl -e 'print "A" x ('"${MAXLEN}"'-1), "B";' | \
586 dd of="${TARGET}" bs=$(( MAXLEN - 1 )) 2>/dev/null
587 if grep -q B "${TARGET}"; then
594 echo -n "Checking sysctl stays NULL terminated on write ... "
596 perl -e 'print "A" x ('"${MAXLEN}"'-1), "B";' | \
598 if grep -q B "${TARGET}"; then
605 echo -n "Checking sysctl stays NULL terminated on overwrite ... "
607 perl -e 'print "A" x ('"${MAXLEN}"'-1), "BB";' | \
609 if grep -q B "${TARGET}"; then
624 if [ ! -f ${TARGET} ] ; then
643 while [ "${#TEST_STR}" -le "$LENGTH" ]; do
652 if [ "$((RANDOM % 2))" -eq "1" ]; then
654 TEST_STR="${TEST_STR}-${RANGE_END}"
659 echo -n "Checking bitmap handler... "
661 echo -n "$TEST_STR" > $TEST_FILE
664 if [ $? -ne 0 ]; then
751 if [ ! -f $TARGET ]; then
756 if [ -d $DIR ]; then
757 echo "Boot param test only possible sysctl_test is built-in, not module:"
762 echo -n "Testing if $TARGET is set to 1 ..."
770 echo "Checking if /proc/cmdline contains setting of the expected parameter ..."
771 if [ ! -f /proc/cmdline ]; then
772 echo "/proc/cmdline does not exist, test inconclusive"
776 FOUND=$(grep -c "sysctl[./]debug[./]test_sysctl[./]boot_int=1" /proc/cmdline)
790 echo "Test ID list:"
793 echo "TEST_ID: Test ID"
796 echo "0001 x $(get_test_count 0001) - tests proc_dointvec_minmax()"
797 echo "0002 x $(get_test_count 0002) - tests proc_dostring()"
798 echo "0003 x $(get_test_count 0003) - tests proc_dointvec()"
799 echo "0004 x $(get_test_count 0004) - tests proc_douintvec()"
800 echo "0005 x $(get_test_count 0005) - tests proc_douintvec() array"
801 echo "0006 x $(get_test_count 0006) - tests proc_do_large_bitmap()"
802 echo "0007 x $(get_test_count 0007) - tests setting sysctl from kernel boot param"
807 NUM_TESTS=$(grep -o ' ' <<<"$ALL_TESTS" | grep -c .)
810 echo "Usage: $0 [ -t <4-number-digit> ] | [ -w <4-number-digit> ] |"
811 echo " [ -s <4-number-digit> ] | [ -c <4-number-digit> <test- count>"
812 echo " [ all ] [ -h | --help ] [ -l ]"
814 echo "Valid tests: 0001-$MAX_TEST"
817 echo " -t Run test ID the number amount of times is recommended"
818 echo " -w Watch test ID run until it runs into an error"
819 echo " -c Run test ID once"
820 echo " -s Run test ID x test-count number of times"
821 echo " -l List all test ID list"
822 echo " -h|--help Help"
825 echo "If you are adding a new test try using -w <test-ID> first to"
830 echo "$TEST_NAME.sh -- executes all tests"
831 echo "$TEST_NAME.sh -t 0002 -- Executes test ID 0002 number of times is recomended"
832 echo "$TEST_NAME.sh -w 0002 -- Watch test ID 0002 run until an error occurs"
833 echo "$TEST_NAME.sh -s 0002 -- Run test ID 0002 once"
834 echo "$TEST_NAME.sh -c 0002 3 -- Run test ID 0002 three times"
842 re='^[0-9]+$'
852 echo ${TEST_DATA} | awk -F":" '{print $2}'
859 echo ${TEST_DATA} | awk -F":" '{print $3}'
866 echo ${TEST_DATA} | awk -F":" '{print $4}'
879 if [[ $ENABLED -eq "1" ]]; then
887 if [ $# -ne 3 ]; then
891 echo "Running test: $2 - run #$1"
899 if [ $# -eq 1 ]; then
921 while [ $i -lt $NUM_TESTS ]; do
932 if [ $# -eq 0 ]; then
937 elif [[ "$1" = "-w" ]]; then
940 elif [[ "$1" = "-t" ]]; then
944 elif [[ "$1" = "-c" ]]; then
949 elif [[ "$1" = "-s" ]]; then
952 elif [[ "$1" = "-l" ]]; then
954 elif [[ "$1" = "-h" || "$1" = "--help" ]]; then