summaryrefslogtreecommitdiffstats
path: root/tests/ts/ipcs
diff options
context:
space:
mode:
authorKarel Zak2009-01-19 16:50:51 +0100
committerKarel Zak2009-02-11 23:21:52 +0100
commit8387a824b576c41a0a4077cb1973046e91f7d1f6 (patch)
tree9cd1bd84ff46b051d1da990321e7624aaabe94ba /tests/ts/ipcs
parentblkid: refresh TODO file (diff)
downloadkernel-qcow2-util-linux-8387a824b576c41a0a4077cb1973046e91f7d1f6.tar.gz
kernel-qcow2-util-linux-8387a824b576c41a0a4077cb1973046e91f7d1f6.tar.xz
kernel-qcow2-util-linux-8387a824b576c41a0a4077cb1973046e91f7d1f6.zip
tests: create subdirs for test scripts
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/ts/ipcs')
-rw-r--r--tests/ts/ipcs/function.sh83
-rwxr-xr-xtests/ts/ipcs/headers60
-rwxr-xr-xtests/ts/ipcs/limits51
-rwxr-xr-xtests/ts/ipcs/limits232
4 files changed, 226 insertions, 0 deletions
diff --git a/tests/ts/ipcs/function.sh b/tests/ts/ipcs/function.sh
new file mode 100644
index 000000000..ff35e75ea
--- /dev/null
+++ b/tests/ts/ipcs/function.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux-ng.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+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 | $AWK '/max number of segments/ { print \$6 }'"
+ "$TS_CMD_IPCS -m -l | $AWK '/max total shared memory/ { print \$7 }'"
+ "$TS_CMD_IPCS -m -l | $AWK '/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
+}
+
diff --git a/tests/ts/ipcs/headers b/tests/ts/ipcs/headers
new file mode 100755
index 000000000..8a391d0c9
--- /dev/null
+++ b/tests/ts/ipcs/headers
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux-ng.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+. ./commands.sh
+. ./functions.sh
+
+TS_COMPONENT="ipcs"
+TS_DESC="headers"
+
+ts_init "$*"
+
+ts_log "test: shm headers"
+$TS_CMD_IPCS -m -t | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -m -p | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -m -c | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -m -l | grep "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -m -u | grep "^---" >> $TS_OUTPUT
+echo >> $TS_OUTPUT
+
+ts_log "test: mesg headers"
+$TS_CMD_IPCS -q -t | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -q -p | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -q -c | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -q -l | grep "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -q -u | grep "^---" >> $TS_OUTPUT
+echo >> $TS_OUTPUT
+
+ts_log "test: sem headers"
+$TS_CMD_IPCS -s -t | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -s -p | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -s -c | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -s -l | grep "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -s -u | grep "^---" >> $TS_OUTPUT
+echo >> $TS_OUTPUT
+
+ts_log "test: all headers"
+$TS_CMD_IPCS -a | grep --after-context=1 "^---" >> $TS_OUTPUT
+
+$TS_CMD_IPCS -a -t | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -a -p | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -a -c | grep --after-context=1 "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -a -l | grep "^---" >> $TS_OUTPUT
+$TS_CMD_IPCS -a -u | grep "^---" >> $TS_OUTPUT
+
+ts_finalize
+
diff --git a/tests/ts/ipcs/limits b/tests/ts/ipcs/limits
new file mode 100755
index 000000000..6224ac440
--- /dev/null
+++ b/tests/ts/ipcs/limits
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux-ng.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+. ./commands.sh
+. ./functions.sh
+
+TS_COMPONENT="ipcs"
+TS_DESC="limits overflow"
+
+. ./ts-ipcs.sh
+
+ts_init "$*"
+ts_skip_nonroot
+
+ts_log "load original values"
+for i in $IPCS_IDX; do
+ SHM_ORG[$i]=$(cat ${IPCS_PROCFILES[$i]})
+done >> $TS_OUTPUT
+
+ts_log "check for difference between kernel and IPC"
+ipcs_limits_check >> $TS_OUTPUT
+
+ts_log "maximalize kernel setting"
+for i in $IPCS_IDX; do
+ echo ${IPCS_LIMITS[$i]} >> ${IPCS_PROCFILES[$i]}
+done >> $TS_OUTPUT
+
+ts_log "re-check for difference between kernel and IPC"
+ipcs_limits_check >> $TS_OUTPUT
+
+ts_log "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..f539e8a6e
--- /dev/null
+++ b/tests/ts/ipcs/limits2
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux-ng.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+. ./commands.sh
+. ./functions.sh
+
+TS_COMPONENT="ipcs"
+TS_DESC="basic limits"
+
+. ./ts-ipcs.sh
+
+ts_init "$*"
+
+ts_log "check for difference between kernel and IPC"
+ipcs_limits_check >> $TS_OUTPUT
+
+ts_finalize
+