]> err.no Git - util-linux/commitdiff
ipcs: add new tests for ipcs limits
authorKarel Zak <kzak@redhat.com>
Wed, 3 Jan 2007 00:07:55 +0000 (01:07 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 4 Jan 2007 13:53:57 +0000 (14:53 +0100)
The tests check if data from kernel and from the ipcs command are same.

Signed-off-by: Karel Zak <kzak@redhat.com>
tests/Makefile.am
tests/expected/ts-ipcs-limits [new file with mode: 0644]
tests/expected/ts-ipcs-limits2 [new file with mode: 0644]
tests/functions.sh
tests/run.sh
tests/ts-ipcs-limits [new file with mode: 0755]
tests/ts-ipcs-limits2 [new file with mode: 0755]
tests/ts-ipcs.sh [new file with mode: 0644]

index ff516ede45dbd5e44bb1d52f0f45cdf3b86012a2..eebb700b73723d12c618943d48036eeb4d997318 100644 (file)
@@ -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 (file)
index 0000000..7480a1e
--- /dev/null
@@ -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 (file)
index 0000000..28454e3
--- /dev/null
@@ -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
index 2a18ef583279cd2392630bd1a624c3ef6b05b2b7..81168fc32c074cf4d7e1d4844e4b1a330ba996fb 100644 (file)
@@ -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)"
index 275b687336b53bbd684a4311aa93798f8559fdd0..feb0089ffd31f44fd830df57638ae375291016eb 100755 (executable)
@@ -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 (executable)
index 0000000..542819f
--- /dev/null
@@ -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 (executable)
index 0000000..59e10d4
--- /dev/null
@@ -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 (file)
index 0000000..9f9e119
--- /dev/null
@@ -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
+}
+