Run all tests:
- ./run.sh
+ ./run.sh [--verbose]
Run one tests:
- ./ts-<component_name>-<test_name>.sh
+ ./ts-<component_name>-<test_name>.sh [--verbose]
TS_DIFFDIR="diff"
TS_EXPECTEDDIR="expected"
TS_INPUTDIR="input"
+TS_VERBOSE="no"
function ts_skip {
echo " IGNORE ($1)"
exit 0
}
+function ts_log {
+ echo "$1" >> $TS_OUTPUT
+ [ "$TS_VERBOSE" == "yes" ] && echo "$1"
+}
+
function ts_init {
export LANG="en_US.UTF-8":
TS_NAME=$(basename $0)
if [ ! -d $TS_DIFFDIR ]; then
mkdir -p $TS_DIFFDIR
fi
+ [ "$1" == "--verbose" ] && TS_VERBOSE="yes"
TS_OUTPUT="$TS_OUTDIR/$TS_NAME"
TS_DIFF="$TS_DIFFDIR/$TS_NAME"
TS_EXPECTED="$TS_EXPECTEDDIR/$TS_NAME"
}
function ts_die {
- echo "$1" >> $TS_OUTPUT
+ ts_log "$1"
if [ -n "$2" ] && [ -b "$2" ]; then
ts_device_deinit "$2"
fi
res=0
count=0
for ts in $(find -maxdepth 1 -regex "\./ts[^\.~]*" | sort); do
- $TS_TOPDIR/$ts
+ $TS_TOPDIR/$ts "$1"
res=$(( $res + $? ))
count=$(( $count + 1 ))
done
TS_COMPONENT="col"
TS_DESC="multibyte"
-ts_init
+ts_init "$1"
cat $TS_INPUT | $TS_CMD_COL > /dev/null 2> $TS_OUTPUT
TS_COMPONENT="mkfs.cramfs"
TS_DESC="mkfs"
-ts_init
+ts_init "$1"
ts_skip_nonroot
set -o pipefail
LABEL="testCramfs"
MOUNTPOINT="$TS_OUTDIR/cramfs-mnt"
-echo "create mountpoint dir" >> $TS_OUTPUT
+ts_log "create mountpoint dir"
[ -d "$MOUNTPOINT" ] || mkdir -p $MOUNTPOINT
-echo "generate data" >> $TS_OUTPUT
+ts_log "generate data"
if [ ! -d "$IMAGE_DATA" ]; then
mkdir -p $IMAGE_DATA
for d in `seq 0 110`; do
done
fi
-echo "list checksums from original data" >> $TS_OUTPUT
+ts_log "list checksums from original data"
find $IMAGE_DATA -type f -exec md5sum {} \; >> $TS_OUTPUT
echo >> $TS_OUTPUT
-echo "create cramfs image" >> $TS_OUTPUT
+ts_log "create cramfs image"
$TS_CMD_MKCRAMFS -n $LABEL $IMAGE_DATA $IMAGE 2>&1 >> $TS_OUTPUT
[ -s "$IMAGE" ] || ts_die "Cannot create $IMAGE"
-echo "count MD5 from the image" >> $TS_OUTPUT
+ts_log "count MD5 from the image"
md5sum $IMAGE 2>&1 >> $TS_OUTPUT
echo >> $TS_OUTPUT
-echo "create loop device from image" >> $TS_OUTPUT
+ts_log "create loop device from image"
DEVICE=$( $TS_CMD_LOSETUP -f )
$TS_CMD_LOSETUP $DEVICE $IMAGE 2>&1 >> $TS_OUTPUT
-echo "check the image" >> $TS_OUTPUT
+ts_log "check the image"
ts_device_has "TYPE" "cramfs" $DEVICE
[ "$?" == "0" ] || ts_die "Cannot found cramfs on $DEVICE" $DEVICE
ts_udev_dev_support "by-label" $LABEL
[ "$?" == "0" ] || ts_skip "udev ignores /dev/loop*" $DEVICE
-echo "mount the image" >> $TS_OUTPUT
+ts_log "mount the image"
$TS_CMD_MOUNT -L $LABEL $MOUNTPOINT 2>&1 >> $TS_OUTPUT
# check it
grep -q $DEVICE /proc/mounts
[ "$?" == "0" ] || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE
-echo "list the image" >> $TS_OUTPUT
+ts_log "list the image"
ls -laR $MOUNTPOINT >> $TS_OUTPUT
echo >> $TS_OUTPUT
-echo "list checksums from new data" >> $TS_OUTPUT
+ts_log "list checksums from new data"
find $MOUNTPOINT -type f -exec md5sum {} \; >> $TS_OUTPUT
echo >> $TS_OUTPUT
-echo "umount the image" >> $TS_OUTPUT
+ts_log "umount the image"
$TS_CMD_UMOUNT $DEVICE
$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
ts_finalize
NTP_SERVER="0.fedora.pool.ntp.org"
-ts_init
+ts_init "$1"
ts_skip_nonroot
[ -x "/usr/sbin/ntpdate" ] || ts_skip "cannot found ntpdate command"
TS_COMPONENT="ipcs"
TS_DESC="headers"
-ts_init
+ts_init "$1"
-echo "test: shm headers" >> $TS_OUTPUT
+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 -u | grep "^---" >> $TS_OUTPUT
echo >> $TS_OUTPUT
-echo "test: mesg headers" >> $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 -u | grep "^---" >> $TS_OUTPUT
echo >> $TS_OUTPUT
-echo "test: sem headers" >> $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 -u | grep "^---" >> $TS_OUTPUT
echo >> $TS_OUTPUT
-echo "test: all headers" >> $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_DESC="limits overflow"
if [ $UID != 0 ]; then
- ts_init
+ ts_init "$1"
ts_skip_nonroot
fi
. ts-ipcs.sh
-ts_init
+ts_init "$1"
-(
- echo "load original values"
- for i in $IPCS_IDX; do
- SHM_ORG[$i]=$(cat ${IPCS_PROCFILES[$i]})
- done
+ts_log "load original values"
+for i in $IPCS_IDX; do
+ SHM_ORG[$i]=$(cat ${IPCS_PROCFILES[$i]})
+done >> $TS_OUTPUT
- echo "check for difference between kernel and IPC"
- ipcs_limits_check
+ts_log "check for difference between kernel and IPC"
+ipcs_limits_check >> $TS_OUTPUT
- echo "maximalize kernel setting"
- for i in $IPCS_IDX; do
- echo ${IPCS_LIMITS[$i]} >> ${IPCS_PROCFILES[$i]}
- done
+ts_log "maximalize kernel setting"
+for i in $IPCS_IDX; do
+ echo ${IPCS_LIMITS[$i]} >> ${IPCS_PROCFILES[$i]}
+done >> $TS_OUTPUT
- echo "re-check for difference between kernel and IPC"
- ipcs_limits_check
+ts_log "re-check for difference between kernel and IPC"
+ipcs_limits_check >> $TS_OUTPUT
- echo "write original values to kernel"
- for i in $IPCS_IDX; do
- echo ${SHM_ORG[$i]} >> ${IPCS_PROCFILES[$i]}
- done
-
-) > $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
. ts-ipcs.sh
-ts_init
+ts_init "$1"
-(
- echo "check for difference between kernel and IPC"
- ipcs_limits_check
-
-) > $TS_OUTPUT
+ts_log "check for difference between kernel and IPC"
+ipcs_limits_check >> $TS_OUTPUT
ts_finalize
#!/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
TS_COMPONENT="login"
TS_DESC="checktty"
-ts_init
+ts_init "$1"
$TS_CMD_CHECKTTY >> $TS_OUTPUT
ts_finalize
TS_COMPONENT="look"
TS_DESC="separator"
-ts_init
+ts_init "$1"
[ -f "/usr/share/dict/words" ] || ts_skip "/usr/share/dict/words not such file"
TS_COMPONENT="mount"
TS_DESC="move "
-ts_init
+ts_init "$1"
ts_skip_nonroot
PWD=$(pwd)
$TS_CMD_UMOUNT $DIR_SRC
rmdir $DIR_SRC $DIR_A $DIR_B
-echo "Success" >> $TS_OUTPUT
+ts_log "Success"
ts_finalize
TS_COMPONENT="mount"
TS_DESC="mtablock"
-ts_init
+ts_init "$1"
ts_skip_nonroot
#
TS_COMPONENT="mount"
TS_DESC="basic paths"
-ts_init
+ts_init "$1"
$TS_CMD_MOUNT -n -f --debug=2 /dev/dummy /mnt &> $TS_OUTPUT
TS_COMPONENT="mount"
TS_DESC="remount"
-ts_init
+ts_init "$1"
ts_skip_nonroot
# mountpoint
ts_device_deinit $DEVICE
-echo "Success" >> $TS_OUTPUT
+ts_log "Success"
ts_finalize
MOUNTER="/sbin/mount.mytest"
-ts_init
+ts_init "$1"
ts_skip_nonroot
cat > $MOUNTER << EOF
TS_COMPONENT="namei"
TS_DESC="logic"
-ts_init
+ts_init "$1"
SANDBOX="$TS_OUTDIR/namei"
mkdir -p $SANDBOX/namei1/namei2
touch $SANDBOX/namei1/namei2/a $SANDBOX/namei1/namei2/b
-touch $TS_OUTPUT
-
$TS_CMD_NAMEI $SANDBOX/namei1/namei2/a >> $TS_OUTPUT 2>&1
$TS_CMD_NAMEI $SANDBOX/namei1/namei2/b >> $TS_OUTPUT 2>&1
$TS_CMD_NAMEI $SANDBOX/namei1/namei2/a/b >> $TS_OUTPUT 2>&1
TS_COMPONENT="swapon"
TS_DESC="devname"
-ts_init
+ts_init "$1"
ts_skip_nonroot
set -o pipefail
ts_swapoff $DEVICE
ts_device_deinit $DEVICE
-echo "Success" >> $TS_OUTPUT
+ts_log "Success"
ts_finalize
LABEL="testSwapLabel"
-ts_init
+ts_init "$1"
ts_skip_nonroot
set -o pipefail
ts_swapoff $DEVICE
ts_device_deinit $DEVICE
-echo "Success" >> $TS_OUTPUT
+ts_log "Success"
ts_finalize
TS_COMPONENT="swapon"
TS_DESC="uuid"
-ts_init
+ts_init "$1"
ts_skip_nonroot
set -o pipefail
ts_swapoff $DEVICE
ts_device_deinit $DEVICE
-echo "Success" >> $TS_OUTPUT
+ts_log "Success"
ts_finalize