summaryrefslogtreecommitdiffstats
path: root/tests/ts/misc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:30:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:30:35 +0000
commit378c18e5f024ac5a8aef4cb40d7c9aa9633d144c (patch)
tree44dfb6ca500d32cabd450649b322a42e70a30683 /tests/ts/misc
parentInitial commit. (diff)
downloadutil-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.tar.xz
util-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.zip
Adding upstream version 2.38.1.upstream/2.38.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/misc')
-rwxr-xr-xtests/ts/misc/fallocate39
-rwxr-xr-xtests/ts/misc/flock106
-rwxr-xr-xtests/ts/misc/ionice30
-rwxr-xr-xtests/ts/misc/line65
-rwxr-xr-xtests/ts/misc/mbsencode85
-rwxr-xr-xtests/ts/misc/mcookie28
-rwxr-xr-xtests/ts/misc/mountpoint36
-rwxr-xr-xtests/ts/misc/rev31
-rwxr-xr-xtests/ts/misc/setarch92
-rwxr-xr-xtests/ts/misc/setsid25
-rwxr-xr-xtests/ts/misc/strtosize62
-rwxr-xr-xtests/ts/misc/swaplabel69
-rwxr-xr-xtests/ts/misc/whereis50
13 files changed, 718 insertions, 0 deletions
diff --git a/tests/ts/misc/fallocate b/tests/ts/misc/fallocate
new file mode 100755
index 0000000..ec3d2d2
--- /dev/null
+++ b/tests/ts/misc/fallocate
@@ -0,0 +1,39 @@
+#!/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="fallocate"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_FALLOCATE"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
+IMAGE=${TS_OUTDIR}/${TS_TESTNAME}.file
+rm -f $IMAGE
+
+if $TS_CMD_FALLOCATE -o 128 -l 256 $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG; then
+ stat -c "%s" $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG
+else
+ # fs type of $TS_OUTDIR, could be used to skip this test early
+ fs_type=$(${TS_CMD_FINDMNT} -n -o FSTYPE -T ${TS_OUTDIR})
+
+ grep -qi "fallocate: fallocate failed:.*not supported" $TS_ERRLOG \
+ && ts_skip "'${fs_type}' not supported"
+fi
+
+rm -f $IMAGE
+
+ts_finalize
diff --git a/tests/ts/misc/flock b/tests/ts/misc/flock
new file mode 100755
index 0000000..6b8edfa
--- /dev/null
+++ b/tests/ts/misc/flock
@@ -0,0 +1,106 @@
+#!/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="flock"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_FLOCK"
+ts_check_prog "pgrep"
+ts_check_prog "timeout"
+
+
+function do_lock {
+ local opts="$1"
+ local expected_rc="$2"
+ local mesg="$3"
+
+ $TS_CMD_FLOCK $1 $TS_OUTDIR/lockfile \
+ echo "$mesg" \
+ >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ local rc="$?"
+
+ if [ "$rc" == "$expected_rc" ]; then
+ ts_log "Success"
+ else
+ ts_log "Failed [rc=$rc]"
+ fi
+}
+
+# general lock
+GEN_OUTPUT="$TS_OUTPUT"
+START=$(date '+%s')
+# running flock in background is not the best usage example
+$TS_CMD_FLOCK --shared $TS_OUTDIR/lockfile \
+ bash -c 'echo "Locking"; sleep 3; echo "Unlocking"' \
+ > $GEN_OUTPUT 2>&1 &
+pid=$!
+
+# check for running background process
+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 ! pgrep -P $pid >/dev/null; do sleep 0.1 ;done" \
+ || ts_die "timeout waiting for flock child"
+
+ts_init_subtest "non-block"
+do_lock "--nonblock --conflict-exit-code 123" 123 "You will never see this!"
+ts_finalize_subtest
+
+
+ts_init_subtest "no-fork"
+do_lock "--no-fork --nonblock --conflict-exit-code 123" 123 "You will never see this!"
+ts_finalize_subtest
+
+
+ts_init_subtest "shared"
+do_lock "--shared" 0 "Have shared lock"
+ts_finalize_subtest
+
+
+# this is the same as non-block test (exclusive lock is the default), but here
+# we explicitly specify --exclusive on command line
+ts_init_subtest "exclusive"
+do_lock "--nonblock --exclusive --conflict-exit-code 123" 123 "You will never see this!"
+ts_finalize_subtest
+
+
+ts_init_subtest "timeout"
+do_lock "--timeout 5 --conflict-exit-code 5" 0 "After timeout."
+END=$(date '+%s')
+ts_finalize_subtest
+
+
+# expected is 3 seconds (see "sleep 3" for the general lock), but we should not
+# rely on exact number due to scheduler, machine load, etc. Let's check for
+# inmterval <3,5>.
+#
+ts_init_subtest "time-check"
+TIMEDIFF=$(( $END - $START ))
+if [ $TIMEDIFF -lt 3 ]; then
+ ts_log "general lock failed [$TIMEDIFF sec]"
+elif [ $TIMEDIFF -gt 5 ]; then
+ ts_log "wait too long [$TIMEDIFF sec]"
+else
+ ts_log "success"
+fi
+ts_finalize_subtest "diff ${TIMEDIFF} sec"
+
+
+echo "Unlocked" >> $GEN_OUTPUT
+ts_finalize
diff --git a/tests/ts/misc/ionice b/tests/ts/misc/ionice
new file mode 100755
index 0000000..81cc0f8
--- /dev/null
+++ b/tests/ts/misc/ionice
@@ -0,0 +1,30 @@
+#!/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="ionice"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_IONICE"
+
+$TS_CMD_IONICE -p $$ -n 0 -c 0 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_IONICE -p $$ -n 3 -c 7 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_IONICE -p $$ -n 4 -c 7 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_IONICE -p $$ -n 1 -c 8 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_IONICE -n 3 ls /etc/passwd >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_IONICE -p $$ >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_finalize
diff --git a/tests/ts/misc/line b/tests/ts/misc/line
new file mode 100755
index 0000000..8424fc7
--- /dev/null
+++ b/tests/ts/misc/line
@@ -0,0 +1,65 @@
+#!/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="line"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LINE"
+ts_check_test_command "$TS_CMD_HEXDUMP"
+
+ts_init_subtest 'one-call'
+printf "a\nb\n" |
+ $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo "ret: $?" >> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest 'two-calls'
+printf "1\n2\n" |
+ ($TS_CMD_LINE && $TS_CMD_LINE) >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo "ret: $?" >> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest 'text-without-eol'
+printf "abc" |
+ $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo "ret: $?" >> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest 'empty-input'
+printf "" |
+ $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo "ret: $?" >> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest 'wait-for-eof'
+(printf "xyz" && cat </dev/null) |
+ $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo "ret: $?" >> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest 'empty-input-wait-for-eof'
+$TS_CMD_LINE </dev/null >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo "ret: $?" >> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest 'large-line'
+dd if=/dev/zero bs=1k count=1k 2>/dev/null |
+ $TS_CMD_LINE line | $TS_CMD_HEXDUMP -C >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo "ret: $?" >> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/misc/mbsencode b/tests/ts/misc/mbsencode
new file mode 100755
index 0000000..cc3a540
--- /dev/null
+++ b/tests/ts/misc/mbsencode
@@ -0,0 +1,85 @@
+#!/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 "$*"
+
+ts_check_test_command $TS_HELPER_MBSENCODE
+
+# 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>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "invalid-ascii"
+if [ "$HAVE_WIDECHAR" = true ]; then
+ $TS_HELPER_MBSENCODE --invalid "${STRINGS[@]}" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ 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>> $TS_ERRLOG
+ 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>> $TS_ERRLOG
+ ts_finalize_subtest
+else
+ ts_skip_subtest 'No widechar support'
+fi
+
+ts_finalize
+
diff --git a/tests/ts/misc/mcookie b/tests/ts/misc/mcookie
new file mode 100755
index 0000000..9931216
--- /dev/null
+++ b/tests/ts/misc/mcookie
@@ -0,0 +1,28 @@
+#!/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="mcookie"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MCOOKIE"
+
+$TS_CMD_MCOOKIE -f /etc/services |
+ # The sed will convert only 32 characters long hexadecimal string
+ # to expected string, but nothing else.
+ sed 's/^[0-9a-f]\{32\}$/the string meets expecations/' >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_finalize
diff --git a/tests/ts/misc/mountpoint b/tests/ts/misc/mountpoint
new file mode 100755
index 0000000..e52ccb2
--- /dev/null
+++ b/tests/ts/misc/mountpoint
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="mountpoint"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNTPOINT"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
+# / is not always a mountpoint (chroots etc.), so check if it is and otherwise
+# fallback to the first available mountpoint.
+FIRST_MOUNTPOINT=$($TS_CMD_FINDMNT -no TARGET / || $TS_CMD_FINDMNT -fno TARGET)
+
+[ -z "$FIRST_MOUNTPOINT" ] && ts_skip "no mountpoint found for symlink tests"
+
+ln -s $FIRST_MOUNTPOINT ./symlink-to-mountpoint
+
+ts_init_subtest "default"
+$TS_CMD_MOUNTPOINT ./symlink-to-mountpoint >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo $? >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "nofollow"
+$TS_CMD_MOUNTPOINT --nofollow ./symlink-to-mountpoint >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo $? >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "mutually-exclusive"
+$TS_CMD_MOUNTPOINT --devno --nofollow / >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo $? >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+rm -f ./symlink-to-mountpoint
+ts_finalize
diff --git a/tests/ts/misc/rev b/tests/ts/misc/rev
new file mode 100755
index 0000000..0b3b64c
--- /dev/null
+++ b/tests/ts/misc/rev
@@ -0,0 +1,31 @@
+#!/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="rev"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_REV"
+ts_check_test_command "$TS_HELPER_MD5"
+
+for I in {0..512}; do printf "%s " {a..z}; done | "$TS_HELPER_MD5" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+for I in {0..512}; do printf "%s " {a..z}; done | \
+ $TS_CMD_REV | "$TS_HELPER_MD5" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+printf "abc\n123" | $TS_CMD_REV >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_finalize
diff --git a/tests/ts/misc/setarch b/tests/ts/misc/setarch
new file mode 100755
index 0000000..ab2f6c0
--- /dev/null
+++ b/tests/ts/misc/setarch
@@ -0,0 +1,92 @@
+#!/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="setarch"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_SETARCH"
+
+ARCH=$(uname -m)
+
+ts_init_subtest options
+test -e /.dockerenv && ts_skip "unsupported in docker environment"
+ts_log_both "###### unknown arch"
+$TS_CMD_SETARCH qubit -v echo "success" >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo "exit: $?" >>$TS_OUTPUT
+
+ts_log_both "###### unknown command"
+$TS_CMD_SETARCH $ARCH -v /das/gibs/nicht >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo "exit: $?" >>$TS_OUTPUT
+
+echo "###### noop uname -a" >>$TS_OUTPUT
+uname_a=$(uname -srm)
+$TS_CMD_SETARCH $ARCH -v uname -srm >> $TS_OUTPUT 2>> $TS_ERRLOG
+sed -i "$ s@${uname_a}@uname -a unchanged@" $TS_OUTPUT
+
+echo "###### almost all options" >>$TS_OUTPUT
+$TS_CMD_SETARCH $ARCH -vRFZLXBIST3 echo "success" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest uname26
+finmsg="" # for debugging 2.6 issues
+
+echo "###### --uname-2.6 echo" >>$TS_OUTPUT
+$TS_CMD_SETARCH $ARCH -v --uname-2.6 echo "2.6 worked" >> $TS_OUTPUT 2>&1
+if [ $? -eq 0 ]; then
+ expected='^2.6 worked$'
+else
+ # this may happen after execvp - gets written to stderr
+ expected="^FATAL: kernel too old$"
+ finmsg+=" echo"
+fi
+sed -i "$ s/$expected/2.6 works or kernel too old/" $TS_OUTPUT
+
+echo "###### --uname-2.6 true, non-verbose" >>$TS_OUTPUT
+$TS_CMD_SETARCH $ARCH --uname-2.6 true >> $TS_OUTPUT 2>&1
+if [ $? -eq 0 ]; then
+ echo "2.6 works or kernel too old" >> $TS_OUTPUT
+else
+ # this may happen after execvp - gets written to stderr
+ expected="^FATAL: kernel too old$"
+ sed -i "$ s/$expected/2.6 works or kernel too old/" $TS_OUTPUT
+ finmsg+=" true"
+fi
+
+if [ -n "$finmsg" ]; then
+ finmsg=$(echo unsupported --uname-2.6: $finmsg)
+else
+ uname26_seems_supported=yes
+fi
+ts_finalize_subtest "$finmsg"
+
+
+# conditional subtest
+if [ "$uname26_seems_supported" = "yes" ]; then
+ts_init_subtest uname26-version
+ tmp=$($TS_CMD_SETARCH $ARCH --uname-2.6 uname -r)
+ if echo "$tmp" | grep -q "^2\.6\."; then
+ echo "kernel version changed to 2.6" >> $TS_OUTPUT
+ else
+ echo "uname26 failed" >> $TS_OUTPUT
+ echo "original kernel: $(uname -r)" >> $TS_OUTPUT
+ echo "uname26 kernel: $tmp" >> $TS_OUTPUT
+ fi
+ts_finalize_subtest
+fi # conditional subtest
+
+ts_finalize
diff --git a/tests/ts/misc/setsid b/tests/ts/misc/setsid
new file mode 100755
index 0000000..dc4a329
--- /dev/null
+++ b/tests/ts/misc/setsid
@@ -0,0 +1,25 @@
+#!/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="setsid"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_SETSID"
+
+$TS_CMD_SETSID echo "success" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_finalize
diff --git a/tests/ts/misc/strtosize b/tests/ts/misc/strtosize
new file mode 100755
index 0000000..7d78c35
--- /dev/null
+++ b/tests/ts/misc/strtosize
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2010 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="strtosize"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_STRUTILS"
+
+$TS_HELPER_STRUTILS --size -1 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 0 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 123 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 18446744073709551615 >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_HELPER_STRUTILS --size 1K >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1KiB >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1M >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1MiB >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1G >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1GiB >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1T >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1TiB >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1P >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1PiB >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1E >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1EiB >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_HELPER_STRUTILS --size 1KB >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1MB >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1GB >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1TB >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1PB >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 1EB >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_HELPER_STRUTILS --size "" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size " " >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size " 1" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size "1 " >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_HELPER_STRUTILS --size 0x0a >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 0xff00 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_HELPER_STRUTILS --size 0x80000000 >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_finalize
+
diff --git a/tests/ts/misc/swaplabel b/tests/ts/misc/swaplabel
new file mode 100755
index 0000000..8b1abb5
--- /dev/null
+++ b/tests/ts/misc/swaplabel
@@ -0,0 +1,69 @@
+#!/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="swaplabel"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MKSWAP"
+ts_check_test_command "$TS_CMD_SWAPLABEL"
+ts_check_test_command "$TS_HELPER_SYSINFO"
+
+# fallocate does not work on most file systems
+function fallocate_or_skip()
+{
+ $TS_CMD_FALLOCATE -x -l $1 $2 2>/dev/null || \
+ truncate -s $1 $2 || \
+ ts_skip "no way to create test image"
+}
+
+IMAGE=${TS_OUTDIR}/${TS_TESTNAME}.file
+
+PAGE_SIZE=$($TS_HELPER_SYSINFO pagesize)
+PAGE_SIZE_KB=$(( $PAGE_SIZE / 1024 ))
+MIN_SWAP_SIZE=$(( 10 * $PAGE_SIZE ))
+MIN_SWAP_SIZE_KB=$(( MIN_SWAP_SIZE / 1024 ))
+
+rm -f $IMAGE
+fallocate_or_skip $(( $MIN_SWAP_SIZE - 1 )) $IMAGE
+$TS_CMD_MKSWAP \
+ --label 1234567890abcdef \
+ --uuid 12345678-abcd-abcd-abcd-1234567890ab \
+ $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+sed -i -e "s/ $MIN_SWAP_SIZE_KB KiB/ 10 pages/" \
+ -e "s:$IMAGE:<swapfile>:g" \
+ -e "s/insecure permissions [0-9]*/insecure permissions <perm>/g" \
+ $TS_OUTPUT $TS_ERRLOG
+
+rm -f $IMAGE
+fallocate_or_skip $MIN_SWAP_SIZE $IMAGE
+$TS_CMD_MKSWAP \
+ --label 1234567890abcdef \
+ --uuid 12345678-abcd-abcd-abcd-1234567890ab \
+ $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+sed -i -e "s/ $(( $MIN_SWAP_SIZE_KB - $PAGE_SIZE_KB )) KiB/ 9 pages/" \
+ -e "s/($(( $MIN_SWAP_SIZE - $PAGE_SIZE )) bytes)/(9xPGSZ bytes)/" \
+ -e "s:$IMAGE:<swapfile>:g" \
+ -e "s/insecure permissions [0-9]*/insecure permissions <perm>/g" \
+ $TS_OUTPUT $TS_ERRLOG
+
+$TS_CMD_SWAPLABEL $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+#rm -f $IMAGE
+
+ts_finalize
diff --git a/tests/ts/misc/whereis b/tests/ts/misc/whereis
new file mode 100755
index 0000000..44643ae
--- /dev/null
+++ b/tests/ts/misc/whereis
@@ -0,0 +1,50 @@
+#!/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="whereis"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_WHEREIS"
+
+BIN_DIR="$(mktemp -d "${TS_OUTDIR}/binXXXXXXXXXXXXX")"
+MAN_DIR="$(mktemp -d "${TS_OUTDIR}/manXXXXXXXXXXXXX")"
+touch "$BIN_DIR/fsck"
+touch "$MAN_DIR/fsck.8.zst"
+touch "$BIN_DIR/fsck.ext4"
+touch "$MAN_DIR/fsck.ext4.8.zst"
+touch "$BIN_DIR/fsck.minix"
+touch "$BIN_DIR/python"
+touch "$MAN_DIR/python.1.gz"
+touch "$BIN_DIR/python3"
+touch "$MAN_DIR/python3.1"
+touch "$BIN_DIR/python3.8"
+touch "$BIN_DIR/python3.8-config"
+touch "$MAN_DIR/python3.8.1"
+
+for COMMAND in fsck fsck.ext4 python python3 python3.8
+do
+ COUNT=$($TS_CMD_WHEREIS -B $BIN_DIR -M $MAN_DIR -f $COMMAND | wc -w)
+ if [ $COUNT -eq 3 ]; then
+ echo "$COMMAND success" >> $TS_OUTPUT
+ else
+ echo "$COMMAND failure" >> $TS_OUTPUT
+ fi
+done
+
+rm -rf "$BIN_DIR" "$MAN_DIR"
+
+ts_finalize