diff options
Diffstat (limited to 'tests/ts')
73 files changed, 819 insertions, 978 deletions
diff --git a/tests/ts/blkid/images-fs/mpool.img.xz b/tests/ts/blkid/images-fs/mpool.img.xz Binary files differnew file mode 100644 index 000000000..4bfefdedb --- /dev/null +++ b/tests/ts/blkid/images-fs/mpool.img.xz diff --git a/tests/ts/blkid/images-fs/vdo.img.xz b/tests/ts/blkid/images-fs/vdo.img.xz Binary files differnew file mode 100644 index 000000000..08c7ecb08 --- /dev/null +++ b/tests/ts/blkid/images-fs/vdo.img.xz diff --git a/tests/ts/blkid/images-pt/atari-icd.img.xz b/tests/ts/blkid/images-pt/atari-icd.img.xz Binary files differnew file mode 100644 index 000000000..00a2aba49 --- /dev/null +++ b/tests/ts/blkid/images-pt/atari-icd.img.xz diff --git a/tests/ts/blkid/images-pt/atari-xgm.img.xz b/tests/ts/blkid/images-pt/atari-xgm.img.xz Binary files differnew file mode 100644 index 000000000..bc2b8f94a --- /dev/null +++ b/tests/ts/blkid/images-pt/atari-xgm.img.xz diff --git a/tests/ts/blkid/md-raid0-whole b/tests/ts/blkid/md-raid0-whole index cbfb1eb7c..45c6ee55b 100755 --- a/tests/ts/blkid/md-raid0-whole +++ b/tests/ts/blkid/md-raid0-whole @@ -41,6 +41,7 @@ DEVICE2=$TS_LODEV MD_DEVNAME=md8 MD_DEVICE=/dev/${MD_DEVNAME} +ts_lock "md" mdadm -q -S ${MD_DEVICE} &> /dev/null ts_log "Create RAID device" @@ -76,6 +77,7 @@ ts_log "Stop RAID device" mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>&1 udevadm settle +ts_unlock "md" ts_log "Deinitialize devices" diff --git a/tests/ts/blkid/md-raid1-part b/tests/ts/blkid/md-raid1-part index 9f1276186..3fa6395b0 100755 --- a/tests/ts/blkid/md-raid1-part +++ b/tests/ts/blkid/md-raid1-part @@ -62,6 +62,8 @@ udevadm settle MD_DEVNAME=md8 MD_DEVICE=/dev/${MD_DEVNAME} +ts_lock "md" + ts_log "Create RAID1 device" mdadm -q -S ${MD_DEVICE} &> /dev/null mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 --level=1 \ @@ -79,6 +81,8 @@ $TS_CMD_BLKID -p -o udev ${TS_DEVICE}2 2>&1 | sort >> $TS_OUTPUT mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>&1 +udevadm settle +ts_unlock "md" ts_fdisk_clean $TS_DEVICE # substitue UUIDs and major/minor number before comparison diff --git a/tests/ts/blkid/md-raid1-whole b/tests/ts/blkid/md-raid1-whole index 050adecd7..ddf4a6934 100755 --- a/tests/ts/blkid/md-raid1-whole +++ b/tests/ts/blkid/md-raid1-whole @@ -41,11 +41,15 @@ DEVICE2=$TS_LODEV MD_DEVNAME=md8 MD_DEVICE=/dev/${MD_DEVNAME} +ts_lock "md" + mdadm -q -S ${MD_DEVICE} &> /dev/null +udevadm settle ts_log "Create RAID device" mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 --level=1 \ --raid-devices=2 ${DEVICE1} ${DEVICE2} >> $TS_OUTPUT 2>&1 +udevadm settle ts_log "Create partitions on RAID device" $TS_CMD_FDISK ${MD_DEVICE} >> $TS_OUTPUT 2>&1 <<EOF @@ -76,6 +80,7 @@ ts_log "Stop RAID device" mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>&1 udevadm settle +ts_unlock "md" ts_log "Deinitialize devices" diff --git a/tests/ts/cal/1m b/tests/ts/cal/1m deleted file mode 100755 index 9f691e137..000000000 --- a/tests/ts/cal/1m +++ /dev/null @@ -1,61 +0,0 @@ -#!/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="${0%/*}/../.." -TS_DESC="1 month" - -. $TS_TOPDIR/functions.sh -ts_init "$*" - -ts_check_test_command "$TS_CMD_CAL" - -export TERM=linux - -USETERM=$( ts_has_option "useterm" "$*" ) -MYTIME="27 09 2006" - -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" - -ts_log "Gregorian - Monday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1m $MYTIME -fi -$TS_CMD_CAL -1m $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Sunday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1s $MYTIME -fi -$TS_CMD_CAL -1s $MYTIME >> $TS_OUTPUT - - -ts_log "Julian - Monday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mj $MYTIME -fi -$TS_CMD_CAL -1mj $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Sunday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sj $MYTIME -fi -$TS_CMD_CAL -1sj $MYTIME >> $TS_OUTPUT - -ts_finalize - diff --git a/tests/ts/cal/1mw b/tests/ts/cal/1mw deleted file mode 100755 index 3234a6adb..000000000 --- a/tests/ts/cal/1mw +++ /dev/null @@ -1,61 +0,0 @@ -#!/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="${0%/*}/../.." -TS_DESC="1 month with week numbers" - -. $TS_TOPDIR/functions.sh -ts_init "$*" - -ts_check_test_command "$TS_CMD_CAL" - -export TERM=linux - -USETERM=$( ts_has_option "useterm" "$*" ) -MYTIME="27 09 2006" - -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" - -ts_log "Gregorian - Monday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mw $MYTIME -fi -$TS_CMD_CAL -1mw $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Sunday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sw $MYTIME -fi -$TS_CMD_CAL -1sw $MYTIME >> $TS_OUTPUT - - -ts_log "Julian - Monday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mjw $MYTIME -fi -$TS_CMD_CAL -1mjw $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Sunday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sjw $MYTIME -fi -$TS_CMD_CAL -1sjw $MYTIME >> $TS_OUTPUT - -ts_finalize - diff --git a/tests/ts/cal/3m b/tests/ts/cal/3m deleted file mode 100755 index baa9ba314..000000000 --- a/tests/ts/cal/3m +++ /dev/null @@ -1,60 +0,0 @@ -#!/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="${0%/*}/../.." -TS_DESC="3 months" - -. $TS_TOPDIR/functions.sh -ts_init "$*" - -ts_check_test_command "$TS_CMD_CAL" - -export TERM=linux - -USETERM=$( ts_has_option "useterm" "$*" ) -MYTIME="27 09 2006" - -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" - -ts_log "Gregorian - Monday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3m $MYTIME -fi -$TS_CMD_CAL -3m $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Sunday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3s $MYTIME -fi -$TS_CMD_CAL -3s $MYTIME >> $TS_OUTPUT - - -ts_log "Julian - Monday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mj $MYTIME -fi -$TS_CMD_CAL -3mj $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Sunday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sj $MYTIME -fi -$TS_CMD_CAL -3sj $MYTIME >> $TS_OUTPUT - -ts_finalize - diff --git a/tests/ts/cal/3mw b/tests/ts/cal/3mw deleted file mode 100755 index cb3905b18..000000000 --- a/tests/ts/cal/3mw +++ /dev/null @@ -1,58 +0,0 @@ -#!/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="${0%/*}/../.." -TS_DESC="3 months with week numbers" - -. $TS_TOPDIR/functions.sh -ts_init "$*" - -ts_check_test_command "$TS_CMD_CAL" - -USETERM=$( ts_has_option "useterm" "$*" ) -MYTIME="27 09 2006" - -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" - -ts_log "Gregorian - Monday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mw $MYTIME -fi -$TS_CMD_CAL -3mw $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Sunday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sw $MYTIME -fi -$TS_CMD_CAL -3sw $MYTIME >> $TS_OUTPUT - - -ts_log "Julian - Monday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mjw $MYTIME -fi -$TS_CMD_CAL -3mjw $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Sunday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sjw $MYTIME -fi -$TS_CMD_CAL -3sjw $MYTIME >> $TS_OUTPUT - -ts_finalize - diff --git a/tests/ts/cal/bigyear b/tests/ts/cal/bigyear index 5dced2a0f..d205c3afd 100755 --- a/tests/ts/cal/bigyear +++ b/tests/ts/cal/bigyear @@ -26,73 +26,58 @@ USETERM=$( ts_has_option "useterm" "$*" ) MYMONTH="12 2147483646" MYYEAR="2147483646" -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" - - -ts_log "Gregorian - Monday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1m -fi -$TS_CMD_CAL -1m $MYMONTH >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1s $MYMONTH -fi -$TS_CMD_CAL -1s $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Monday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mj $MYMONTH -fi -$TS_CMD_CAL -1mj $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Sunday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sj $MYMONTH -fi -$TS_CMD_CAL -1sj $MYMONTH >> $TS_OUTPUT - - -ts_log "Gregorian - Monday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3m -fi -$TS_CMD_CAL -3m $MYMONTH >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3s $MYMONTH -fi -$TS_CMD_CAL -3s $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Monday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mj $MYMONTH -fi -$TS_CMD_CAL -3mj $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Sunday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sj $MYMONTH -fi -$TS_CMD_CAL -3sj $MYMONTH >> $TS_OUTPUT - - -ts_log "Gregorian - Monday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1m $MYYEAR -fi -$TS_CMD_CAL -1m $MYYEAR >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1s $MYYEAR -fi -$TS_CMD_CAL -1s $MYYEAR >> $TS_OUTPUT -ts_log "Julian - Monday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mj $MYYEAR -fi -$TS_CMD_CAL -1mj $MYYEAR >> $TS_OUTPUT -ts_log "Julian - Sunday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sj $MYYEAR -fi -$TS_CMD_CAL -1sj $MYYEAR >> $TS_OUTPUT + +CAL_TEST_TIME=1516562739 # 21st January 2018 +export CAL_TEST_TIME + +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') + + if [ "$3" == "$MYYEAR" ]; then + testname="${testname}-year" + else + testname="${testname}-month" + fi + + ts_init_subtest "$testname" + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_HELPER_CAL "$@" + fi + $TS_HELPER_CAL "$@" >> $TS_OUTPUT + ts_finalize_subtest +} + +call_cal "Gregorian - Monday-based month" -1m $MYMONTH +call_cal "Gregorian - Sunday-based month" -1s $MYMONTH +call_cal "Julian - Monday-based month" -1mj $MYMONTH +call_cal "Julian - Sunday-based month" -1sj $MYMONTH + +call_cal "Gregorian - Monday-based 3 months" -3m $MYMONTH +call_cal "Gregorian - Sunday-based 3 months" -3s $MYMONTH +call_cal "Julian - Monday-based 3 months" -3mj $MYMONTH +call_cal "Julian - Sunday-based 3 months" -3sj $MYMONTH + +call_cal "Gregorian - Monday-based year" -1m $MYYEAR +call_cal "Gregorian - Sunday-based year" -1s $MYYEAR +call_cal "Julian - Monday-based year" -1mj $MYYEAR +call_cal "Julian - Sunday-based year" -1sj $MYYEAR + + +call_cal "Gregorian - Monday-based month with weeks" -1mw $MYMONTH +call_cal "Gregorian - Sunday-based month with weeks" -1sw $MYMONTH +call_cal "Julian - Monday-based month with weeks" -1mjw $MYMONTH +call_cal "Julian - Sunday-based month with weeks" -1sjw $MYMONTH + +call_cal "Gregorian - Monday-based 3 months with weeks" -3mw $MYMONTH +call_cal "Gregorian - Sunday-based 3 months with weeks" -3sw $MYMONTH +call_cal "Julian - Monday-based 3 months with weeks" -3mjw $MYMONTH +call_cal "Julian - Sunday-based 3 months with weeks" -3sjw $MYMONTH + +call_cal "Gregorian - Monday-based year with weeks" -1mw $MYYEAR +call_cal "Gregorian - Sunday-based year with weeks" -1sw $MYYEAR +call_cal "Julian - Monday-based year with weeks" -1mjw $MYYEAR +call_cal "Julian - Sunday-based year with weeks" -1sjw $MYYEAR ts_finalize diff --git a/tests/ts/cal/bigyearw b/tests/ts/cal/bigyearw deleted file mode 100755 index 2ce9fc73d..000000000 --- a/tests/ts/cal/bigyearw +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash - -# 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="${0%/*}/../.." -TS_DESC="Year 2147483646 with week numbers" - -. $TS_TOPDIR/functions.sh -ts_init "$*" - -ts_check_test_command "$TS_CMD_CAL" - -export TERM=linux - -USETERM=$( ts_has_option "useterm" "$*" ) -MYMONTH="12 2147483646" -MYYEAR="2147483646" - -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" - - -ts_log "Gregorian - Monday-based month with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mw -fi -$TS_CMD_CAL -1mw $MYMONTH >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based month with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sw $MYMONTH -fi -$TS_CMD_CAL -1sw $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Monday-based month with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mjw $MYMONTH -fi -$TS_CMD_CAL -1mjw $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Sunday-based month with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sjw $MYMONTH -fi -$TS_CMD_CAL -1sjw $MYMONTH >> $TS_OUTPUT - - -ts_log "Gregorian - Monday-based three months with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mw -fi -$TS_CMD_CAL -3mw $MYMONTH >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based three months with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sw $MYMONTH -fi -$TS_CMD_CAL -3sw $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Monday-based three months with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mjw $MYMONTH -fi -$TS_CMD_CAL -3mjw $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Sunday-based three months with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sjw $MYMONTH -fi -$TS_CMD_CAL -3sjw $MYMONTH >> $TS_OUTPUT - - -ts_log "Gregorian - Monday-based year with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mw $MYYEAR -fi -$TS_CMD_CAL -1mw $MYYEAR >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based year with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sw $MYYEAR -fi -$TS_CMD_CAL -1sw $MYYEAR >> $TS_OUTPUT -ts_log "Julian - Monday-based year with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mjw $MYYEAR -fi -$TS_CMD_CAL -1mjw $MYYEAR >> $TS_OUTPUT -ts_log "Julian - Sunday-based year with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sjw $MYYEAR -fi -$TS_CMD_CAL -1sjw $MYYEAR >> $TS_OUTPUT - -ts_finalize diff --git a/tests/ts/cal/jan1753 b/tests/ts/cal/jan1753 index 85dbf3530..1be3db3b8 100755 --- a/tests/ts/cal/jan1753 +++ b/tests/ts/cal/jan1753 @@ -25,19 +25,21 @@ export TERM=linux USETERM=$( ts_has_option "useterm" "$*" ) MYMONTH="1 1753" -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" - -ts_log "Monday-based 1753 week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -m3w $MYMONTH -fi -$TS_CMD_CAL -m3w $MYMONTH >> $TS_OUTPUT - -ts_log "Sunday-based 1753 week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3w $MYMONTH -fi -$TS_CMD_CAL -3w $MYMONTH >> $TS_OUTPUT +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') + + ts_init_subtest "$testname" + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL "$@" + fi + $TS_CMD_CAL "$@" >> $TS_OUTPUT + + ts_finalize_subtest +} + +call_cal "Monday-based 1753 week numbers" -m3w $MYMONTH +call_cal "Sunday-based 1753 week numbers" -3w $MYMONTH ts_finalize diff --git a/tests/ts/cal/month b/tests/ts/cal/month new file mode 100755 index 000000000..9794e90c0 --- /dev/null +++ b/tests/ts/cal/month @@ -0,0 +1,67 @@ +#!/bin/bash + +# +# Copyright (C) 2007-2018 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="${0%/*}/../.." +TS_DESC="month" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_CAL" + +export TERM=linux + +USETERM=$( ts_has_option "useterm" "$*" ) +MYTIME="27 09 2006" + +CAL_TEST_TIME=1516562739 # 21st January 2018 +export CAL_TEST_TIME + +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') + + ts_init_subtest "$testname" + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_HELPER_CAL "$@" + fi + $TS_HELPER_CAL "$@" >> $TS_OUTPUT + + ts_finalize_subtest +} + +call_cal "Gregorian - Monday-based week" -1m $MYTIME +call_cal "Gregorian - Sunday-based week" -1s $MYTIME +call_cal "Julian - Monday-based week" -1mj $MYTIME +call_cal "Julian - Sunday-based week" -1sj $MYTIME +call_cal "Gregorian - Monday-based week with week numbers" -1mw $MYTIME +call_cal "Gregorian - Sunday-based week with week numbers" -1sw $MYTIME +call_cal "Julian - Monday-based week with week numbers" -1mjw $MYTIME +call_cal "Julian - Sunday-based week with week numbers" -1sjw $MYTIME +call_cal "Gregorian - Monday-based week" -3m $MYTIME +call_cal "Gregorian - Sunday-based week" -3s $MYTIME +call_cal "Julian - Monday-based week" -3mj $MYTIMET +call_cal "Julian - Sunday-based week" -3sj $MYTIME +call_cal "Gregorian - Monday-based week with week numbers" -3mw $MYTIME +call_cal "Gregorian - Sunday-based week with week numbers" -3sw $MYTIME +call_cal "Julian - Monday-based week with week numbers" -3mjw $MYTIME +call_cal "Julian - Sunday-based week with week numbers" -3sjw $MYTIME + +ts_finalize + diff --git a/tests/ts/cal/sep1752 b/tests/ts/cal/sep1752 index 8db7e3cac..3128261cd 100755 --- a/tests/ts/cal/sep1752 +++ b/tests/ts/cal/sep1752 @@ -26,73 +26,61 @@ USETERM=$( ts_has_option "useterm" "$*" ) MYMONTH="09 1752" MYYEAR="1752" -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" - - -ts_log "Gregorian - Monday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1m -fi -$TS_CMD_CAL -1m $MYMONTH >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1s $MYMONTH -fi -$TS_CMD_CAL -1s $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Monday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mj $MYMONTH -fi -$TS_CMD_CAL -1mj $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Sunday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sj $MYMONTH -fi -$TS_CMD_CAL -1sj $MYMONTH >> $TS_OUTPUT - - -ts_log "Gregorian - Monday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3m -fi -$TS_CMD_CAL -3m $MYMONTH >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3s $MYMONTH -fi -$TS_CMD_CAL -3s $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Monday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mj $MYMONTH -fi -$TS_CMD_CAL -3mj $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Sunday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sj $MYMONTH -fi -$TS_CMD_CAL -3sj $MYMONTH >> $TS_OUTPUT - - -ts_log "Gregorian - Monday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1m $MYYEAR -fi -$TS_CMD_CAL -1m $MYYEAR >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1s $MYYEAR -fi -$TS_CMD_CAL -1s $MYYEAR >> $TS_OUTPUT -ts_log "Julian - Monday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mj $MYYEAR -fi -$TS_CMD_CAL -1mj $MYYEAR >> $TS_OUTPUT -ts_log "Julian - Sunday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sj $MYYEAR -fi -$TS_CMD_CAL -1sj $MYYEAR >> $TS_OUTPUT +CAL_TEST_TIME=1516562739 # 21st January 2018 +export CAL_TEST_TIME + +function call_cal_simple { + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_HELPER_CAL "$@" + fi + $TS_HELPER_CAL "$@" >> $TS_OUTPUT +} + +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') + + if [ "$3" == "$MYYEAR" ]; then + testname="${testname}-year" + else + testname="${testname}-month" + fi + + ts_init_subtest "$testname" + call_cal_simple "$@" + ts_finalize_subtest +} + + +call_cal "Gregorian - Monday-based month with week numbers" -1mw $MYMONTH +call_cal "Gregorian - Sunday-based month with week numbers" -1sw $MYMONTH +call_cal "Julian - Monday-based month with week numbers" -1mjw $MYMONTH +call_cal "Julian - Sunday-based month with week numbers" -1sjw $MYMONTH +call_cal "Gregorian - Monday-based three months with week numbers" -3mw $MYMONTH +call_cal "Gregorian - Sunday-based three months with week numbers" -3sw $MYMONTH +call_cal "Julian - Monday-based three months with week numbers" -3mjw $MYMONTH +call_cal "Julian - Sunday-based three months with week numbers" -3sjw $MYMONTH +call_cal "Gregorian - Monday-based year with week numbers" -1mw $MYYEAR +call_cal "Gregorian - Sunday-based year with week numbers" -1sw $MYYEAR +call_cal "Julian - Monday-based year with week numbers" -1mjw $MYYEAR +call_cal "Julian - Sunday-based year with week numbers" -1sjw $MYYEAR + +ts_init_subtest "week-iso" +call_cal_simple "Gregorian - address by week number" --week=40 --iso $MYYEAR +ts_finalize_subtest + +call_cal "Gregorian - Monday-based month" -1m $MYMONTH +call_cal "Gregorian - Sunday-based month" -1s $MYMONTH +call_cal "Julian - Monday-based month" -1mj $MYMONTH +call_cal "Julian - Sunday-based month" -1sj $MYMONTH +call_cal "Gregorian - Monday-based three months" -3m $MYMONTH +call_cal "Gregorian - Sunday-based three months" -3s $MYMONTH +call_cal "Julian - Monday-based three months" -3mj $MYMONTH +call_cal "Julian - Sunday-based three months" -3sj $MYMONTH +call_cal "Gregorian - Monday-based year" -1m $MYYEAR +call_cal "Gregorian - Sunday-based year" -1s $MYYEAR +call_cal "Julian - Monday-based year" -1mj $MYYEAR +call_cal "Julian - Sunday-based year" -1sj $MYYEAR ts_finalize diff --git a/tests/ts/cal/sep1752w b/tests/ts/cal/sep1752w deleted file mode 100755 index d2d0d3166..000000000 --- a/tests/ts/cal/sep1752w +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash - -# 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="${0%/*}/../.." -TS_DESC="September 1752 with week numbers" - -. $TS_TOPDIR/functions.sh -ts_init "$*" - -ts_check_test_command "$TS_CMD_CAL" - -export TERM=linux - -USETERM=$( ts_has_option "useterm" "$*" ) -MYMONTH="09 1752" -MYYEAR="1752" - -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" - - -ts_log "Gregorian - Monday-based month with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mw -fi -$TS_CMD_CAL -1mw $MYMONTH >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based month with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sw $MYMONTH -fi -$TS_CMD_CAL -1sw $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Monday-based month with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mjw $MYMONTH -fi -$TS_CMD_CAL -1mjw $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Sunday-based month with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sjw $MYMONTH -fi -$TS_CMD_CAL -1sjw $MYMONTH >> $TS_OUTPUT - - -ts_log "Gregorian - Monday-based three months with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mw -fi -$TS_CMD_CAL -3mw $MYMONTH >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based three months with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sw $MYMONTH -fi -$TS_CMD_CAL -3sw $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Monday-based three months with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mjw $MYMONTH -fi -$TS_CMD_CAL -3mjw $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Sunday-based three months with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sjw $MYMONTH -fi -$TS_CMD_CAL -3sjw $MYMONTH >> $TS_OUTPUT - - -ts_log "Gregorian - Monday-based year with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mw $MYYEAR -fi -$TS_CMD_CAL -1mw $MYYEAR >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based year with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sw $MYYEAR -fi -$TS_CMD_CAL -1sw $MYYEAR >> $TS_OUTPUT -ts_log "Julian - Monday-based year with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mjw $MYYEAR -fi -$TS_CMD_CAL -1mjw $MYYEAR >> $TS_OUTPUT -ts_log "Julian - Sunday-based year with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sjw $MYYEAR -fi -$TS_CMD_CAL -1sjw $MYYEAR >> $TS_OUTPUT - -ts_finalize diff --git a/tests/ts/cal/weekarg b/tests/ts/cal/weekarg index 236baedd5..d26906ee1 100755 --- a/tests/ts/cal/weekarg +++ b/tests/ts/cal/weekarg @@ -32,133 +32,67 @@ export TERM=linux USETERM=$( ts_has_option "useterm" "$*" ) -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" +function call_cal_simple { + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL "$@" + fi + $TS_CMD_CAL "$@" >> $TS_OUTPUT +} + +function call_cal { + local testname=$(echo "${2}" | sed 's/-//g') + testname="${testname}-$(echo "${3}" | sed 's/=//g;s/-//g')" + + ts_init_subtest "$testname" + call_cal_simple "$@" + ts_finalize_subtest +} + +function call_cal_color { + local testname=$(echo "${2}" | sed 's/-//g') + testname="${testname}-$(echo "${3}" | sed 's/=//g;s/-//g')-color" + + ts_init_subtest "$testname" + call_cal_simple "$@" --color=always + ts_finalize_subtest +} MYTIME="7 10 2013" PWEEK="week 40" WEEK="--week=40" -ts_log "Gregorian - Monday-based, $PWEEK, 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3m $WEEK $MYTIME -fi -$TS_CMD_CAL -3m $WEEK $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Sunday-based, $PWEEK, 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3s $WEEK $MYTIME -fi -$TS_CMD_CAL -3s $WEEK $MYTIME >> $TS_OUTPUT - - -ts_log "Julian - Monday-based, $PWEEK, 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mj $WEEK $MYTIME -fi -$TS_CMD_CAL -3mj $WEEK $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Sunday-based, $PWEEK, 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sj $WEEK $MYTIME -fi -$TS_CMD_CAL -3sj $WEEK $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Monday-based, $PWEEK, 1 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -m $WEEK $MYTIME -fi -$TS_CMD_CAL -m $WEEK $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Sunday-based, $PWEEK, 1 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -s $WEEK $MYTIME -fi -$TS_CMD_CAL -s $WEEK $MYTIME >> $TS_OUTPUT - - -ts_log "Julian - Monday-based, $PWEEK, 1 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -mj $WEEK $MYTIME -fi -$TS_CMD_CAL -mj $WEEK $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Sunday-based, $PWEEK, 1 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -sj $WEEK $MYTIME -fi -$TS_CMD_CAL -sj $WEEK $MYTIME >> $TS_OUTPUT +call_cal "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME +call_cal "Gregorian - Sunday-based, $PWEEK, 3 month" -3s $WEEK $MYTIME +call_cal "Julian - Monday-based, $PWEEK, 3 month" -3mj $WEEK $MYTIME +call_cal "Julian - Sunday-based, $PWEEK, 3 month" -3sj $WEEK $MYTIME +call_cal "Gregorian - Monday-based, $PWEEK, 1 month" -m $WEEK $MYTIME +call_cal "Gregorian - Sunday-based, $PWEEK, 1 month" -s $WEEK $MYTIME +call_cal "Julian - Monday-based, $PWEEK, 1 month" -mj $WEEK $MYTIME +call_cal "Julian - Sunday-based, $PWEEK, 1 month" -sj $WEEK $MYTIME + +call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME +call_cal_color "Julian - Monday-based, $PWEEK, 3 month" -3mj $WEEK $MYTIME # tricky year, starts with a bit of 53 yet ends during 52 MYTIME="2010" PWEEK="week 53" WEEK="--week=53" -ts_log "Gregorian - Monday-based, $PWEEK, 1 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1m $WEEK $MYTIME -fi -$TS_CMD_CAL -1m $WEEK $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Monday-based, $PWEEK, 1 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mj $WEEK $MYTIME -fi -$TS_CMD_CAL -1mj $WEEK $MYTIME >> $TS_OUTPUT - -MYTIME="2010" -PWEEK="week 53 with colors" -WEEK="--week=53 --color=always" -ts_log "Gregorian - Monday-based, $PWEEK, 1 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1m $WEEK $MYTIME -fi -$TS_CMD_CAL -1m $WEEK $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Monday-based, $PWEEK, 1 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mj $WEEK $MYTIME -fi -$TS_CMD_CAL -1mj $WEEK $MYTIME >> $TS_OUTPUT - -MYTIME="7 10 2013" -PWEEK="week 40 with colors" -WEEK="--week=40 --color=always" -ts_log "Gregorian - Monday-based, $PWEEK, 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3m $WEEK $MYTIME -fi -$TS_CMD_CAL -3m $WEEK $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Monday-based, $PWEEK, 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mj $WEEK $MYTIME -fi -$TS_CMD_CAL -3mj $WEEK $MYTIME >> $TS_OUTPUT +call_cal "Gregorian - Monday-based, $PWEEK, 1 month" -1m $WEEK $MYTIME +call_cal "Julian - Monday-based, $PWEEK, 1 month" -1mj $WEEK $MYTIME +call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME +call_cal_color "Gregorian - Monday-based, $PWEEK, 1 month" -1m $WEEK $MYTIME +call_cal_color "Julian - Monday-based, $PWEEK, 1 month" -1mj $WEEK $MYTIME MYTIME="31 12 2000" -PWEEK="week 54 with colors" -WEEK="--week=54 --color=always" -ts_log "Gregorian - Sunday-based, $PWEEK, 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL --three --sunday $WEEK $MYTIME -fi -$TS_CMD_CAL --three --sunday $WEEK $MYTIME >> $TS_OUTPUT - -PWEEK="week 53 with colors" -WEEK="--week=53 --color=always" -ts_log "Gregorian - Monday-based, $PWEEK, 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL --three --monday $WEEK $MYTIME -fi -$TS_CMD_CAL --three --monday $WEEK $MYTIME >> $TS_OUTPUT 2>&1 - -PWEEK="week 52 with colors" -WEEK="--week=52 --color=always" -ts_log "Gregorian - Monday-based, $PWEEK, 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL --three --monday $WEEK $MYTIME -fi -$TS_CMD_CAL --three --monday $WEEK $MYTIME >> $TS_OUTPUT 2>&1 +PWEEK="week 54" +WEEK="--week=54" +call_cal_color "Gregorian - Sunday-based, $PWEEK, 3 month" -3s $WEEK $MYTIME +MYTIME="31 12 2000" +PWEEK="week 52" +WEEK="--week=52" +call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME ts_finalize diff --git a/tests/ts/cal/weeknum b/tests/ts/cal/weeknum index 3a8f376e6..f2aec9474 100755 --- a/tests/ts/cal/weeknum +++ b/tests/ts/cal/weeknum @@ -28,62 +28,30 @@ export TERM=linux USETERM=$( ts_has_option "useterm" "$*" ) [ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" -for x in 2001 2002 2003 2009 2010 2011 2012 ; do -MYTIME="1 $x" - -ts_log "Gregorian - Monday-based week with week numbers - year $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ymw $MYTIME -fi -$TS_CMD_CAL -ymw $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Sunday-based week with week numbers - year $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ysw $MYTIME -fi -$TS_CMD_CAL -ysw $MYTIME >> $TS_OUTPUT - - -ts_log "Julian - Monday-based week with week numbers - year $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ymjw $MYTIME -fi -$TS_CMD_CAL -ymjw $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Sunday-based week with week numbers - year $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ysjw $MYTIME -fi -$TS_CMD_CAL -ysjw $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Monday-based week with week numbers - 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mw $MYTIME -fi -$TS_CMD_CAL -3mw $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Sunday-based week with week numbers - 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sw $MYTIME -fi -$TS_CMD_CAL -3sw $MYTIME >> $TS_OUTPUT - - -ts_log "Julian - Monday-based week with week numbers - 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mjw $MYTIME -fi -$TS_CMD_CAL -3mjw $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Sunday-based week with week numbers - 3 month $x" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sjw $MYTIME -fi -$TS_CMD_CAL -3sjw $MYTIME >> $TS_OUTPUT - -done +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') + + ts_init_subtest "$testname" + ts_log "$1" + shift + for x in 2001 2002 2003 2009 2010 2011 2012 ; do + if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL "$@" 1 $x + fi + $TS_CMD_CAL "$@" 1 $x >> $TS_OUTPUT + done + ts_finalize_subtest +} + +call_cal "Gregorian - Monday-based week with week numbers" -ymw +call_cal "Gregorian - Sunday-based week with week numbers" -ysw +call_cal "Julian - Monday-based week with week numbers" -ymjw +call_cal "Julian - Sunday-based week with week numbers" -ysjw +call_cal "Gregorian - Monday-based week with week number" -3mw +call_cal "Gregorian - Sunday-based week with week numbers - 3 month" -3sw +call_cal "Julian - Monday-based week with week numbers - 3 month" -3mjw +call_cal "Julian - Sunday-based week with week numbers - 3 month" -3sjw ts_finalize diff --git a/tests/ts/cal/year b/tests/ts/cal/year index 77e847e28..6a8c42eaa 100755 --- a/tests/ts/cal/year +++ b/tests/ts/cal/year @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright (C) 2007 Karel Zak <kzak@redhat.com> +# Copyright (C) 2007-2018 Karel Zak <kzak@redhat.com> # # This file is part of util-linux. # @@ -28,33 +28,27 @@ export TERM=linux USETERM=$( ts_has_option "useterm" "$*" ) MYTIME="29 11 2006" -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" - -ts_log "Gregorian - Monday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ym $MYTIME -fi -$TS_CMD_CAL -ym $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Sunday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ys $MYTIME -fi -$TS_CMD_CAL -ys $MYTIME >> $TS_OUTPUT - - -ts_log "Julian - Monday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ymj $MYTIME -fi -$TS_CMD_CAL -ymj $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Sunday-based week" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ysj $MYTIME -fi -$TS_CMD_CAL -ysj $MYTIME >> $TS_OUTPUT +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') + + ts_init_subtest "$testname" + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL "$@" + fi + $TS_CMD_CAL "$@" >> $TS_OUTPUT + ts_finalize_subtest +} + +call_cal "Gregorian - Monday-based week" -ym $MYTIME +call_cal "Gregorian - Sunday-based week" -ys $MYTIME +call_cal "Julian - Monday-based week" -ymj $MYTIME +call_cal "Julian - Sunday-based week" -ysj $MYTIME +call_cal "Gregorian - Monday-based week with week numbers" -ymw $MYTIME +call_cal "Gregorian - Sunday-based week with week numbers" -ysw $MYTIME +call_cal "Julian - Monday-based week with week numbers" -ymjw $MYTIME +call_cal "Julian - Sunday-based week with week numbers" -ysjw $MYTIME ts_finalize diff --git a/tests/ts/cal/yearw b/tests/ts/cal/yearw deleted file mode 100755 index 2f5d2c40c..000000000 --- a/tests/ts/cal/yearw +++ /dev/null @@ -1,60 +0,0 @@ -#!/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="${0%/*}/../.." -TS_DESC="year with week numbers" - -. $TS_TOPDIR/functions.sh -ts_init "$*" - -ts_check_test_command "$TS_CMD_CAL" - -export TERM=linux - -USETERM=$( ts_has_option "useterm" "$*" ) -MYTIME="29 11 2006" - -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" - -ts_log "Gregorian - Monday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ymw $MYTIME -fi -$TS_CMD_CAL -ymw $MYTIME >> $TS_OUTPUT - -ts_log "Gregorian - Sunday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ysw $MYTIME -fi -$TS_CMD_CAL -ysw $MYTIME >> $TS_OUTPUT - - -ts_log "Julian - Monday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ymjw $MYTIME -fi -$TS_CMD_CAL -ymjw $MYTIME >> $TS_OUTPUT - -ts_log "Julian - Sunday-based week with week numbers" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -ysjw $MYTIME -fi -$TS_CMD_CAL -ysjw $MYTIME >> $TS_OUTPUT - -ts_finalize - diff --git a/tests/ts/column/files/table-sep b/tests/ts/column/files/table-sep index c56bac891..d4c2bf3e7 100644 --- a/tests/ts/column/files/table-sep +++ b/tests/ts/column/files/table-sep @@ -1,5 +1,5 @@ AAA,BBBB,C,DDDD -A,BBB,CCCC,DDD +,BBB,CCCC,DDD AA,BB,,DD AAAA,B,CC,D AA,,CC,DD diff --git a/tests/ts/column/files/table-sep-space b/tests/ts/column/files/table-sep-space new file mode 100644 index 000000000..25d9b5ab0 --- /dev/null +++ b/tests/ts/column/files/table-sep-space @@ -0,0 +1,6 @@ +AAA BBBB C DDDD + BBB CCCC DDD +AA BB DD +AAAA B CC D +AA CC DD +AAAAA BBB CCC DDDD diff --git a/tests/ts/column/table b/tests/ts/column/table index f11c1d794..5c89d5eaf 100755 --- a/tests/ts/column/table +++ b/tests/ts/column/table @@ -36,6 +36,9 @@ ts_init_subtest "input-separator" $TS_CMD_COLUMN --separator ',' --table $TS_SELF/files/table-sep >> $TS_OUTPUT 2>&1 ts_finalize_subtest +ts_init_subtest "input-separator-space" +$TS_CMD_COLUMN --separator "$(echo -e '\t')" --table $TS_SELF/files/table-sep-space >> $TS_OUTPUT 2>&1 +ts_finalize_subtest ts_init_subtest "long" $TS_CMD_COLUMN --table $TS_SELF/files/mountinfo >> $TS_OUTPUT 2>&1 diff --git a/tests/ts/cramfs/fsck-bad-header b/tests/ts/cramfs/fsck-bad-header index 8d5309c35..c71782bde 100755 --- a/tests/ts/cramfs/fsck-bad-header +++ b/tests/ts/cramfs/fsck-bad-header @@ -16,7 +16,7 @@ # GNU General Public License for more details. # TS_TOPDIR="${0%/*}/../.." -TS_DESC="fsck endianness" +TS_DESC="fsck bad header" . $TS_TOPDIR/functions.sh ts_init "$*" @@ -25,14 +25,78 @@ ts_check_test_command "$TS_CMD_MKCRAMFS" ts_check_test_command "$TS_CMD_FSCKCRAMFS" ts_check_prog "dd" -IMAGE_SOURCE="$TS_OUTDIR/${TS_TESTNAME}-data/root" +function num2binary() +{ + local num=$1 + local endian=$2 + + test "$num" -ge 0 -a "$num" -le 4294967295 || return 1 + test "$endian" = "be" -o "$endian" = "le" || return 1 + + # how to do that easier? + if test "$endian" = "be"; then + echo -en "$(printf "%08x" "$1" | sed 's/\(..\)/\\x\1/g')" + else + echo -en "$(printf "%08x" "$1" | sed 's/^\(..\)\(..\)\(..\)\(..\)$/\\x\4\\x\3\\x\2\\x\1/')" + fi +} + +function fsck_loop_sizes() +{ + local endian=$1 # be, le + local seek=$2 # 4 for nopad, 516 for pad + shift 2 # the rest are sizes to loop over + + for size in "$@"; do + ts_log "## size: $size" + cp -a "$IMAGE_FILE" "$IMAGE_FILE.tmp" + num2binary "$size" $endian | + dd of="$IMAGE_FILE.tmp" bs=1 seek="$seek" count=4 conv=notrunc &> /dev/null + $TS_CMD_FSCKCRAMFS "$IMAGE_FILE.tmp" >> $TS_OUTPUT 2>&1 + ts_log "ret: $? +" + done + rm -f "$IMAGE_FILE" +} + + +IMAGE_SOURCE="$TS_OUTDIR/${TS_TESTNAME}-data" IMAGE_FILE="$TS_OUTDIR/${TS_TESTNAME}-cramfs.img" mkdir -p "${IMAGE_SOURCE}/subdir" &> /dev/null -$TS_CMD_MKCRAMFS -p -N big $IMAGE_SOURCE $IMAGE_FILE &> /dev/null -echo -ne \\00\\x4c | - dd of=$IMAGE_FILE bs=1 seek=518 count=2 conv=notrunc &> /dev/null -$TS_CMD_FSCKCRAMFS $IMAGE_FILE >> $TS_OUTPUT 2>&1 + +ts_init_subtest "nopad-4K-be" +$TS_CMD_MKCRAMFS -N big -b 4096 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes be 4 0 75 76 4095 4096 4097 4294967295 +rm -f "$IMAGE_FILE" +ts_finalize_subtest + +ts_init_subtest "nopad-4K-le" +$TS_CMD_MKCRAMFS -N little -b 4096 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes le 4 0 75 76 4095 4096 4097 4294967295 +ts_finalize_subtest + +ts_init_subtest "pad-4K-be" +$TS_CMD_MKCRAMFS -p -N big -b 4096 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes be 516 76 587 588 4095 4096 4097 4294967295 +ts_finalize_subtest + +ts_init_subtest "pad-4K-le" +$TS_CMD_MKCRAMFS -p -N little -b 4096 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes le 516 76 587 588 4095 4096 4097 4294967295 +ts_finalize_subtest + +ts_init_subtest "pad-64K-be" +$TS_CMD_MKCRAMFS -p -N big -b 65536 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes be 516 76 587 588 65535 65536 65537 4294967295 +ts_finalize_subtest + +ts_init_subtest "pad-64K-le" +$TS_CMD_MKCRAMFS -p -N little -b 65536 $IMAGE_SOURCE $IMAGE_FILE &> /dev/null +fsck_loop_sizes le 516 76 587 588 65535 65536 65537 4294967295 +ts_finalize_subtest + +rm -rf "$IMAGE_SOURCE" "$IMAGE_FILE.tmp" ts_finalize diff --git a/tests/ts/fdisk/align-512-4K-md b/tests/ts/fdisk/align-512-4K-md index 04c3df68e..7f60a654f 100755 --- a/tests/ts/fdisk/align-512-4K-md +++ b/tests/ts/fdisk/align-512-4K-md @@ -56,14 +56,18 @@ udevadm settle ts_log "Alignment offsets:" cat /sys/block/${DEVNAME}/${DEVNAME}{1,2}/alignment_offset >> $TS_OUTPUT 2>&1 +ts_lock "md" + MD_DEVNAME=md8 MD_DEVICE=/dev/${MD_DEVNAME} mdadm -q -S ${MD_DEVICE} &> /dev/null +udevadm settle + mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 \ --level=0 --raid-devices=2 ${TS_DEVICE}1 ${TS_DEVICE}2 >> $TS_OUTPUT 2>&1 - udevadm settle + ts_log "Create partitions (MD)" $TS_CMD_FDISK ${MD_DEVICE} >> $TS_OUTPUT 2>&1 <<EOF n @@ -87,6 +91,9 @@ cat /sys/block/${MD_DEVNAME}/${MD_DEVNAME}p{1,2}/alignment_offset >> $TS_OUTPUT mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>&1 +udevadm settle +ts_unlock "md" + ts_fdisk_clean $TS_DEVICE ts_fdisk_clean $MD_DEVICE diff --git a/tests/ts/fincore/count b/tests/ts/fincore/count index 0b6f24dfe..46700a32e 100755 --- a/tests/ts/fincore/count +++ b/tests/ts/fincore/count @@ -8,6 +8,9 @@ ts_init "$*" ts_check_test_command "$TS_HELPER_SYSINFO" +# Send patch if you know how to keep it portable and robust. Thanks. +TS_KNOWN_FAIL="yes" + function header { echo "[" "$1" "]" diff --git a/tests/ts/getopt/options b/tests/ts/getopt/options index c9ac53dd3..fee51195e 100755 --- a/tests/ts/getopt/options +++ b/tests/ts/getopt/options @@ -90,7 +90,7 @@ gnu_getopt_clean ts_finalize_subtest ts_init_subtest longopts -$TS_CMD_GETOPT -o a -l long1,secondlong:,thirdlong::,abbriviation: -- --long1 EXTRA1 --thirdlong=ARGUMENT --secondlong=ARG --abbr ABBRARG -a >> $TS_OUTPUT 2>&1 +$TS_CMD_GETOPT -o a -l long1,secondlong:,thirdlong::,abbreviation: -- --long1 EXTRA1 --thirdlong=ARGUMENT --secondlong=ARG --abbr ABBRARG -a >> $TS_OUTPUT 2>&1 echo "exit value: $?" >> $TS_OUTPUT gnu_getopt_clean ts_finalize_subtest diff --git a/tests/ts/ipcs/limits b/tests/ts/ipcs/limits index f038b6cd0..7b64b3c17 100755 --- a/tests/ts/ipcs/limits +++ b/tests/ts/ipcs/limits @@ -29,6 +29,8 @@ ts_check_prog "bc" . $TS_SELF/functions.sh +ts_lock "ipcslimits" + ts_log "load original values" for i in $IPCS_IDX; do SHM_ORG[$i]=$(cat ${IPCS_PROCFILES[$i]}) diff --git a/tests/ts/ipcs/limits2 b/tests/ts/ipcs/limits2 index 62a4f5bcb..d23c41a35 100755 --- a/tests/ts/ipcs/limits2 +++ b/tests/ts/ipcs/limits2 @@ -27,6 +27,8 @@ ts_check_prog "bc" . $TS_SELF/functions.sh +ts_lock "ipcslimits" + ts_log "check for difference between kernel and IPC" ipcs_limits_check >> $TS_OUTPUT diff --git a/tests/ts/libmount/context b/tests/ts/libmount/context index 3b49801d4..3750c701f 100755 --- a/tests/ts/libmount/context +++ b/tests/ts/libmount/context @@ -53,7 +53,7 @@ DEVICE="${TS_DEVICE}1" udevadm settle -grep -q $DEVNAME /proc/partitions +grep -q " $DEVNAME\$" /proc/partitions if [ $? -ne 0 ]; then ts_skip "no partition!" fi @@ -111,7 +111,9 @@ ts_init_subtest "mount-by-uuid" mkdir -p $MOUNTPOINT &> /dev/null ts_run $TESTPROG --mount UUID="$UUID" $MOUNTPOINT >> $TS_OUTPUT 2>&1 is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>&1 +sleep 1 ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1 +sleep 1 is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>&1 ts_finalize_subtest diff --git a/tests/ts/libmount/context-py b/tests/ts/libmount/context-py index b4e22b400..dfc8faaee 100755 --- a/tests/ts/libmount/context-py +++ b/tests/ts/libmount/context-py @@ -58,7 +58,7 @@ DEVICE="${TS_DEVICE}1" udevadm settle -grep -q $DEVNAME /proc/partitions +grep -q " $DEVNAME\$" /proc/partitions if [ $? -ne 0 ]; then ts_skip "no partition!" fi @@ -77,7 +77,7 @@ function is_mounted { ts_is_mounted "$1" return $? fi - grep -q "$1" $LIBMOUNT_MTAB && return 0 + grep -q "\(^\| \)$1 " $LIBMOUNT_MTAB && return 0 return 1 } diff --git a/tests/ts/libmount/context-utab b/tests/ts/libmount/context-utab index 24d528d87..a63ba57d6 100755 --- a/tests/ts/libmount/context-utab +++ b/tests/ts/libmount/context-utab @@ -44,7 +44,7 @@ DEVICE="${TS_DEVICE}1" udevadm settle -grep -q $DEVNAME /proc/partitions +grep -q " $DEVNAME\$" /proc/partitions if [ $? -ne 0 ]; then ts_skip "no partition!" fi @@ -67,14 +67,14 @@ udevadm settle ts_init_subtest "mount-by-devname" mkdir -p $MOUNTPOINT &> /dev/null ts_run $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1 -grep -q $DEVICE /proc/mounts || \ +ts_is_mounted "$DEVICE" || \ echo "(by device) cannot find $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1 ts_finalize_subtest ts_init_subtest "umount-by-devname" ts_run $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>&1 -grep -q $DEVICE /proc/mounts && +ts_is_mounted "$DEVICE" && echo "umount (device) failed: found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1 ts_finalize_subtest @@ -82,14 +82,14 @@ ts_finalize_subtest ts_init_subtest "mount-uhelper" mkdir -p $MOUNTPOINT &> /dev/null ts_run $TESTPROG --mount -o uhelper=foo,rw LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>&1 -grep -q $DEVICE $LIBMOUNT_UTAB || \ +grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \ echo "(by label) cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 ts_finalize_subtest ts_init_subtest "umount" ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1 -grep -q $DEVICE $LIBMOUNT_UTAB && \ +grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 ts_finalize_subtest @@ -109,7 +109,7 @@ if type "mkfs.btrfs" &>/dev/null && mkfs.btrfs --version &>/dev/null; then ts_init_subtest "mount-uhelper-subvol" mkdir -p $MOUNTPOINT &> /dev/null ts_run $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1 - grep -q $DEVICE $LIBMOUNT_UTAB || \ + grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \ echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 ts_finalize_subtest @@ -123,7 +123,7 @@ if type "mkfs.btrfs" &>/dev/null && mkfs.btrfs --version &>/dev/null; then ts_init_subtest "umount-subvol" ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1 - grep -q $DEVICE $LIBMOUNT_UTAB && \ + grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 ts_finalize_subtest fi diff --git a/tests/ts/libmount/context-utab-py b/tests/ts/libmount/context-utab-py index 94c957d91..89fc0c157 100755 --- a/tests/ts/libmount/context-utab-py +++ b/tests/ts/libmount/context-utab-py @@ -45,7 +45,7 @@ DEVICE="${TS_DEVICE}1" udevadm settle -grep -q $DEVNAME /proc/partitions +grep -q " $DEVNAME\$" /proc/partitions if [ $? -ne 0 ]; then ts_skip "no partition!" fi @@ -68,14 +68,14 @@ udevadm settle ts_init_subtest "mount-by-devname" mkdir -p $MOUNTPOINT &> /dev/null $PYTHON $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1 -grep -q $DEVICE /proc/mounts || \ +ts_is_mounted "$DEVICE" || \ echo "(by device) cannot find $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1 ts_finalize_subtest ts_init_subtest "umount-by-devname" $PYTHON $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>&1 -grep -q $DEVICE /proc/mounts && +ts_is_mounted "$DEVICE" && echo "umount (device) failed: found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1 ts_finalize_subtest @@ -83,14 +83,14 @@ ts_finalize_subtest ts_init_subtest "mount-uhelper" mkdir -p $MOUNTPOINT &> /dev/null $PYTHON $TESTPROG --mount -o uhelper=foo,rw LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>&1 -grep -q $DEVICE $LIBMOUNT_UTAB || \ +grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \ echo "(by label) cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 ts_finalize_subtest ts_init_subtest "umount" $PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1 -grep -q $DEVICE $LIBMOUNT_UTAB && \ +grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 ts_finalize_subtest @@ -110,7 +110,7 @@ if type "mkfs.btrfs" &>/dev/null && mkfs.btrfs --version &>/dev/null; then ts_init_subtest "mount-uhelper-subvol" mkdir -p $MOUNTPOINT &> /dev/null $PYTHON $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1 - grep -q $DEVICE $LIBMOUNT_UTAB || \ + grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \ echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 ts_finalize_subtest diff --git a/tests/ts/libmount/files/swaps b/tests/ts/libmount/files/swaps new file mode 100644 index 000000000..13ce933cb --- /dev/null +++ b/tests/ts/libmount/files/swaps @@ -0,0 +1,4 @@ +Filename Type Size Used Priority +/dev/dm-2 partition 8151036 2283436 -2 +/some/swapfile file 111 111 0 +/some/swapfile2\040(deleted) file 111 111 0 diff --git a/tests/ts/libmount/lock b/tests/ts/libmount/lock index 816612484..7ba678baf 100755 --- a/tests/ts/libmount/lock +++ b/tests/ts/libmount/lock @@ -21,7 +21,7 @@ TESTPROG="$TS_HELPER_LIBMOUNT_LOCK" # # Note: the original version (< 2.13) of util-linux is completely useless for # this test (maximum for this old version is NLOOPS=10 and NPROCESSES=5 (2-way -# 2GHz machine)). It has terrible performance due a bad timeouts implemntation +# 2GHz machine)). It has terrible performance due a bad timeouts implementation # in lock_mtab(). # NLOOPS=1000 diff --git a/tests/ts/libmount/loop b/tests/ts/libmount/loop index ec22c9a2c..b52b7476a 100755 --- a/tests/ts/libmount/loop +++ b/tests/ts/libmount/loop @@ -81,14 +81,19 @@ ts_log "Success" ts_finalize_subtest ts_init_subtest "o-loop-val" -[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT -LODEV=$( $TS_CMD_LOSETUP --find 2>> $TS_OUTPUT ) -$TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1 -verify_mount_dev "$LODEV" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1 -$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1 -udevadm settle -ts_log "Success" -ts_finalize_subtest +if [ "$TS_PARALLEL" = "yes" ]; then + # There is a race in $LODEV is usage + ts_skip_subtest "no-reentrant" +else + [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + LODEV=$( $TS_CMD_LOSETUP --find 2>> $TS_OUTPUT ) + $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1 + verify_mount_dev "$LODEV" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1 + $TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1 + udevadm settle + ts_log "Success" + ts_finalize_subtest +fi ts_init_subtest "reuse" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT @@ -113,8 +118,7 @@ ts_finalize_subtest ts_init_subtest "o-loop-val-initialized" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT -LODEV=$( $TS_CMD_LOSETUP --find 2>> $TS_OUTPUT ) -$TS_CMD_LOSETUP $LODEV "$BACKFILE" >> $TS_OUTPUT 2>&1 +LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE" 2>>$TS_OUTPUT) $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \ | sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT $TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1 @@ -125,8 +129,7 @@ ts_finalize_subtest ts_init_subtest "o-loop-val-conflict" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT cp "$BACKFILE" "$BACKFILE"-2 -LODEV=$( $TS_CMD_LOSETUP --find 2>> $TS_OUTPUT ) -$TS_CMD_LOSETUP $LODEV "$BACKFILE"-2 >> $TS_OUTPUT 2>&1 +LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE"-2 2>> $TS_OUTPUT) $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \ | sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT $TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1 diff --git a/tests/ts/libmount/loop-overlay b/tests/ts/libmount/loop-overlay index df096bf30..fffb823c0 100755 --- a/tests/ts/libmount/loop-overlay +++ b/tests/ts/libmount/loop-overlay @@ -54,8 +54,7 @@ $TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1 $TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>&1 echo "both should fail" >>$TS_OUTPUT -LOOPDEV=$($TS_CMD_LOSETUP --find) -$TS_CMD_LOSETUP --offset 1 --sizelimit $OFFSET $LOOPDEV "$IMG" +LOOPDEV=$($TS_CMD_LOSETUP --show -f --offset 1 --sizelimit $OFFSET "$IMG") $TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" 2>&1 \ | sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \ diff --git a/tests/ts/libmount/tabfiles b/tests/ts/libmount/tabfiles index ba424b24d..a45c28606 100755 --- a/tests/ts/libmount/tabfiles +++ b/tests/ts/libmount/tabfiles @@ -37,6 +37,11 @@ ts_run $TESTPROG --parse "$TS_SELF/files/mountinfo" &> $TS_OUTPUT sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT ts_finalize_subtest +ts_init_subtest "parse-swaps" +ts_run $TESTPROG --parse "$TS_SELF/files/swaps" &> $TS_OUTPUT +sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +ts_finalize_subtest + ts_init_subtest "copy" ts_run $TESTPROG --copy-fs "$TS_SELF/files/fstab" &> $TS_OUTPUT sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT diff --git a/tests/ts/libmount/tabfiles-tags b/tests/ts/libmount/tabfiles-tags index 4933876d4..38858f47b 100755 --- a/tests/ts/libmount/tabfiles-tags +++ b/tests/ts/libmount/tabfiles-tags @@ -26,9 +26,8 @@ UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9" # Create filesystem # mkfs.ext3 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext3 on $TS_DEVICE" -udevadm settle - -ts_device_has_uuid $TS_DEVICE || ts_die "Cannot find UUID on $TS_DEVICE" +ts_device_has "LABEL" "$LABEL" "$TS_DEVICE" || ts_die "Cannot find LABEL '$LABEL' on $TS_DEVICE" +ts_device_has "UUID" "$UUID" "$TS_DEVICE" || ts_die "Cannot find $UUID on $TS_DEVICE" FSTAB="$TS_OUTDIR/fstab" @@ -36,6 +35,7 @@ FSTAB="$TS_OUTDIR/fstab" # Label in fstab # echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB +ts_udevadm_settle "$TS_DEVICE" "LABEL" "UUID" ts_init_subtest "fstab-label2uuid" ts_run $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT diff --git a/tests/ts/libmount/tabfiles-tags-py b/tests/ts/libmount/tabfiles-tags-py index c1ad596bf..5e72a6f90 100755 --- a/tests/ts/libmount/tabfiles-tags-py +++ b/tests/ts/libmount/tabfiles-tags-py @@ -30,9 +30,8 @@ UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9" # Create filesystem # mkfs.ext3 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext3 on $TS_DEVICE" -udevadm settle - -ts_device_has_uuid $TS_DEVICE || ts_die "Cannot find UUID on $TS_DEVICE" +ts_device_has "LABEL" "$LABEL" "$TS_DEVICE" || ts_die "Cannot find LABEL '$LABEL' on $TS_DEVICE" +ts_device_has "UUID" "$UUID" "$TS_DEVICE" || ts_die "Cannot find $UUID on $TS_DEVICE" FSTAB="$TS_OUTDIR/fstab" @@ -40,6 +39,7 @@ FSTAB="$TS_OUTDIR/fstab" # Label in fstab # echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB +ts_udevadm_settle "$DEVICE" "LABEL" "UUID" ts_init_subtest "fstab-label2uuid" $PYTHON $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT diff --git a/tests/ts/losetup/losetup-loop b/tests/ts/losetup/losetup-loop index 6ec521e3a..037e5c7c6 100755 --- a/tests/ts/losetup/losetup-loop +++ b/tests/ts/losetup/losetup-loop @@ -47,7 +47,7 @@ $TS_CMD_LOSETUP -d "$LODEV" LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE ) udevadm settle dd if=/dev/zero of="$LODEV" count=1 bs=1 >/dev/null 2>&1 -$TS_CMD_LOSETUP --list | grep -q "$LODEV" +$TS_CMD_LOSETUP --list | grep -q "$LODEV\b" ts_log $? udevadm settle $TS_CMD_LOSETUP -d "$LODEV" >/dev/null 2>&1 @@ -202,34 +202,44 @@ ts_finalize_subtest udevadm settle ts_init_subtest "plain-conflict" -LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE ) -if [ -z "$LODEV" ]; then - ts_log "Failed to create loop device" +if [ "$TS_PARALLEL" = "yes" ]; then + # There is a race in $LODEV is usage + ts_skip_subtest "no-reentrant" +else + LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE ) + if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" + fi + LODEVR=$( $TS_CMD_LOSETUP --find ) + $TS_CMD_LOSETUP --nooverlap "$LODEVR" $BACKFILE >/dev/null 2>&1 + ts_log $? + udevadm settle + $TS_CMD_LOSETUP -d "$LODEV" + $TS_CMD_LOSETUP -d "$LODEVR" >/dev/null 2>&1 + ts_log "Success" + ts_finalize_subtest fi -LODEVR=$( $TS_CMD_LOSETUP --find ) -$TS_CMD_LOSETUP --nooverlap "$LODEVR" $BACKFILE >/dev/null 2>&1 -ts_log $? -udevadm settle -$TS_CMD_LOSETUP -d "$LODEV" -$TS_CMD_LOSETUP -d "$LODEVR" >/dev/null 2>&1 -ts_log "Success" -ts_finalize_subtest udevadm settle ts_init_subtest "plain-readonly" -LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show --read-only $BACKFILE ) -if [ -z "$LODEV" ]; then - ts_log "Failed to create loop device" +if [ "$TS_PARALLEL" = "yes" ]; then + # There is a race in $LODEV is usage + ts_skip_subtest "no-reentrant" +else + LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show --read-only $BACKFILE ) + if [ -z "$LODEV" ]; then + ts_log "Failed to create loop device" + fi + LODEVR=$( $TS_CMD_LOSETUP --find ) + $TS_CMD_LOSETUP --nooverlap "$LODEVR" $BACKFILE >/dev/null 2>&1 + ts_log $? + udevadm settle + $TS_CMD_LOSETUP -d "$LODEV" + $TS_CMD_LOSETUP -d "$LODEVR" >/dev/null 2>&1 + ts_log "Success" + ts_finalize_subtest fi -LODEVR=$( $TS_CMD_LOSETUP --find ) -$TS_CMD_LOSETUP --nooverlap "$LODEVR" $BACKFILE >/dev/null 2>&1 -ts_log $? -udevadm settle -$TS_CMD_LOSETUP -d "$LODEV" -$TS_CMD_LOSETUP -d "$LODEVR" >/dev/null 2>&1 -ts_log "Success" -ts_finalize_subtest udevadm settle diff --git a/tests/ts/lsns/netnsid b/tests/ts/lsns/netnsid new file mode 100755 index 000000000..72c14de6c --- /dev/null +++ b/tests/ts/lsns/netnsid @@ -0,0 +1,72 @@ +#!/bin/bash +# +# Copyright (C) 2017 Masatake YAMATO <yamato@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="${0%/*}/../.." +TS_DESC="NETNSID compare to ip-link" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSNS" +ts_check_prog "ip" +ts_check_prog "dd" +ts_check_prog "mkfifo" +ts_check_prog "sed" +ts_skip_nonroot + +grep -q '#define HAVE_LINUX_NET_NAMESPACE_H' ${top_builddir}/config.h || ts_skip "no netns support" +ts_cd "$TS_OUTDIR" + +vetha=lsns-vetha +vethb=lsns-vethb +NS=LSNS-TEST-NETNSID-NS +FIFO=$TS_OUTDIR/FIFO-NETNSID +NULL=/dev/null + +function cleanup { + ip link delete $vetha 2> $NULL || : + ip netns delete $NS 2> $NULL || : + rm -f $FIFO +} + +cleanup +mkfifo $FIFO + +if ip netns add $NS && + ip link add name $vetha type veth peer name $vethb && + ip link set $vethb netns $NS; then + ip netns exec $NS dd if=$FIFO bs=1 count=2 of=$NULL 2> $NULL & + PID=$! +else + cleanup + ts_skip "failed to initialize" +fi +{ + dd if=/dev/zero bs=1 count=1 2> $NULL + { + ip -o link show dev $vetha > $NULL + IP_ID=$(ip -o link show dev $vetha | sed -ne 's/.* *link-netnsid *\([0-9]*\)/\1/p') + LSNS_ID=$($TS_CMD_LSNS -n -o NETNSID --type net --task $PID | { read VAL; echo $VAL; } ) + } + dd if=/dev/zero bs=1 count=1 2> $NULL +} > $FIFO + +test "$IP_ID" = "$LSNS_ID" +echo $? >> $TS_OUTPUT + +cleanup +ts_finalize diff --git a/tests/ts/lsns/nsfs b/tests/ts/lsns/nsfs new file mode 100755 index 000000000..70cab2b85 --- /dev/null +++ b/tests/ts/lsns/nsfs @@ -0,0 +1,94 @@ +#!/bin/bash +# +# Copyright (C) 2017 Masatake YAMATO <yamato@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="${0%/*}/../.." +TS_DESC="NSFS for ip-netns-add" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_skip_nonroot + +ts_check_test_command "$TS_CMD_LSNS" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_prog "ip" +ts_check_prog "dd" +ts_check_prog "touch" +ts_check_prog "mkfifo" +ts_check_prog "sed" + +grep -q '#define HAVE_LINUX_NET_NAMESPACE_H' ${top_builddir}/config.h || ts_skip "no netns support" + +ts_cd "$TS_OUTDIR" + +NAME1=ABC +NAME2=XYZ +PATH1=/run/netns/$NAME1 +PATH2=$TS_OUTDIR/$NAME2 +FIFO=$TS_OUTDIR/FIFO-NSFS +NULL=/dev/null + +function cleanup { + rm -f $FIFO + $TS_CMD_UMOUNT $PATH2 2> /dev/null || : + rm -f $PATH2 + ip netns delete $NAME1 2> /dev/null || : +} + +cleanup +mkfifo $FIFO + +if ip netns add $NAME1 && + touch ${PATH2} && + $TS_CMD_MOUNT -o bind ${PATH1} ${PATH2}; then + ip netns exec $NAME1 dd if=$FIFO bs=1 count=2 of=$NULL 2> $NULL & + PID=$! +else + cleanup + ts_skip "failed to initialize" +fi +{ + dd if=/dev/zero bs=1 count=1 2> $NULL + LSNS_FULL=$($TS_CMD_LSNS --type net) + NSFS_NAMES_MLINES=$($TS_CMD_LSNS -n -o NSFS --type net --task $PID | { while read VAL; do echo $VAL; done; } ) + NSFS_NAMES_1LINE=$($TS_CMD_LSNS -n -o NSFS --nowrap --type net --task $PID | { while read VAL; do echo $VAL; done; } ) + dd if=/dev/zero bs=1 count=1 2> $NULL +} > $FIFO + +test "$NSFS_NAMES_MLINES" = "$PATH1 +$PATH2" && test "$NSFS_NAMES_1LINE" = "$PATH1,$PATH2" + +RESULT=$? +echo $RESULT >> $TS_OUTPUT + +if [ $RESULT -ne 0 ]; then + echo + echo "**Full-report**" + echo "$LSNS_FULL" + echo "**Paths**" + echo "PATH1: $PATH1" + echo "PATH2: $PATH2" + echo "**Multi-line:**" + echo "$NSFS_NAMES_MLINES" + echo "**One-line:**" + echo "$NSFS_NAMES_1LINE" + echo "****" +fi + +cleanup +ts_finalize diff --git a/tests/ts/minix/mkfs b/tests/ts/minix/mkfs index 7af0b109a..6c3a00247 100755 --- a/tests/ts/minix/mkfs +++ b/tests/ts/minix/mkfs @@ -41,6 +41,7 @@ mkfs_and_mount_minix() { ts_mount "minix" $dev $TS_MOUNTPOINT ts_is_mounted $dev || ts_die "Cannot find $dev in /proc/mounts" ts_log "umount the image" + udevadm settle $TS_CMD_UMOUNT $dev ts_finalize_subtest } diff --git a/tests/ts/misc/flock b/tests/ts/misc/flock index cf3ca5357..6a43fea40 100755 --- a/tests/ts/misc/flock +++ b/tests/ts/misc/flock @@ -19,12 +19,9 @@ TS_DESC="flock" ts_init "$*" ts_check_test_command "$TS_CMD_FLOCK" -ts_check_prog "ps" +ts_check_prog "pgrep" ts_check_prog "timeout" -if ! ps --ppid $$ &>/dev/null; then - ts_skip "no ps --ppid" -fi function do_lock { local opts="$1" @@ -58,7 +55,7 @@ if [ "$pid" -le "0" ] || ! kill -s 0 "$pid" &>/dev/null; then ts_die "unable to run flock" fi # the lock should be established when flock has a child -timeout 1s bash -c "while [ \$(ps --ppid $pid |wc -l) -lt 2 ]; do sleep 0.1 ;done" \ +timeout 1s bash -c "while ! pgrep -P $pid >/dev/null; do sleep 0.1 ;done" \ || ts_die "timeout waiting for flock child" ts_init_subtest "non-block" diff --git a/tests/ts/misc/mbsencode b/tests/ts/misc/mbsencode new file mode 100755 index 000000000..405d34c56 --- /dev/null +++ b/tests/ts/misc/mbsencode @@ -0,0 +1,83 @@ +#!/bin/bash + +# +# Copyright (C) 2018 Vaclav Dolezal <vdolezal@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="${0%/*}/../.." +TS_DESC="mbsencode" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +# These test may fail on some machines (locales, other libc...) +TS_KNOWN_FAIL="yes" + +STRINGS=( +# ASCII + $'foo\tbar baz' + '\\foo.local\bar' + '\\foo.local\xbar' + +# UNICODE + 'über' + $'c\xcc\x8ca\xcc\x81rka' # 'c\u030Ca\u0301rka' + 'Москва́' + '北京' + $'\xc2\x83' # U+0083 + +# INVALID UNICODE + $'\xff' + $'\xe8\xe1\xf9\xa7' +) + +if grep -q '^#define HAVE_WIDECHAR' ${top_builddir}/config.h ;then + HAVE_WIDECHAR=true +else + HAVE_WIDECHAR=false +fi + +ts_init_subtest "safe-ascii" +$TS_HELPER_MBSENCODE --safe "${STRINGS[@]}" >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "invalid-ascii" +if [ "$HAVE_WIDECHAR" = true ]; then + $TS_HELPER_MBSENCODE --invalid "${STRINGS[@]}" >> $TS_OUTPUT 2>&1 + ts_finalize_subtest +else + ts_skip_subtest 'No widechar support' +fi + +ts_init_subtest "safe-utf8" +if [ "$HAVE_WIDECHAR" = true ]; then + LC_ALL=C.UTF-8 \ + $TS_HELPER_MBSENCODE --safe "${STRINGS[@]}" >> $TS_OUTPUT 2>&1 + ts_finalize_subtest +else + ts_skip_subtest 'No widechar support' +fi + +ts_init_subtest "invalid-utf8" +if [ "$HAVE_WIDECHAR" = true ]; then + LC_ALL=C.UTF-8 \ + $TS_HELPER_MBSENCODE --invalid "${STRINGS[@]}" >> $TS_OUTPUT 2>&1 + ts_finalize_subtest +else + ts_skip_subtest 'No widechar support' +fi + +ts_finalize + diff --git a/tests/ts/mount/devname b/tests/ts/mount/devname index 65a1ba217..4db878bb6 100755 --- a/tests/ts/mount/devname +++ b/tests/ts/mount/devname @@ -48,12 +48,12 @@ $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1 ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" -grep -q $DEVICE $MTAB_FILE || +grep -q "\(^\| \)$DEVICE " $MTAB_FILE || echo "mount failed: cannot find $DEVICE in $MTAB_FILE" >> $TS_OUTPUT 2>&1 $TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" -grep -q $DEVICE $MTAB_FILE && +grep -q "\(^\| \)$DEVICE " $MTAB_FILE && echo "umount failed: found $DEVICE in $MTAB_FILE" >> $TS_OUTPUT 2>&1 ts_log "Success" diff --git a/tests/ts/mount/fslists b/tests/ts/mount/fslists index 64859ba38..de485319a 100755 --- a/tests/ts/mount/fslists +++ b/tests/ts/mount/fslists @@ -71,7 +71,7 @@ ts_finalize_subtest ts_init_subtest "type-pattern" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT -$TS_CMD_MOUNT -t nofoo,bar $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1 +$TS_CMD_MOUNT -i -t nofoo,bar $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1 ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" $TS_CMD_UMOUNT $TS_MOUNTPOINT ts_log "Success" @@ -80,7 +80,7 @@ ts_finalize_subtest ts_init_subtest "type-pattern-neg" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT -$TS_CMD_MOUNT -t nofoo,bar,ext3,ext2,ext4 $DEVICE $TS_MOUNTPOINT &> /dev/null +$TS_CMD_MOUNT -i -t nofoo,bar,ext3,ext2,ext4 $DEVICE $TS_MOUNTPOINT &> /dev/null ts_is_mounted $DEVICE && ts_die "$DEVICE unexpectedly mounted" ts_log "Success" ts_finalize_subtest diff --git a/tests/ts/mount/fstab-broken b/tests/ts/mount/fstab-broken index 67dfa6e81..947e3af7a 100755 --- a/tests/ts/mount/fstab-broken +++ b/tests/ts/mount/fstab-broken @@ -31,6 +31,7 @@ ts_skip_nonroot MNT=$TS_MOUNTPOINT mkdir -p $MNT +ts_fstab_lock ts_fstab_open echo "tmpd $MNT tmpfs" >> /etc/fstab ts_fstab_close @@ -72,7 +73,7 @@ else fi ts_finalize_subtest -ts_fstab_clean +ts_fstab_clean # this unlocks too ts_log "Success" ts_finalize diff --git a/tests/ts/mount/fstab-btrfs b/tests/ts/mount/fstab-btrfs index 6abbd0be1..090f52304 100755 --- a/tests/ts/mount/fstab-btrfs +++ b/tests/ts/mount/fstab-btrfs @@ -78,15 +78,18 @@ $TS_CMD_UMOUNT "$TS_MOUNTPOINT_CREATE" ts_init_subtest "btrfs" +ts_fstab_lock +ts_fstab_open # Tests with fs == btrfs # mounting default subvolume, deep in the structure, without entry in fstab -ts_fstab_add "$DEVICE" "$TS_MOUNTPOINT_DEFAULT" "btrfs" "" +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_DEFAULT" "btrfs" "" # mounting default subvolume, deep in the structure -ts_fstab_add "$DEVICE" "$TS_MOUNTPOINT_SUBVOL" "btrfs" "subvol=$NON_DEFAULT_SUBVOL" +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOL" "btrfs" "subvol=$NON_DEFAULT_SUBVOL" # mounting non-default subvolume -ts_fstab_add "$DEVICE" "$TS_MOUNTPOINT_SUBVOLID" "btrfs" "subvolid=$NON_DEFAULT_SUBVOLID" +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOLID" "btrfs" "subvolid=$NON_DEFAULT_SUBVOLID" # test bind mount pointing to subvolume root -ts_fstab_add "$TS_MOUNTPOINT_SUBVOLID" "$TS_MOUNTPOINT_BIND" "auto" "bind" +ts_fstab_addline "$TS_MOUNTPOINT_SUBVOLID" "$TS_MOUNTPOINT_BIND" "auto" "bind" +ts_fstab_close $TS_CMD_MOUNT -a >> $TS_OUTPUT 2>&1 $TS_CMD_MOUNT -a >> $TS_OUTPUT 2>&1 @@ -99,20 +102,24 @@ $TS_CMD_UMOUNT "$TS_MOUNTPOINT_SUBVOLID" >> $TS_OUTPUT 2>&1 # check that everything was unmounted $TS_CMD_MOUNT | grep "$TS_MOUNTPOINT_ANY" >> $TS_OUTPUT 2>&1 -ts_fstab_clean +ts_fstab_clean # this unlock too ts_log "Success" ts_finalize_subtest + ts_init_subtest "auto" +ts_fstab_lock +ts_fstab_open # Tests with fs == auto # mounting default subvolume, deep in the structure, without entry in fstab -ts_fstab_add "$DEVICE" "$TS_MOUNTPOINT_DEFAULT" "auto" "" +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_DEFAULT" "auto" "" # mounting default subvolume, deep in the structure -ts_fstab_add "$DEVICE" "$TS_MOUNTPOINT_SUBVOL" "auto" "subvol=$NON_DEFAULT_SUBVOL" +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOL" "auto" "subvol=$NON_DEFAULT_SUBVOL" # mounting non-default subvolume -ts_fstab_add "$DEVICE" "$TS_MOUNTPOINT_SUBVOLID" "auto" "subvolid=$NON_DEFAULT_SUBVOLID" +ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOLID" "auto" "subvolid=$NON_DEFAULT_SUBVOLID" # test bind mount pointing to subvolume sub-directory -ts_fstab_add "$TS_MOUNTPOINT_SUBVOL/bind-mnt" "$TS_MOUNTPOINT_BIND" "auto" "bind" +ts_fstab_addline "$TS_MOUNTPOINT_SUBVOL/bind-mnt" "$TS_MOUNTPOINT_BIND" "auto" "bind" +ts_fstab_close $TS_CMD_MOUNT -a >> $TS_OUTPUT 2>&1 $TS_CMD_MOUNT -a >> $TS_OUTPUT 2>&1 @@ -125,7 +132,7 @@ $TS_CMD_UMOUNT "$TS_MOUNTPOINT_SUBVOLID" >> $TS_OUTPUT 2>&1 # check that everything was unmounted $TS_CMD_MOUNT | grep "$TS_MOUNTPOINT_ANY" >> $TS_OUTPUT 2>&1 -ts_fstab_clean +ts_fstab_clean # this unlock too ts_log "Success" ts_finalize_subtest diff --git a/tests/ts/mount/fstab-devname b/tests/ts/mount/fstab-devname index 8e391c806..6648784d3 100755 --- a/tests/ts/mount/fstab-devname +++ b/tests/ts/mount/fstab-devname @@ -50,7 +50,5 @@ ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" ts_fstab_clean - ts_log "Success" ts_finalize - diff --git a/tests/ts/mount/fstab-devname2label b/tests/ts/mount/fstab-devname2label index 380b91d03..02ef1ef18 100755 --- a/tests/ts/mount/fstab-devname2label +++ b/tests/ts/mount/fstab-devname2label @@ -33,13 +33,13 @@ ts_device_init DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" - ts_device_has "LABEL" $LABEL $DEVICE \ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT ts_fstab_add "LABEL=$LABEL" +ts_udevadm_settle "$DEVICE" "LABEL" $TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>&1 ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" diff --git a/tests/ts/mount/fstab-devname2uuid b/tests/ts/mount/fstab-devname2uuid index 3ed19d2df..4cd4f4502 100755 --- a/tests/ts/mount/fstab-devname2uuid +++ b/tests/ts/mount/fstab-devname2uuid @@ -32,14 +32,12 @@ ts_device_init DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" - -ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" - -UUID=$(ts_uuid_by_devname $DEVICE) +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT ts_fstab_add "UUID=$UUID" +ts_udevadm_settle "$DEVICE" "UUID" $TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>&1 ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" diff --git a/tests/ts/mount/fstab-label b/tests/ts/mount/fstab-label index bc5a15f4f..be6292d17 100755 --- a/tests/ts/mount/fstab-label +++ b/tests/ts/mount/fstab-label @@ -33,13 +33,13 @@ ts_device_init DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" - ts_device_has "LABEL" $LABEL $DEVICE \ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT ts_fstab_add "LABEL=$LABEL" +ts_udevadm_settle "$DEVICE" "LABEL" # variant A) $TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1 diff --git a/tests/ts/mount/fstab-label2devname b/tests/ts/mount/fstab-label2devname index 3dcaad54a..ee4642e25 100755 --- a/tests/ts/mount/fstab-label2devname +++ b/tests/ts/mount/fstab-label2devname @@ -33,13 +33,13 @@ ts_device_init DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" - ts_device_has "LABEL" $LABEL $DEVICE \ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT ts_fstab_add "$DEVICE" +ts_udevadm_settle "$DEVICE" "LABEL" # variant A) $TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>&1 diff --git a/tests/ts/mount/fstab-label2uuid b/tests/ts/mount/fstab-label2uuid index 486d07041..0d2b93154 100755 --- a/tests/ts/mount/fstab-label2uuid +++ b/tests/ts/mount/fstab-label2uuid @@ -34,17 +34,14 @@ ts_device_init DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" - ts_device_has "LABEL" $LABEL $DEVICE \ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" - -ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" - -UUID=$(ts_uuid_by_devname $DEVICE) +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT ts_fstab_add "UUID=$UUID" +ts_udevadm_settle "$DEVICE" "LABEL" "UUID" # variant A) $TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>&1 diff --git a/tests/ts/mount/fstab-loop b/tests/ts/mount/fstab-loop index 9e17943b1..4104a62a0 100755 --- a/tests/ts/mount/fstab-loop +++ b/tests/ts/mount/fstab-loop @@ -35,12 +35,17 @@ mkfs.ext3 -F $IMG &> /dev/null || ts_die "Cannot make ext3 on $IMG" [ -d "$TS_MOUNTPOINT-1" ] || mkdir -p $TS_MOUNTPOINT-1 [ -d "$TS_MOUNTPOINT-2" ] || mkdir -p $TS_MOUNTPOINT-2 -ts_fstab_add "$IMG" "$TS_MOUNTPOINT-1" "ext3" "loop" +ts_fstab_lock +ts_fstab_open + +ts_fstab_addline "$IMG" "$TS_MOUNTPOINT-1" "ext3" "loop" $TS_CMD_MOUNT -a >> $TS_OUTPUT 2>&1 -ts_fstab_add "$IMG" "$TS_MOUNTPOINT-2" "ext3" "loop" +ts_fstab_addline "$IMG" "$TS_MOUNTPOINT-2" "ext3" "loop" $TS_CMD_MOUNT -a >> $TS_OUTPUT 2>&1 +ts_fstab_close + $TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1 $TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>&1 diff --git a/tests/ts/mount/fstab-uuid b/tests/ts/mount/fstab-uuid index afe414dc4..1c588fc1b 100755 --- a/tests/ts/mount/fstab-uuid +++ b/tests/ts/mount/fstab-uuid @@ -32,14 +32,12 @@ ts_device_init DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" - -ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" - -UUID=$(ts_uuid_by_devname $DEVICE) +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT ts_fstab_add "UUID=$UUID" +ts_udevadm_settle "$DEVICE" "UUID" # varian A) $TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1 diff --git a/tests/ts/mount/fstab-uuid2devname b/tests/ts/mount/fstab-uuid2devname index 3197148bd..39aed65a9 100755 --- a/tests/ts/mount/fstab-uuid2devname +++ b/tests/ts/mount/fstab-uuid2devname @@ -32,14 +32,12 @@ ts_device_init DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" - -ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" - -UUID=$(ts_uuid_by_devname $DEVICE) +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT ts_fstab_add "$DEVICE" +ts_udevadm_settle "$DEVICE" "UUID" # variant A) $TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>&1 diff --git a/tests/ts/mount/fstab-uuid2label b/tests/ts/mount/fstab-uuid2label index 22c5647dd..4676c9a7b 100755 --- a/tests/ts/mount/fstab-uuid2label +++ b/tests/ts/mount/fstab-uuid2label @@ -33,17 +33,14 @@ ts_device_init DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" - ts_device_has "LABEL" $LABEL $DEVICE \ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" - -ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" - -UUID=$(ts_uuid_by_devname $DEVICE) +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT ts_fstab_add "LABEL=$LABEL" +ts_udevadm_settle "$DEVICE" "LABEL" "UUID" # variant A) $TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>&1 diff --git a/tests/ts/mount/label b/tests/ts/mount/label index 09f598e12..45da02b6e 100755 --- a/tests/ts/mount/label +++ b/tests/ts/mount/label @@ -34,11 +34,11 @@ ts_device_init DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" - ts_device_has "LABEL" $LABEL $DEVICE \ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +ts_udevadm_settle "$DEVICE" "LABEL" # variant A) $TS_CMD_MOUNT -L $LABEL $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1 diff --git a/tests/ts/mount/umount-alltargets b/tests/ts/mount/umount-alltargets index 687229a87..69799de77 100755 --- a/tests/ts/mount/umount-alltargets +++ b/tests/ts/mount/umount-alltargets @@ -79,6 +79,8 @@ function multi_mount() { ts_log "prepare: Mount /dev/xxx1 to mnt3" [ -d "${MNT}3" ] || mkdir -p ${MNT}3 $TS_CMD_MOUNT $DEV ${MNT}3 >> $TS_OUTPUT 2>&1 + + udevadm settle } # use the same top-level mountpoint for all sub-tests diff --git a/tests/ts/mount/umount-recursive b/tests/ts/mount/umount-recursive index 85708554f..547217e3a 100755 --- a/tests/ts/mount/umount-recursive +++ b/tests/ts/mount/umount-recursive @@ -87,6 +87,7 @@ ts_log "E) Mount child-bind" mkdir -p $TS_MOUNTPOINT/bindC $TS_CMD_MOUNT --bind $TS_MOUNTPOINT/mntB/mntC $TS_MOUNTPOINT/bindC +udevadm settle $TS_CMD_UMOUNT --recursive $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1 [ $? == 0 ] || ts_die "umount failed" diff --git a/tests/ts/mount/uuid b/tests/ts/mount/uuid index efd2774ed..36f75cef9 100755 --- a/tests/ts/mount/uuid +++ b/tests/ts/mount/uuid @@ -32,12 +32,10 @@ ts_device_init DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" - -ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" - -UUID=$(ts_uuid_by_devname $DEVICE) +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +ts_udevadm_settle "$DEVICE" "UUID" # variant A) $TS_CMD_MOUNT -U $UUID $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1 diff --git a/tests/ts/rename/overwrite b/tests/ts/rename/overwrite new file mode 100755 index 000000000..be5b24d03 --- /dev/null +++ b/tests/ts/rename/overwrite @@ -0,0 +1,31 @@ +#!/bin/bash + +# +# Copyright (C) 2017 Sami Kerola <kerolasa@iki.fi> +# +# 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="${0%/*}/../.." +TS_DESC="overwrite" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_RENAME" +ts_cd "$TS_OUTDIR" + +touch rename_from rename_to +$TS_CMD_RENAME -v --no-overwrite from to rename_from > $TS_OUTPUT 2>&1 +rm rename_from rename_to >> $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/sfdisk/resize b/tests/ts/sfdisk/resize index 308798d5e..4b2ad4f53 100755 --- a/tests/ts/sfdisk/resize +++ b/tests/ts/sfdisk/resize @@ -144,6 +144,7 @@ ${TS_DEVICE}4 : start= 108544, size= 2048, type=83 ${TS_DEVICE}5 : start= 8192, size= 2048, type=83 ${TS_DEVICE}6 : start= 12288, size= 96256, type=83 EOF +udevadm settle # enlarge to use all space behind partition #4 echo ',+,' | $TS_CMD_SFDISK --no-reread -N 4 ${TS_DEVICE} >> $TS_OUTPUT 2>&1 ts_fdisk_clean $TS_DEVICE diff --git a/tests/ts/swapon/devname b/tests/ts/swapon/devname index de9a5f20c..7469dcb18 100755 --- a/tests/ts/swapon/devname +++ b/tests/ts/swapon/devname @@ -38,7 +38,7 @@ ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE" $TS_CMD_SWAPON $DEVICE >> $TS_OUTPUT 2>&1 -grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" +grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $TS_CMD_SWAPOFF $DEVICE diff --git a/tests/ts/swapon/fixpgsz b/tests/ts/swapon/fixpgsz index 01b2e9aff..4479cd8f9 100755 --- a/tests/ts/swapon/fixpgsz +++ b/tests/ts/swapon/fixpgsz @@ -40,7 +40,7 @@ ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE" # $TS_CMD_SWAPON --fixpgsz $DEVICE &> /dev/null -grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" +grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $TS_CMD_SWAPOFF $DEVICE diff --git a/tests/ts/swapon/fixsig b/tests/ts/swapon/fixsig index 3f9e3ff84..c3104a23e 100755 --- a/tests/ts/swapon/fixsig +++ b/tests/ts/swapon/fixsig @@ -41,7 +41,7 @@ ts_device_has "TYPE" "swsuspend" $DEVICE || ts_die "Cannot find swsuspend on $DE # $TS_CMD_SWAPON $DEVICE &> /dev/null -grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" +grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $TS_CMD_SWAPOFF $DEVICE diff --git a/tests/ts/swapon/label b/tests/ts/swapon/label index bbcd771be..1bb5dbb3e 100755 --- a/tests/ts/swapon/label +++ b/tests/ts/swapon/label @@ -34,13 +34,13 @@ DEVICE=$TS_LODEV $TS_CMD_MKSWAP -L $LABEL $DEVICE > /dev/null 2>> $TS_OUTPUT \ || ts_die "Cannot make swap on $DEVICE" - ts_device_has "LABEL" $LABEL $DEVICE \ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" +ts_udevadm_settle "$DEVICE" "LABEL" $TS_CMD_SWAPON -L $LABEL >> $TS_OUTPUT 2>&1 -grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" +grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $TS_CMD_SWAPOFF $DEVICE diff --git a/tests/ts/swapon/uuid b/tests/ts/swapon/uuid index 9f244f39a..70e62d7f9 100755 --- a/tests/ts/swapon/uuid +++ b/tests/ts/swapon/uuid @@ -33,14 +33,12 @@ DEVICE=$TS_LODEV $TS_CMD_MKSWAP $DEVICE > /dev/null 2>> $TS_OUTPUT \ || ts_die "Cannot make swap $DEVICE" - -ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" - -UUID=$(ts_uuid_by_devname $DEVICE) +UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE" +ts_udevadm_settle "$DEVICE" "UUID" $TS_CMD_SWAPON -U $UUID >> $TS_OUTPUT 2>&1 -grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" +grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $TS_CMD_SWAPOFF $DEVICE diff --git a/tests/ts/uuid/uuidd b/tests/ts/uuid/uuidd index 17cf29d06..16dc45e3f 100755 --- a/tests/ts/uuid/uuidd +++ b/tests/ts/uuid/uuidd @@ -23,7 +23,8 @@ ts_check_test_command "$TS_CMD_UUIDD" OUTPUT_FILE="$(mktemp "${TS_OUTDIR}/uuiddXXXXXXXXXXXXX")" UUIDD_PID="$(mktemp -u "${TS_OUTDIR}/uuiddXXXXXXXXXXXXX")" -UUIDD_SOCKET="$(mktemp -u "${TS_OUTDIR}/uuiddXXXXXXXXXXXXX")" +# socket path must be short (SIZEOF_SOCKADDR_UN_SUN_PATH 108) +UUIDD_SOCKET=$(mktemp "/tmp/ultest-$TS_COMPONENT-$TS_TESTNAME-socketXXXXXX") $TS_CMD_UUIDD -p "$UUIDD_PID" -s "$UUIDD_SOCKET" if [ $? -ne 0 ]; then |