diff options
author | Orson Zhai <orson.zhai@linaro.org> | 2017-06-26 20:52:09 -0400 |
---|---|---|
committer | Shuah Khan <shuahkh@osg.samsung.com> | 2017-06-27 20:57:02 -0400 |
commit | d644437a1dc6226afb7b8a814657961d8812f763 (patch) | |
tree | ebc2b66ea461f99acb82da3103ac82a88d35991e /tools | |
parent | fde662d9c3e09ba54273785de4e12628b7bd9de1 (diff) |
tools/testing/selftests/sysctl: Add pre-check to the value of writes_strict
Sysctl test will fail in some items if the value of /proc/sys/kernel
/sysctrl_writes_strict is 0 as the default value in kernel older than v4.5.
Make this test more robus and compatible with older kernel by checking and
update writes_strict value and restore it when test is done.
Signed-off-by: Orson Zhai <orson.zhai@linaro.org>
Reviewed-by: Sumit Semwal <sumit.semwal@linaro.org>
Tested-by: Sumit Semwal <sumit.semwal@linaro.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/sysctl/common_tests | 22 | ||||
-rwxr-xr-x | tools/testing/selftests/sysctl/run_numerictests | 2 | ||||
-rwxr-xr-x | tools/testing/selftests/sysctl/run_stringtests | 2 |
3 files changed, 24 insertions, 2 deletions
diff --git a/tools/testing/selftests/sysctl/common_tests b/tools/testing/selftests/sysctl/common_tests index 17d534b1b7b4..b6862322962f 100644 --- a/tools/testing/selftests/sysctl/common_tests +++ b/tools/testing/selftests/sysctl/common_tests | |||
@@ -24,6 +24,14 @@ verify() | |||
24 | return 0 | 24 | return 0 |
25 | } | 25 | } |
26 | 26 | ||
27 | exit_test() | ||
28 | { | ||
29 | if [ ! -z ${old_strict} ]; then | ||
30 | echo ${old_strict} > ${WRITES_STRICT} | ||
31 | fi | ||
32 | exit $rc | ||
33 | } | ||
34 | |||
27 | trap 'set_orig; rm -f "${TEST_FILE}"' EXIT | 35 | trap 'set_orig; rm -f "${TEST_FILE}"' EXIT |
28 | 36 | ||
29 | rc=0 | 37 | rc=0 |
@@ -63,6 +71,20 @@ else | |||
63 | echo "ok" | 71 | echo "ok" |
64 | fi | 72 | fi |
65 | 73 | ||
74 | echo -n "Checking write strict setting ... " | ||
75 | WRITES_STRICT="${SYSCTL}/kernel/sysctl_writes_strict" | ||
76 | if [ ! -e ${WRITES_STRICT} ]; then | ||
77 | echo "FAIL, but skip in case of old kernel" >&2 | ||
78 | else | ||
79 | old_strict=$(cat ${WRITES_STRICT}) | ||
80 | if [ "$old_strict" = "1" ]; then | ||
81 | echo "ok" | ||
82 | else | ||
83 | echo "FAIL, strict value is 0 but force to 1 to continue" >&2 | ||
84 | echo "1" > ${WRITES_STRICT} | ||
85 | fi | ||
86 | fi | ||
87 | |||
66 | # Now that we've validated the sanity of "set_test" and "set_orig", | 88 | # Now that we've validated the sanity of "set_test" and "set_orig", |
67 | # we can use those functions to set starting states before running | 89 | # we can use those functions to set starting states before running |
68 | # specific behavioral tests. | 90 | # specific behavioral tests. |
diff --git a/tools/testing/selftests/sysctl/run_numerictests b/tools/testing/selftests/sysctl/run_numerictests index 8510f93f2d14..e6e76c93d948 100755 --- a/tools/testing/selftests/sysctl/run_numerictests +++ b/tools/testing/selftests/sysctl/run_numerictests | |||
@@ -7,4 +7,4 @@ TEST_STR=$(( $ORIG + 1 )) | |||
7 | 7 | ||
8 | . ./common_tests | 8 | . ./common_tests |
9 | 9 | ||
10 | exit $rc | 10 | exit_test |
diff --git a/tools/testing/selftests/sysctl/run_stringtests b/tools/testing/selftests/sysctl/run_stringtests index 90a9293d520c..857ec667fb02 100755 --- a/tools/testing/selftests/sysctl/run_stringtests +++ b/tools/testing/selftests/sysctl/run_stringtests | |||
@@ -74,4 +74,4 @@ else | |||
74 | echo "ok" | 74 | echo "ok" |
75 | fi | 75 | fi |
76 | 76 | ||
77 | exit $rc | 77 | exit_test |