diff options
Diffstat (limited to 'tests/ts/ipcs')
-rw-r--r-- | tests/ts/ipcs/functions.sh | 83 | ||||
-rwxr-xr-x | tests/ts/ipcs/headers | 58 | ||||
-rwxr-xr-x | tests/ts/ipcs/limits | 51 | ||||
-rwxr-xr-x | tests/ts/ipcs/limits2 | 31 |
4 files changed, 223 insertions, 0 deletions
diff --git a/tests/ts/ipcs/functions.sh b/tests/ts/ipcs/functions.sh new file mode 100644 index 0000000..24ea445 --- /dev/null +++ b/tests/ts/ipcs/functions.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak <kzak@redhat.com> +# +# This file is part of util-linux. +# +# 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 0000000..99b82a3 --- /dev/null +++ b/tests/ts/ipcs/headers @@ -0,0 +1,58 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak <kzak@redhat.com> +# +# This file is part of util-linux. +# +# 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. +# +TS_TOPDIR="$(dirname $0)/../.." +TS_DESC="headers" + +. $TS_TOPDIR/functions.sh +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 0000000..ed6e084 --- /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. +# +# 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. +# + +TS_TOPDIR="$(dirname $0)/../.." +TS_DESC="limits overflow" + +. $TS_TOPDIR/functions.sh + +ts_init "$*" +ts_skip_nonroot + +. $TS_SELF/functions.sh + +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 0000000..acb1749 --- /dev/null +++ b/tests/ts/ipcs/limits2 @@ -0,0 +1,31 @@ +#!/bin/bash + +# +# Copyright (C) 2007 Karel Zak <kzak@redhat.com> +# +# This file is part of util-linux. +# +# 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. +# + +TS_TOPDIR="$(dirname $0)/../.." +TS_DESC="basic limits" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +. $TS_SELF/functions.sh + +ts_log "check for difference between kernel and IPC" +ipcs_limits_check >> $TS_OUTPUT + +ts_finalize + |