Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[linux/fpc-iii.git] / tools / testing / selftests / sysctl / run_stringtests
blob90a9293d520cbb624c80a3e3b36e7dc3c1cfac38
1 #!/bin/sh
3 SYSCTL="/proc/sys"
4 TARGET="${SYSCTL}/kernel/domainname"
5 ORIG=$(cat "${TARGET}")
6 TEST_STR="Testing sysctl"
8 . ./common_tests
10 # Only string sysctls support seeking/appending.
11 MAXLEN=65
13 echo -n "Writing entire sysctl in short writes ... "
14 set_orig
15 dd if="${TEST_FILE}" of="${TARGET}" bs=1 2>/dev/null
16 if ! verify "${TARGET}"; then
17 echo "FAIL" >&2
18 rc=1
19 else
20 echo "ok"
23 echo -n "Writing middle of sysctl after unsynchronized seek ... "
24 set_test
25 dd if="${TEST_FILE}" of="${TARGET}" bs=1 seek=1 2>/dev/null
26 if verify "${TARGET}"; then
27 echo "FAIL" >&2
28 rc=1
29 else
30 echo "ok"
33 echo -n "Checking sysctl maxlen is at least $MAXLEN ... "
34 set_orig
35 perl -e 'print "A" x ('"${MAXLEN}"'-2), "B";' | \
36 dd of="${TARGET}" bs="${MAXLEN}" 2>/dev/null
37 if ! grep -q B "${TARGET}"; then
38 echo "FAIL" >&2
39 rc=1
40 else
41 echo "ok"
44 echo -n "Checking sysctl keeps original string on overflow append ... "
45 set_orig
46 perl -e 'print "A" x ('"${MAXLEN}"'-1), "B";' | \
47 dd of="${TARGET}" bs=$(( MAXLEN - 1 )) 2>/dev/null
48 if grep -q B "${TARGET}"; then
49 echo "FAIL" >&2
50 rc=1
51 else
52 echo "ok"
55 echo -n "Checking sysctl stays NULL terminated on write ... "
56 set_orig
57 perl -e 'print "A" x ('"${MAXLEN}"'-1), "B";' | \
58 dd of="${TARGET}" bs="${MAXLEN}" 2>/dev/null
59 if grep -q B "${TARGET}"; then
60 echo "FAIL" >&2
61 rc=1
62 else
63 echo "ok"
66 echo -n "Checking sysctl stays NULL terminated on overwrite ... "
67 set_orig
68 perl -e 'print "A" x ('"${MAXLEN}"'-1), "BB";' | \
69 dd of="${TARGET}" bs=$(( $MAXLEN + 1 )) 2>/dev/null
70 if grep -q B "${TARGET}"; then
71 echo "FAIL" >&2
72 rc=1
73 else
74 echo "ok"
77 exit $rc