summaryrefslogtreecommitdiffstats
path: root/testsuite/sysctl.test/sysctl_read.exp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 20:34:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 20:34:44 +0000
commite3be059d4da38aa36f1aee1d56f8ceb943d92f1c (patch)
tree26edef31e4e503dd1c92a112de174f366dd61802 /testsuite/sysctl.test/sysctl_read.exp
parentInitial commit. (diff)
downloadprocps-e3be059d4da38aa36f1aee1d56f8ceb943d92f1c.tar.xz
procps-e3be059d4da38aa36f1aee1d56f8ceb943d92f1c.zip
Adding upstream version 2:4.0.4.upstream/2%4.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testsuite/sysctl.test/sysctl_read.exp')
-rw-r--r--testsuite/sysctl.test/sysctl_read.exp29
1 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/sysctl.test/sysctl_read.exp b/testsuite/sysctl.test/sysctl_read.exp
new file mode 100644
index 0000000..c55cd95
--- /dev/null
+++ b/testsuite/sysctl.test/sysctl_read.exp
@@ -0,0 +1,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"