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>
This commit is contained in:
Karel Zak 2007-01-03 01:07:55 +01:00
parent 0f0584addc
commit b30cd7eed5
8 changed files with 166 additions and 3 deletions

View 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

View File

@ -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

View File

@ -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

View 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)"

View File

@ -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 ))

43
tests/ts-ipcs-limits Executable file
View File

@ -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

20
tests/ts-ipcs-limits2 Executable file
View File

@ -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

72
tests/ts-ipcs.sh Normal file
View File

@ -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
}