| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (C) 2007 Karel Zak <[email protected]> |
| 5 |
# |
| 6 |
# This file is part of util-linux. |
| 7 |
# |
| 8 |
# This file is free software; you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU General Public License as published by |
| 10 |
# the Free Software Foundation; either version 2 of the License, or |
| 11 |
# (at your option) any later version. |
| 12 |
# |
| 13 |
# This file is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU General Public License for more details. |
| 17 |
# |
| 18 |
TS_TOPDIR="${0%/*}/../.." |
| 19 |
TS_DESC="call mount.<type>" |
| 20 |
MOUNTER="/sbin/mount.mytest" |
| 21 |
|
| 22 |
. "$TS_TOPDIR"/functions.sh |
| 23 |
ts_init "$*" |
| 24 |
|
| 25 |
ts_check_test_command "$TS_CMD_MOUNT" |
| 26 |
ts_check_test_command "$TS_CMD_UMOUNT" |
| 27 |
|
| 28 |
ts_skip_nonroot |
| 29 |
|
| 30 |
cat > $MOUNTER <<\EOF |
| 31 |
#!/bin/bash |
| 32 |
# This util-linux regression test component |
| 33 |
# It's safe to remove me... |
| 34 |
# |
| 35 |
echo "$0 called with \"$*\"" |
| 36 |
EOF |
| 37 |
chmod +x $MOUNTER |
| 38 |
|
| 39 |
ts_init_subtest "basic" |
| 40 |
$TS_CMD_MOUNT -t mytest /foo /bar &> $TS_OUTPUT |
| 41 |
ts_finalize_subtest |
| 42 |
|
| 43 |
ts_init_subtest "options" |
| 44 |
$TS_CMD_MOUNT -t mytest -o foo,defaults /foo /bar &> $TS_OUTPUT |
| 45 |
ts_finalize_subtest |
| 46 |
|
| 47 |
ts_init_subtest "multi-types" |
| 48 |
$TS_CMD_MOUNT -t mytest,invalid /foo /bar &> $TS_OUTPUT |
| 49 |
ts_finalize_subtest |
| 50 |
|
| 51 |
ts_init_subtest "user" |
| 52 |
$TS_CMD_MOUNT -t mytest -ouser,abc /foo /bar &> $TS_OUTPUT |
| 53 |
ts_finalize_subtest |
| 54 |
|
| 55 |
ts_init_subtest "username" |
| 56 |
$TS_CMD_MOUNT -t mytest -ouser=name,abc /foo /bar &> $TS_OUTPUT |
| 57 |
ts_finalize_subtest |
| 58 |
|
| 59 |
|
| 60 |
ts_init_subtest "missing-options" |
| 61 |
|
| 62 |
grep -q 'nodev[[:space:]]*tmpfs' /proc/filesystems |
| 63 |
if [ "$?" == "0" ]; then |
| 64 |
cat > $MOUNTER <<EOF |
| 65 |
#!/bin/bash |
| 66 |
# This util-linux regression test component |
| 67 |
# It's safe to remove me... |
| 68 |
# |
| 69 |
exec $TS_CMD_MOUNT -t tmpfs -i "\$1" "\$2" -o x-foo=123 |
| 70 |
EOF |
| 71 |
chmod +x $MOUNTER |
| 72 |
|
| 73 |
mountpoint="$TS_OUTDIR/mnt" |
| 74 |
mkdir -p "$mountpoint" |
| 75 |
export LIBMOUNT_UTAB=$TS_OUTDIR/utab |
| 76 |
rm -f $LIBMOUNT_UTAB |
| 77 |
echo -n "" > $LIBMOUNT_UTAB |
| 78 |
|
| 79 |
$TS_CMD_MOUNT -t mytest -o x-bar=BAR /foo "$mountpoint" &> $TS_OUTPUT |
| 80 |
udevadm settle |
| 81 |
|
| 82 |
grep -q "$mountpoint" /proc/mounts |
| 83 |
if [ "$?" == "0" ]; then |
| 84 |
cat "$LIBMOUNT_UTAB" \ |
| 85 |
| grep "$mountpoint" \ |
| 86 |
| sed -e "s|$mountpoint|/mountpoint|g" \ |
| 87 |
-e 's/ID=[[:digit:]]* //g' \ |
| 88 |
&> $TS_OUTPUT |
| 89 |
$TS_CMD_UMOUNT "$mountpoint" |
| 90 |
unset LIBMOUNT_UTAB |
| 91 |
rm -f $MOUNTER |
| 92 |
ts_finalize_subtest |
| 93 |
else |
| 94 |
ts_skip_subtest "tmpfs not mounted" |
| 95 |
fi |
| 96 |
else |
| 97 |
ts_skip_subtest "tmpfs unsupported" |
| 98 |
fi |
| 99 |
|
| 100 |
ts_finalize |