summaryrefslogtreecommitdiffstats
path: root/tests/ts/misc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ts/misc')
-rwxr-xr-xtests/ts/misc/fallocate39
-rwxr-xr-xtests/ts/misc/flock124
-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/pipesz80
-rwxr-xr-xtests/ts/misc/rev34
-rwxr-xr-xtests/ts/misc/setarch109
-rwxr-xr-xtests/ts/misc/setsid25
-rwxr-xr-xtests/ts/misc/strtosize62
-rwxr-xr-xtests/ts/misc/swaplabel69
-rwxr-xr-xtests/ts/misc/waitpid59
-rwxr-xr-xtests/ts/misc/whereis50
15 files changed, 895 insertions, 0 deletions
diff --git a/tests/ts/misc/fallocate b/tests/ts/misc/fallocate
new file mode 100755
index 0000000..07efd98
--- /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..0c6ac0b
--- /dev/null
+++ b/tests/ts/misc/flock
@@ -0,0 +1,124 @@
+#!/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 "fd"
+cd "$TS_OUTDIR"
+rm 4 2> /dev/null
+exec 4<>$TS_OUTDIR/lockfile || ts_log "Could not open lockfile"
+$TS_CMD_FLOCK --nonblock --exclusive --conflict-exit-code 123 4 \
+ >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+rc="$?"
+
+if [ "$rc" == "123" ]; then
+ ts_log "Success"
+else
+ ts_log "Failed [rc=$rc]"
+fi
+[ -f 4 ] && ts_log "fd file should not exist"
+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..0114979
--- /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..97a415c
--- /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..39f9510
--- /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..a8c54f3
--- /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..19e6cfc
--- /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/pipesz b/tests/ts/misc/pipesz
new file mode 100755
index 0000000..e3c31f6
--- /dev/null
+++ b/tests/ts/misc/pipesz
@@ -0,0 +1,80 @@
+#!/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="pipesz"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_PIPESZ"
+ts_check_test_command "$TS_HELPER_SYSINFO"
+
+set -o pipefail
+
+DEFAULT_PIPE_SIZE=$(($($TS_HELPER_SYSINFO pagesize) * 16))
+
+ts_init_subtest "set-fd-bad"
+$TS_CMD_PIPESZ --check --set 4096 --fd 42 >> $TS_OUTPUT 2>> $TS_ERRLOG
+[[ $? -eq 0 ]] && ts_logerr "expected failure"
+ts_finalize_subtest
+
+ts_init_subtest "set-fd"
+echo -n | $TS_CMD_PIPESZ --check --set 4096 --stdin >> $TS_OUTPUT 2>> $TS_ERRLOG
+[[ $? -ne 0 ]] && ts_logerr "expected success"
+ts_finalize_subtest
+
+ts_init_subtest "set-file-bad"
+$TS_CMD_PIPESZ --check --set 4096 --file "/dev/null" >> $TS_OUTPUT 2>> $TS_ERRLOG
+[[ $? -eq 0 ]] && ts_logerr "expected failure"
+ts_finalize_subtest
+
+ts_init_subtest "set-file"
+echo -n | $TS_CMD_PIPESZ --check --set 4096 --file "/dev/stdin" >> $TS_OUTPUT 2>> $TS_ERRLOG
+[[ $? -ne 0 ]] && ts_logerr "expected success"
+ts_finalize_subtest
+
+ts_init_subtest "get-fd-bad"
+$TS_CMD_PIPESZ --check --get --fd 42 >> $TS_OUTPUT 2>> $TS_ERRLOG
+[[ $? -eq 0 ]] && ts_logerr "expected failure"
+ts_finalize_subtest
+
+ts_init_subtest "get-fd"
+echo -n | $TS_CMD_PIPESZ --check --get --stdin 2>> $TS_ERRLOG | sed "s/$DEFAULT_PIPE_SIZE/DEFAULT_PIPE_SIZE/g" >> $TS_OUTPUT
+[[ $? -ne 0 ]] && ts_logerr "expected success"
+ts_finalize_subtest
+
+ts_init_subtest "get-file-bad"
+$TS_CMD_PIPESZ --check --get --file "/dev/null" >> $TS_OUTPUT 2>> $TS_ERRLOG
+[[ $? -eq 0 ]] && ts_logerr "expected failure"
+ts_finalize_subtest
+
+ts_init_subtest "get-file"
+echo -n | $TS_CMD_PIPESZ --check --get --file "/dev/stdin" 2>> $TS_ERRLOG | sed "s/$DEFAULT_PIPE_SIZE/DEFAULT_PIPE_SIZE/g" >> $TS_OUTPUT
+[[ $? -ne 0 ]] && ts_logerr "expected success"
+ts_finalize_subtest
+
+ts_init_subtest "pipe-max-size"
+echo -n | $TS_CMD_PIPESZ --check --stdin >> $TS_OUTPUT 2>> $TS_ERRLOG
+[[ $? -ne 0 ]] && ts_logerr "expected success"
+ts_finalize_subtest
+
+ts_init_subtest "exec"
+echo this_should_be_output_by_cat | $TS_CMD_PIPESZ --check --stdin cat >> $TS_OUTPUT 2>> $TS_ERRLOG
+[[ $? -ne 0 ]] && ts_logerr "expected success"
+ts_finalize_subtest
+
+set +o pipefail
+
+ts_finalize
diff --git a/tests/ts/misc/rev b/tests/ts/misc/rev
new file mode 100755
index 0000000..b13f79c
--- /dev/null
+++ b/tests/ts/misc/rev
@@ -0,0 +1,34 @@
+#!/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
+echo >> $TS_OUTPUT
+printf "abc\000123" | $TS_CMD_REV -0 | tr '\0' '|' >> $TS_OUTPUT 2>> $TS_ERRLOG
+echo >> $TS_OUTPUT
+
+ts_finalize
diff --git a/tests/ts/misc/setarch b/tests/ts/misc/setarch
new file mode 100755
index 0000000..e7b6ff3
--- /dev/null
+++ b/tests/ts/misc/setarch
@@ -0,0 +1,109 @@
+#!/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"
+ts_skip_docker
+
+ARCH=$(uname -m)
+
+ts_init_subtest options
+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_init_subtest show
+echo "###### --show" >>$TS_OUTPUT
+
+show() {
+ echo -n "$1: " >> $TS_OUTPUT
+ $TS_CMD_SETARCH --show=$1 >> $TS_OUTPUT 2> $TS_ERRLOG
+}
+
+show 0x00000000
+show 0x00800000
+show 0x00880000
+show 0x00000008
+show 0x08000008
+show 0x000040ff
+
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/misc/setsid b/tests/ts/misc/setsid
new file mode 100755
index 0000000..9f04717
--- /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..e6233d5
--- /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..9db7d2b
--- /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/waitpid b/tests/ts/misc/waitpid
new file mode 100755
index 0000000..ae5ab6f
--- /dev/null
+++ b/tests/ts/misc/waitpid
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+# Copyright (C) 2022 Thomas Weißschuh <thomas@t-8ch.de>
+#
+# 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="waitpid"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_WAITPID"
+
+ts_init_subtest normal
+
+(sleep 0.2; echo 1 >> "$TS_OUTPUT") &
+BG1="$!"
+
+(sleep 0.1; echo 2 >> "$TS_OUTPUT") &
+BG2="$!"
+
+echo 3 >> "$TS_OUTPUT"
+"$TS_CMD_WAITPID" "$BG1" "$BG2"
+ts_skip_exitcode_not_supported
+
+echo 4 >> "$TS_OUTPUT"
+
+ts_finalize_subtest
+
+ts_init_subtest timeout
+"$TS_CMD_WAITPID" -v -t 0.1 1 >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+echo $? >> "$TS_OUTPUT"
+ts_finalize_subtest
+
+ts_init_subtest exited
+"$TS_CMD_WAITPID" -e 2147483647 >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+echo $? >> "$TS_ERRLOG"
+ts_finalize_subtest
+
+ts_init_subtest count
+(sleep 0.2; echo 1 >> "$TS_OUTPUT") &
+BG1="$!"
+
+"$TS_CMD_WAITPID" -c 1 1 "$BG1" >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+echo $? >> "$TS_ERRLOG"
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/misc/whereis b/tests/ts/misc/whereis
new file mode 100755
index 0000000..a799be0
--- /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