summaryrefslogtreecommitdiffstats
path: root/tests/ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ts')
-rw-r--r--tests/ts/blkid/images-fs/bluestore.img.xzbin0 -> 412 bytes
-rw-r--r--tests/ts/blkid/images-fs/drbd-v08.img.xzbin0 -> 448 bytes
-rw-r--r--tests/ts/blkid/images-fs/drbd-v09.img.xzbin0 -> 460 bytes
-rw-r--r--tests/ts/blkid/images-fs/udf-bdr-2.60-nero.img.xzbin0 -> 1956 bytes
-rwxr-xr-xtests/ts/cal/bigyear2
-rwxr-xr-xtests/ts/cal/month9
-rwxr-xr-xtests/ts/cal/sep17522
-rw-r--r--tests/ts/column/files/table-empty-lines6
-rwxr-xr-xtests/ts/column/table12
-rw-r--r--tests/ts/libmount/files/mountinfo_nosrc7
-rwxr-xr-xtests/ts/libmount/tabfiles5
-rw-r--r--tests/ts/lsblk/README19
-rw-r--r--tests/ts/lsblk/dumps/simple-lvm.tar.xzbin0 -> 14216 bytes
-rw-r--r--tests/ts/lsblk/dumps/simple-nvme.tar.xzbin0 -> 10292 bytes
-rwxr-xr-xtests/ts/lsblk/lsblk56
-rw-r--r--tests/ts/lsblk/mk-input.sh109
-rwxr-xr-xtests/ts/lscpu/lscpu2
-rwxr-xr-xtests/ts/lsmem/lsmem2
-rwxr-xr-xtests/ts/lsns/netnsid26
-rwxr-xr-xtests/ts/mount/fstab-btrfs2
-rwxr-xr-xtests/ts/uuid/oids10
21 files changed, 259 insertions, 10 deletions
diff --git a/tests/ts/blkid/images-fs/bluestore.img.xz b/tests/ts/blkid/images-fs/bluestore.img.xz
new file mode 100644
index 000000000..4fd8cbde6
--- /dev/null
+++ b/tests/ts/blkid/images-fs/bluestore.img.xz
Binary files differ
diff --git a/tests/ts/blkid/images-fs/drbd-v08.img.xz b/tests/ts/blkid/images-fs/drbd-v08.img.xz
new file mode 100644
index 000000000..2c8db6b50
--- /dev/null
+++ b/tests/ts/blkid/images-fs/drbd-v08.img.xz
Binary files differ
diff --git a/tests/ts/blkid/images-fs/drbd-v09.img.xz b/tests/ts/blkid/images-fs/drbd-v09.img.xz
new file mode 100644
index 000000000..798042da8
--- /dev/null
+++ b/tests/ts/blkid/images-fs/drbd-v09.img.xz
Binary files differ
diff --git a/tests/ts/blkid/images-fs/udf-bdr-2.60-nero.img.xz b/tests/ts/blkid/images-fs/udf-bdr-2.60-nero.img.xz
new file mode 100644
index 000000000..9fb9a4fec
--- /dev/null
+++ b/tests/ts/blkid/images-fs/udf-bdr-2.60-nero.img.xz
Binary files differ
diff --git a/tests/ts/cal/bigyear b/tests/ts/cal/bigyear
index d205c3afd..34139fd27 100755
--- a/tests/ts/cal/bigyear
+++ b/tests/ts/cal/bigyear
@@ -18,7 +18,7 @@ TS_DESC="Year 2147483646"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-ts_check_test_command "$TS_CMD_CAL"
+ts_check_test_command "$TS_HELPER_CAL"
export TERM=linux
diff --git a/tests/ts/cal/month b/tests/ts/cal/month
index 9794e90c0..62fd1f928 100755
--- a/tests/ts/cal/month
+++ b/tests/ts/cal/month
@@ -22,7 +22,7 @@ TS_DESC="month"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-ts_check_test_command "$TS_CMD_CAL"
+ts_check_test_command "$TS_HELPER_CAL"
export TERM=linux
@@ -33,7 +33,7 @@ CAL_TEST_TIME=1516562739 # 21st January 2018
export CAL_TEST_TIME
function call_cal {
- local testname=$(echo "$2" | sed 's/-//g')
+ local testname=$(echo "$2" | sed 's/-//g; s/ //g')
ts_init_subtest "$testname"
ts_log "$1"
@@ -63,5 +63,10 @@ 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
+call_cal "Normal span" "-Sn 3" $MYTIME
+call_cal "Large span" "-Sn 21" $MYTIME
+call_cal "Very Large span" "-Sn 51" $MYTIME
+call_cal "Extreme span" "-Sn 201" $MYTIME
+
ts_finalize
diff --git a/tests/ts/cal/sep1752 b/tests/ts/cal/sep1752
index 3128261cd..41c30d40e 100755
--- a/tests/ts/cal/sep1752
+++ b/tests/ts/cal/sep1752
@@ -18,7 +18,7 @@ TS_DESC="September 1752"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-ts_check_test_command "$TS_CMD_CAL"
+ts_check_test_command "$TS_HELPER_CAL"
export TERM=linux
diff --git a/tests/ts/column/files/table-empty-lines b/tests/ts/column/files/table-empty-lines
new file mode 100644
index 000000000..9429b4dab
--- /dev/null
+++ b/tests/ts/column/files/table-empty-lines
@@ -0,0 +1,6 @@
+
+A B CCC
+AA BBB AA
+AAA BB C
+
+AAAA BBBB CCCC
diff --git a/tests/ts/column/table b/tests/ts/column/table
index 5c89d5eaf..bd1f16f3f 100755
--- a/tests/ts/column/table
+++ b/tests/ts/column/table
@@ -40,6 +40,14 @@ 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 "empty-lines"
+$TS_CMD_COLUMN --table --table-empty-lines $TS_SELF/files/table-empty-lines >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "noempty-lines"
+$TS_CMD_COLUMN --table $TS_SELF/files/table-empty-lines >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
ts_init_subtest "long"
$TS_CMD_COLUMN --table $TS_SELF/files/mountinfo >> $TS_OUTPUT 2>&1
ts_finalize_subtest
@@ -104,4 +112,8 @@ $TS_CMD_COLUMN --table $TS_SELF/files/mountinfo \
>> $TS_OUTPUT 2>&1
ts_finalize_subtest
+ts_init_subtest "empty-column"
+printf ':a:b\n' | $TS_CMD_COLUMN --table --separator ':' --output-separator ':' >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
ts_finalize
diff --git a/tests/ts/libmount/files/mountinfo_nosrc b/tests/ts/libmount/files/mountinfo_nosrc
new file mode 100644
index 000000000..1ef7cf08b
--- /dev/null
+++ b/tests/ts/libmount/files/mountinfo_nosrc
@@ -0,0 +1,7 @@
+15 20 0:3 / /proc rw,relatime - proc /proc rw
+16 20 0:15 / /sys rw,relatime - sysfs /sys rw
+17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755
+18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
+19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw
+20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered
+21 20 0:53 / /mnt/test rw,relatime shared:212 - tmpfs rw
diff --git a/tests/ts/libmount/tabfiles b/tests/ts/libmount/tabfiles
index a45c28606..ec0eae8e1 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-mountinfo-nosrc"
+ts_run $TESTPROG --parse "$TS_SELF/files/mountinfo_nosrc" &> $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
diff --git a/tests/ts/lsblk/README b/tests/ts/lsblk/README
new file mode 100644
index 000000000..6f937102c
--- /dev/null
+++ b/tests/ts/lsblk/README
@@ -0,0 +1,19 @@
+
+Howto add new lsblk test:
+
+* run mk-input.sh <testname>
+
+* copy testname.tar.xz file to tests/ts/lsblk/dumps
+
+* copy lsblk-* files from the tarball to tests/expected/lsblk/
+
+* run ./tests/run.sh lsblk
+
+* git add tests/ts/lsblk/testname.tar.xz
+ git add tests/expected/lsblk/lsblk-testname*
+
+
+Note that we do not use directly lsblk-* from the tarball. It's better to keep
+copy of the files in the tests/expected/lsblk/, because output formatting may
+be different in the current version. The version in the tarball is just initial
+hint only.
diff --git a/tests/ts/lsblk/dumps/simple-lvm.tar.xz b/tests/ts/lsblk/dumps/simple-lvm.tar.xz
new file mode 100644
index 000000000..b0c8c34ab
--- /dev/null
+++ b/tests/ts/lsblk/dumps/simple-lvm.tar.xz
Binary files differ
diff --git a/tests/ts/lsblk/dumps/simple-nvme.tar.xz b/tests/ts/lsblk/dumps/simple-nvme.tar.xz
new file mode 100644
index 000000000..47229b3ab
--- /dev/null
+++ b/tests/ts/lsblk/dumps/simple-nvme.tar.xz
Binary files differ
diff --git a/tests/ts/lsblk/lsblk b/tests/ts/lsblk/lsblk
new file mode 100755
index 000000000..d51438bc8
--- /dev/null
+++ b/tests/ts/lsblk/lsblk
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# Copyright (C) 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 3 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+TS_TOPDIR="${0%/*}/../.."
+. $TS_TOPDIR/functions.sh
+
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSBLK"
+ts_check_prog xz
+ts_check_prog tar
+
+for dump in $(ls $TS_SELF/dumps/*.tar.xz | sort); do
+ name=$(basename $dump .tar.xz)
+ dumpdir="$TS_OUTDIR/dumps"
+
+ mkdir -p $dumpdir
+ tar -C $dumpdir --xz -xf $dump
+
+ #
+ # Read *.cols from the tarball, but the expected output is not used
+ # from the tarball due to changes in lsblk fomatting etc. We keep up to
+ # date version in tests/expected/lsblk.
+ #
+ for cols_file in $(ls $dumpdir/$name/*.cols | sort); do
+ subname=$(basename $cols_file .cols)
+ subtestname="${name}-${subname}"
+
+ ts_init_subtest $subtestname
+ cols=$(cat $cols_file)
+ ${TS_CMD_LSBLK} --sysroot "${dumpdir}/${name}" \
+ --output $cols \
+ >"${TS_OUTPUT}" 2>&1
+
+ ts_finalize_subtest
+ done
+done
+
+ts_finalize
+
diff --git a/tests/ts/lsblk/mk-input.sh b/tests/ts/lsblk/mk-input.sh
new file mode 100644
index 000000000..8cd467e9a
--- /dev/null
+++ b/tests/ts/lsblk/mk-input.sh
@@ -0,0 +1,109 @@
+#!/bin/bash
+#
+# Copyright (C) 2018 Karel Zak <kzak@redhat.com>
+#
+# This script makes a copy of relevant files from /sys and /proc.
+# The files are useful for lsblk(1) regression tests.
+#
+progname=$(basename $0)
+
+if [ -z "$1" ]; then
+ echo -e "\nusage: $progname <testname>\n"
+ exit 1
+fi
+
+TS_DUMP="$1"
+TS_NAME=$(basename ${TS_DUMP})
+TS_TARBALL="$TS_DUMP.tar.xz"
+TS_CMD_LSBLK=${TS_CMD_LSBLK:-"lsblk"}
+
+#
+# procfs
+#
+mkdir -p $TS_DUMP/proc
+mkdir -p $TS_DUMP/proc/self
+cp /proc/self/mountinfo ${TS_DUMP}/proc/self
+cp /proc/swaps ${TS_DUMP}/proc/swaps
+cp /proc/version ${TS_DUMP}/proc/version
+
+
+#
+# sysfs
+#
+mkdir -p $TS_DUMP/sys/{block,dev/block}
+cp --no-dereference /sys/dev/block/* ${TS_DUMP}/sys/dev/block
+cp --no-dereference /sys/block/* ${TS_DUMP}/sys/block
+
+DEVS=$(find /sys/dev/block/ -type l)
+for x in ${DEVS}; do
+ DEV="/sys/dev/block/$(readlink $x)"
+
+ mkdir -p ${TS_DUMP}/${DEV}
+
+ # attributes
+ for f in $(find ${DEV} -type f -not -path '*/trace/*' -not -path '*/uevent'); do
+ if [ ! -f ${TS_DUMP}/${f} ]; then
+ SUB=$(dirname $f)
+ mkdir -p ${TS_DUMP}/${SUB}
+ cp $f ${TS_DUMP}/$f 2> /dev/null
+ fi
+ done
+
+ # symlinks (slave, holders, etc.)
+ for f in $(find ${DEV} -type l -not -path '*/subsystem' -not -path '*/bdi'); do
+ if [ ! -f ${TS_DUMP}/${f} ]; then
+ SUB=$(dirname $f)
+ mkdir -p ${TS_DUMP}/${SUB}
+ cp --no-dereference $f ${TS_DUMP}/$f
+ fi
+ done
+
+ # device/ files
+ if [ -d ${DEV}/device/ ]; then
+ for f in $(find ${DEV}/device/ -maxdepth 1 -type f -not -path '*/uevent'); do
+ if [ ! -f ${TS_DUMP}/${f} ]; then
+ SUB=$(dirname $f)
+ cp $f ${TS_DUMP}/$f 2> /dev/null
+ fi
+ done
+ fi
+
+done
+
+
+function mk_output {
+ local cols="NAME,${2}"
+ local subname="$1"
+
+ echo "$cols" > ${TS_DUMP}/${subname}.cols
+ $TS_CMD_LSBLK -o ${cols} > ${TS_DUMP}/lsblk-${TS_NAME}-${subname}
+}
+
+
+LANG="POSIX"
+LANGUAGE="POSIX"
+LC_ALL="POSIX"
+CHARSET="UTF-8"
+
+export LANG LANGUAGE LC_ALL CHARSET
+
+#
+# lsblk info
+#
+$TS_CMD_LSBLK -V &> ${TS_DUMP}/version
+
+mk_output basic KNAME,MAJ:MIN,RM,SIZE,TYPE,MOUNTPOINT
+mk_output vendor MODEL,VENDOR,REV
+mk_output state RO,RM,HOTPLUG,RAND,STATE,ROTA,TYPE,PKNAME,SCHED
+mk_output rw RA,WSAME
+mk_output topo SIZE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,RQ-SIZE
+mk_output discard DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO
+mk_output zone ZONED
+
+
+tar --xz -cvf ${TS_TARBALL} $TS_DUMP
+rm -rf $TS_DUMP
+
+echo -e "\nPlease, send ${TS_TARBALL} to util-linux upstream. Thanks!\n"
+
+
diff --git a/tests/ts/lscpu/lscpu b/tests/ts/lscpu/lscpu
index 70fbce9f3..ccf271149 100755
--- a/tests/ts/lscpu/lscpu
+++ b/tests/ts/lscpu/lscpu
@@ -22,6 +22,8 @@ TS_TOPDIR="${0%/*}/../.."
ts_init "$*"
+ts_check_prog "tar"
+ts_check_prog "gzip"
ts_check_test_command "$TS_CMD_LSCPU"
for dump in $(ls $TS_SELF/dumps/*.tar.gz | sort); do
diff --git a/tests/ts/lsmem/lsmem b/tests/ts/lsmem/lsmem
index f1a643f85..bedf4143f 100755
--- a/tests/ts/lsmem/lsmem
+++ b/tests/ts/lsmem/lsmem
@@ -21,6 +21,8 @@ TS_TOPDIR="${0%/*}/../.."
ts_init "$*"
ts_check_test_command "$TS_CMD_LSMEM"
+ts_check_prog "tar"
+ts_check_prog "bzip2"
LSCOLUMNS="RANGE,SIZE,STATE,REMOVABLE,BLOCK,NODE"
diff --git a/tests/ts/lsns/netnsid b/tests/ts/lsns/netnsid
index 72c14de6c..9d04f28f0 100755
--- a/tests/ts/lsns/netnsid
+++ b/tests/ts/lsns/netnsid
@@ -36,6 +36,7 @@ vethb=lsns-vethb
NS=LSNS-TEST-NETNSID-NS
FIFO=$TS_OUTDIR/FIFO-NETNSID
NULL=/dev/null
+LOG=/dev/null #/root/foo.log
function cleanup {
ip link delete $vetha 2> $NULL || :
@@ -43,24 +44,47 @@ function cleanup {
rm -f $FIFO
}
+echo "==Cleanup" >> $LOG
cleanup
+
+echo "==Create FIFO" >> $LOG
mkfifo $FIFO
+echo "==Netns ADD" >> $LOG
if ip netns add $NS &&
ip link add name $vetha type veth peer name $vethb &&
ip link set $vethb netns $NS; then
+ echo "===Netns EXEC" >> $LOG
ip netns exec $NS dd if=$FIFO bs=1 count=2 of=$NULL 2> $NULL &
PID=$!
+ echo "====PID=$PID" >> $LOG
else
cleanup
ts_skip "failed to initialize"
fi
{
+ echo "==Write to FIFO" >> $LOG
dd if=/dev/zero bs=1 count=1 2> $NULL
{
- ip -o link show dev $vetha > $NULL
+ echo "===IP output" >> $LOG
+ ip -o link show dev $vetha >> $LOG
+
IP_ID=$(ip -o link show dev $vetha | sed -ne 's/.* *link-netnsid *\([0-9]*\)/\1/p')
+ echo "====ip show: IP_ID=$IP_ID" >> $LOG
+
+ if [ "x$IP_ID" = "x" ]; then
+ echo "===IP output list id" >> $LOG
+ ip netns list-id >> $LOG
+
+ IP_ID=$(ip netns list-id | awk "/name: $NS/ { print \$2 }")
+ echo "====ip list-id: IP_ID=$IP_ID" >> $LOG
+ fi
+
+ echo "===LSNS output" >> $LOG
+ $TS_CMD_LSNS -o+NETNSID,NSFS --type net >> $LOG
+
LSNS_ID=$($TS_CMD_LSNS -n -o NETNSID --type net --task $PID | { read VAL; echo $VAL; } )
+ echo "===LSNS_ID=$LSNS_ID" >> $LOG
}
dd if=/dev/zero bs=1 count=1 2> $NULL
} > $FIFO
diff --git a/tests/ts/mount/fstab-btrfs b/tests/ts/mount/fstab-btrfs
index 090f52304..54c6bb8ba 100755
--- a/tests/ts/mount/fstab-btrfs
+++ b/tests/ts/mount/fstab-btrfs
@@ -42,7 +42,7 @@ TS_MOUNTPOINT_SUBVOL="$TS_MOUNTPOINT-subvol"
TS_MOUNTPOINT_SUBVOLID="$TS_MOUNTPOINT-subvolid"
TS_MOUNTPOINT_BIND="$TS_MOUNTPOINT-bind"
-ts_device_init 42
+ts_device_init 50
DEVICE=$TS_LODEV
[ -d "$TS_MOUNTPOINT_CREATE" ] || mkdir -p "$TS_MOUNTPOINT_CREATE"
[ -d "$TS_MOUNTPOINT_DEFAULT" ] || mkdir -p "$TS_MOUNTPOINT_DEFAULT"
diff --git a/tests/ts/uuid/oids b/tests/ts/uuid/oids
index 3b005c5b2..77e010c1d 100755
--- a/tests/ts/uuid/oids
+++ b/tests/ts/uuid/oids
@@ -20,12 +20,14 @@ ts_init "$*"
: . > $TS_OUTPUT
-uuidgen --md5 --namespace @dns --name "www.widgets.com" >> $TS_OUTPUT
+ts_check_test_command "$TS_CMD_UUIDGEN"
-uuidgen --md5 --namespace @dns --name "www.example.com" >> $TS_OUTPUT
+$TS_CMD_UUIDGEN --md5 --namespace @dns --name "www.widgets.com" >> $TS_OUTPUT
-uuidgen --sha1 --namespace @dns --name "www.example.com" >> $TS_OUTPUT
+$TS_CMD_UUIDGEN --md5 --namespace @dns --name "www.example.com" >> $TS_OUTPUT
-uuidgen --sha1 --namespace @oid --hex --name "525400fc0f5e" >> $TS_OUTPUT
+$TS_CMD_UUIDGEN --sha1 --namespace @dns --name "www.example.com" >> $TS_OUTPUT
+
+$TS_CMD_UUIDGEN --sha1 --namespace @oid --hex --name "525400fc0f5e" >> $TS_OUTPUT
ts_finalize