diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 02:42:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 02:42:50 +0000 |
commit | 8cb83eee5a58b1fad74c34094ce3afb9e430b5a4 (patch) | |
tree | a9b2e7baeca1be40eb734371e3c8b11b02294497 /tests/ts/misc | |
parent | Initial commit. (diff) | |
download | util-linux-8cb83eee5a58b1fad74c34094ce3afb9e430b5a4.tar.xz util-linux-8cb83eee5a58b1fad74c34094ce3afb9e430b5a4.zip |
Adding upstream version 2.33.1.upstream/2.33.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | tests/ts/misc/fallocate | 39 | ||||
-rwxr-xr-x | tests/ts/misc/flock | 106 | ||||
-rwxr-xr-x | tests/ts/misc/ionice | 30 | ||||
-rwxr-xr-x | tests/ts/misc/line | 58 | ||||
-rwxr-xr-x | tests/ts/misc/mbsencode | 83 | ||||
-rwxr-xr-x | tests/ts/misc/mcookie | 28 | ||||
-rwxr-xr-x | tests/ts/misc/rev | 31 | ||||
-rwxr-xr-x | tests/ts/misc/setarch | 91 | ||||
-rwxr-xr-x | tests/ts/misc/setsid | 25 | ||||
-rwxr-xr-x | tests/ts/misc/strtosize | 60 | ||||
-rwxr-xr-x | tests/ts/misc/swaplabel | 65 | ||||
-rwxr-xr-x | tests/ts/misc/ul | 26 | ||||
-rwxr-xr-x | tests/ts/misc/whereis | 30 |
13 files changed, 672 insertions, 0 deletions
diff --git a/tests/ts/misc/fallocate b/tests/ts/misc/fallocate new file mode 100755 index 0000000..b37d025 --- /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>&1; then + stat -c "%s" $IMAGE >> $TS_OUTPUT 2>&1 +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_OUTPUT \ + && 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..6a43fea --- /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>&1 + + 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..32b2259 --- /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>&1 +$TS_CMD_IONICE -p $$ -n 3 -c 7 >> $TS_OUTPUT 2>&1 +$TS_CMD_IONICE -p $$ -n 4 -c 7 >> $TS_OUTPUT 2>&1 +$TS_CMD_IONICE -p $$ -n 1 -c 8 >> $TS_OUTPUT 2>&1 +$TS_CMD_IONICE -n 3 ls /etc/passwd >> $TS_OUTPUT 2>&1 +$TS_CMD_IONICE -p $$ >> $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/misc/line b/tests/ts/misc/line new file mode 100755 index 0000000..186a789 --- /dev/null +++ b/tests/ts/misc/line @@ -0,0 +1,58 @@ +#!/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_log '# usually behave like "head -n 1"' +printf "a\nb\n" | + $TS_CMD_LINE >> $TS_OUTPUT 2>&1 +echo "ret: $?" >> $TS_OUTPUT + +ts_log '# never consume more than one line' +printf "1\n2\n" | + ($TS_CMD_LINE && $TS_CMD_LINE) >> $TS_OUTPUT 2>&1 +echo "ret: $?" >> $TS_OUTPUT + +ts_log '# add a newline' +printf "abc" | + $TS_CMD_LINE >> $TS_OUTPUT 2>&1 +echo "ret: $?" >> $TS_OUTPUT + +ts_log '# print one newline on empty input' +printf "" | + $TS_CMD_LINE >> $TS_OUTPUT 2>&1 +echo "ret: $?" >> $TS_OUTPUT + +ts_log '# add a newline, return 1 when EOF' +(printf "xyz" && cat </dev/null) | + $TS_CMD_LINE >> $TS_OUTPUT 2>&1 +echo "ret: $?" >> $TS_OUTPUT + +ts_log '# print one newline on empty input, return 1 when EOF' +$TS_CMD_LINE </dev/null >> $TS_OUTPUT 2>&1 +echo "ret: $?" >> $TS_OUTPUT + +ts_log '# large line of zero bytes' +dd if=/dev/zero bs=1k count=1k 2>/dev/null | + $TS_CMD_LINE line | $TS_CMD_HEXDUMP -C >> $TS_OUTPUT 2>&1 +echo "ret: $?" >> $TS_OUTPUT + +ts_finalize diff --git a/tests/ts/misc/mbsencode b/tests/ts/misc/mbsencode new file mode 100755 index 0000000..405d34c --- /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/misc/mcookie b/tests/ts/misc/mcookie new file mode 100755 index 0000000..96e3cc7 --- /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>&1 + +ts_finalize diff --git a/tests/ts/misc/rev b/tests/ts/misc/rev new file mode 100755 index 0000000..3a541ac --- /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>&1 + +for I in {0..512}; do printf "%s " {a..z}; done | \ + $TS_CMD_REV | "$TS_HELPER_MD5" >> $TS_OUTPUT 2>&1 + +printf "abc\n123" | $TS_CMD_REV >> $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/misc/setarch b/tests/ts/misc/setarch new file mode 100755 index 0000000..c8050e5 --- /dev/null +++ b/tests/ts/misc/setarch @@ -0,0 +1,91 @@ +#!/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 +echo "###### unknown arch" >>$TS_OUTPUT +$TS_CMD_SETARCH qubit -v echo "success" >>$TS_OUTPUT 2>&1 +echo "exit: $?" >>$TS_OUTPUT + +echo "###### unknown command" >>$TS_OUTPUT +$TS_CMD_SETARCH $ARCH -v /das/gibs/nicht >>$TS_OUTPUT 2>&1 +echo "exit: $?" >>$TS_OUTPUT + +echo "###### noop uname -a" >>$TS_OUTPUT +uname_a=$(uname -srm) +$TS_CMD_SETARCH $ARCH -v uname -srm >>$TS_OUTPUT 2>&1 +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>&1 +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 + 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 + 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..baef70d --- /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>&1 + +ts_finalize diff --git a/tests/ts/misc/strtosize b/tests/ts/misc/strtosize new file mode 100755 index 0000000..68b3b8b --- /dev/null +++ b/tests/ts/misc/strtosize @@ -0,0 +1,60 @@ +#!/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_HELPER_STRUTILS --size -1 >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 0 >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1 >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 123 >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 18446744073709551615 >> $TS_OUTPUT 2>&1 + +$TS_HELPER_STRUTILS --size 1K >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1KiB >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1M >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1MiB >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1G >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1GiB >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1T >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1TiB >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1P >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1PiB >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1E >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1EiB >> $TS_OUTPUT 2>&1 + +$TS_HELPER_STRUTILS --size 1KB >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1MB >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1GB >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1TB >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1PB >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 1EB >> $TS_OUTPUT 2>&1 + +$TS_HELPER_STRUTILS --size "" >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size " " >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size " 1" >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size "1 " >> $TS_OUTPUT 2>&1 + +$TS_HELPER_STRUTILS --size 0x0a >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 0xff00 >> $TS_OUTPUT 2>&1 +$TS_HELPER_STRUTILS --size 0x80000000 >> $TS_OUTPUT 2>&1 + +ts_finalize + diff --git a/tests/ts/misc/swaplabel b/tests/ts/misc/swaplabel new file mode 100755 index 0000000..6463045 --- /dev/null +++ b/tests/ts/misc/swaplabel @@ -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="swaplabel" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKSWAP" +ts_check_test_command "$TS_CMD_SWAPLABEL" + +# fallocate does not work on most file systems +function fallocate_or_skip() +{ + $TS_CMD_FALLOCATE -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 2>&1 |\ + sed -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 2>&1 + +rm -f $IMAGE +fallocate_or_skip $MIN_SWAP_SIZE $IMAGE +$TS_CMD_MKSWAP \ + --label 1234567890abcdef \ + --uuid 12345678-abcd-abcd-abcd-1234567890ab \ + $IMAGE 2>&1 |\ + sed -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 2>&1 +$TS_CMD_SWAPLABEL $IMAGE >> $TS_OUTPUT 2>&1 + +#rm -f $IMAGE + +ts_finalize diff --git a/tests/ts/misc/ul b/tests/ts/misc/ul new file mode 100755 index 0000000..2c2c1da --- /dev/null +++ b/tests/ts/misc/ul @@ -0,0 +1,26 @@ +#!/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="ul" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_UL" + +printf "a\x08ab\x5F\x08c\\n\\ttab\\f\\b\\r" | + $TS_CMD_UL -t xterm > $TS_OUTPUT 2>&1 + +ts_finalize diff --git a/tests/ts/misc/whereis b/tests/ts/misc/whereis new file mode 100755 index 0000000..ee7ec27 --- /dev/null +++ b/tests/ts/misc/whereis @@ -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="whereis" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_WHEREIS" + +LS_COUNT=$($TS_CMD_WHEREIS ls | wc -w) +if [ $LS_COUNT -lt 2 ]; then + echo "ls binary nor manual not found?" > $TS_OUTPUT +else + echo "success" > $TS_OUTPUT +fi + +ts_finalize |