summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKarel Zak2007-01-03 01:07:55 +0100
committerKarel Zak2007-01-04 14:53:57 +0100
commitb30cd7eed5b70c5eaf08f8681eb3f717c4d11329 (patch)
tree27343c827a816540244fd213fccaa95182f79653 /tests
parenttests: add simple helper that returns info about system (diff)
downloadkernel-qcow2-util-linux-b30cd7eed5b70c5eaf08f8681eb3f717c4d11329.tar.gz
kernel-qcow2-util-linux-b30cd7eed5b70c5eaf08f8681eb3f717c4d11329.tar.xz
kernel-qcow2-util-linux-b30cd7eed5b70c5eaf08f8681eb3f717c4d11329.zip
ipcs: add new tests for ipcs limits
The tests check if data from kernel and from the ipcs command are same. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/expected/ts-ipcs-limits11
-rw-r--r--tests/expected/ts-ipcs-limits24
-rw-r--r--tests/functions.sh11
-rwxr-xr-xtests/run.sh2
-rwxr-xr-xtests/ts-ipcs-limits43
-rwxr-xr-xtests/ts-ipcs-limits220
-rw-r--r--tests/ts-ipcs.sh72
8 files changed, 166 insertions, 3 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ff516ede4..eebb700b7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,8 +6,12 @@ EXTRA_DIST = commands.sh.in \
functions.sh \
ts-mount-paths \
ts-ipcs-headers \
+ ts-ipcs-limits \
+ ts-ipcs-limits2 \
expected/ts-mount-paths \
- expected/ts-ipcs-headers
+ expected/ts-ipcs-headers \
+ expected/ts-ipcs-limits \
+ expected/ts-ipcs-limits2
distclean-local:
rm -rf output diff
diff --git a/tests/expected/ts-ipcs-limits b/tests/expected/ts-ipcs-limits
new file mode 100644
index 000000000..7480a1e27
--- /dev/null
+++ b/tests/expected/ts-ipcs-limits
@@ -0,0 +1,11 @@
+load original values
+check for difference between kernel and IPC
+/proc/sys/kernel/shmmni OK
+/proc/sys/kernel/shmall OK
+/proc/sys/kernel/shmmax OK
+maximalize kernel setting
+re-check for difference between kernel and IPC
+/proc/sys/kernel/shmmni OK
+/proc/sys/kernel/shmall OK
+/proc/sys/kernel/shmmax OK
+write original values to kernel
diff --git a/tests/expected/ts-ipcs-limits2 b/tests/expected/ts-ipcs-limits2
new file mode 100644
index 000000000..28454e358
--- /dev/null
+++ b/tests/expected/ts-ipcs-limits2
@@ -0,0 +1,4 @@
+check for difference between kernel and IPC
+/proc/sys/kernel/shmmni OK
+/proc/sys/kernel/shmall OK
+/proc/sys/kernel/shmmax OK
diff --git a/tests/functions.sh b/tests/functions.sh
index 2a18ef583..81168fc32 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -3,6 +3,11 @@ TS_OUTDIR="$TS_TOPDIR/output"
TS_DIFFDIR="$TS_TOPDIR/diff"
TS_EXPECTEDDIR="$TS_TOPDIR/expected"
+function ts_skip {
+ echo " IGNORE ($1)"
+ exit 0
+}
+
function ts_init {
TS_NAME=$(basename $0)
if [ ! -d $TS_OUTDIR ]; then
@@ -37,7 +42,11 @@ function ts_finalize {
exit 0
fi
if [ $res -eq 0 ]; then
- echo " OK"
+ if [ x"$1" == x"" ]; then
+ echo " OK"
+ else
+ echo " OK ($1)"
+ fi
exit 0
else
echo " FAILED ($TS_NAME)"
diff --git a/tests/run.sh b/tests/run.sh
index 275b68733..feb0089ff 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -10,7 +10,7 @@ rm -f *~
res=0
count=0
-for ts in `ls ts-*`; do
+for ts in $(find -maxdepth 1 -regex "\./ts[^\.~]*" | sort); do
$TS_TOPDIR/$ts
res=$(( $res + $? ))
count=$(( $count + 1 ))
diff --git a/tests/ts-ipcs-limits b/tests/ts-ipcs-limits
new file mode 100755
index 000000000..542819f16
--- /dev/null
+++ b/tests/ts-ipcs-limits
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+. commands.sh
+. functions.sh
+
+TS_COMPONENT="ipcs"
+TS_DESC="limits overflow"
+
+if [ $UID != 0 ]; then
+ ts_init
+ ts_skip "not root permissions"
+fi
+
+. ts-ipcs.sh
+
+ts_init
+
+(
+ echo "load original values"
+ for i in $IPCS_IDX; do
+ SHM_ORG[$i]=$(cat ${IPCS_PROCFILES[$i]})
+ done
+
+ echo "check for difference between kernel and IPC"
+ ipcs_limits_check
+
+ echo "maximalize kernel setting"
+ for i in $IPCS_IDX; do
+ echo ${IPCS_LIMITS[$i]} >> ${IPCS_PROCFILES[$i]}
+ done
+
+ echo "re-check for difference between kernel and IPC"
+ ipcs_limits_check
+
+ echo "write original values to kernel"
+ for i in $IPCS_IDX; do
+ echo ${SHM_ORG[$i]} >> ${IPCS_PROCFILES[$i]}
+ done
+
+) > $TS_OUTPUT
+
+ts_finalize
+
diff --git a/tests/ts-ipcs-limits2 b/tests/ts-ipcs-limits2
new file mode 100755
index 000000000..59e10d4fe
--- /dev/null
+++ b/tests/ts-ipcs-limits2
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+. commands.sh
+. functions.sh
+
+TS_COMPONENT="ipcs"
+TS_DESC="basic limits"
+
+. ts-ipcs.sh
+
+ts_init
+
+(
+ echo "check for difference between kernel and IPC"
+ ipcs_limits_check
+
+) > $TS_OUTPUT
+
+ts_finalize
+
diff --git a/tests/ts-ipcs.sh b/tests/ts-ipcs.sh
new file mode 100644
index 000000000..9f9e119c2
--- /dev/null
+++ b/tests/ts-ipcs.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+if [ ! -f "/proc/sys/kernel/shmall" ]; then
+ ts_init
+ ts_skip "not IPC in kernel"
+fi
+
+PAGE_SIZE=$($TS_HELPER_SYSINFO pagesize)
+
+# kernel files
+IPCS_PROCFILES=(
+ /proc/sys/kernel/shmmni
+ /proc/sys/kernel/shmall
+ /proc/sys/kernel/shmmax
+)
+
+# raw data converted to ipcs-like format
+# shmmni = same
+# shmall = from pages to KBytes
+# shmmax = from bytes to KBytes
+#
+IPCS_KERNEL_CMD=(
+ "cat /proc/sys/kernel/shmmni"
+ "echo \$(cat /proc/sys/kernel/shmall) / 1024 \* $PAGE_SIZE | bc -l | sed 's/\..*//'"
+ "echo \$(cat /proc/sys/kernel/shmmax) / 1024 | bc -l | sed 's/\..*//'"
+)
+
+# data from the ipcs command
+IPCS_CMD=(
+ "$TS_CMD_IPCS -m -l | gawk '/max number of segments/ { print \$6 }'"
+ "$TS_CMD_IPCS -m -l | gawk '/max total shared memory/ { print \$7 }'"
+ "$TS_CMD_IPCS -m -l | gawk '/max seg size/ { print \$6 }'"
+)
+
+
+# The linux kernel accepts ULONG_MAX, but this value is same like ULLONG_MAX on
+# 64-bit archs. So the ipcs command has to always overflow on 64-bit archs when
+# shmall (=num of pages!) is same or almost same like ULONG_MAX. This is reason
+# why we for the test uses 32-bit limits on all archs.
+#
+# (Don't worry that 64-bit ULONG_MAX makes ipcs useless ...
+# ... it's a problem for admins who want to use 75557863725TB of RAM for shm)
+#
+IPCS_LIMITS=(
+ $($TS_HELPER_SYSINFO INT_MAX)
+ $($TS_HELPER_SYSINFO ULONG_MAX32)
+ $($TS_HELPER_SYSINFO ULONG_MAX32)
+)
+
+# list of indexes = 0..(sizeof Array - 1)
+IPCS_IDX=$(seq 0 $(( ${#IPCS_PROCFILES[*]} - 1 )))
+
+# checker
+function ipcs_limits_check {
+ for i in $IPCS_IDX; do
+ echo -n ${IPCS_PROCFILES[$i]}
+
+ a=$(eval ${IPCS_KERNEL_CMD[$i]})
+ b=$(eval ${IPCS_CMD[$i]})
+
+ #echo -n " RAW: "
+ #cat ${IPCS_PROCFILES[$i]}
+ #echo "CMD: ${ICPS_KERNEL_CMD[$i]}"
+
+ if [ x"$a" == x"$b" ]; then
+ echo " OK"
+ else
+ echo " kernel=$a, ipcs=$b"
+ fi
+ done
+}
+