summaryrefslogtreecommitdiffstats
path: root/testsuite/sysctl.test/sysctl_read.exp
blob: c55cd95fe6238c9df83c0c8d77f8bb5c526ba0dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#
# Dejagnu tests for sysctl (read only) - part of procps
#
set sysctl ${topdir}src/sysctl
set hostname [ exec cat "/proc/sys/kernel/hostname" ]

set test "sysctl with no arguments"
spawn $sysctl
expect_pass "$test" "^\\s+Usage:\\s+\(lt-\)?sysctl \\\[options\\\] \\\[variable\\\[=value\\\] \.\.\.\\\]"

set test "sysctl reading a variable using slash delimiter"
spawn $sysctl kernel/hostname
expect_pass "$test" "kernel.hostname = ${hostname}"

set test "sysctl reading a variable using dot delimiter"
spawn $sysctl kernel.hostname
expect_pass "$test" "kernel.hostname = ${hostname}"

set test "sysctl reading a variable suppress key"
spawn $sysctl -n kernel.hostname
expect_pass "$test" "${hostname}"

set test "sysctl reading a variable suppress value"
spawn $sysctl -N kernel.hostname
expect_pass "$test" "kernel.hostname"

set test "sysctl reading using a path traversal"
spawn $sysctl /../../etc/passwd
expect_pass "$test" "sysctl: Path is not under /proc/sys/: /proc/sys//../../etc/passwd"