diff options
Diffstat (limited to 'tests/ts/mount')
-rwxr-xr-x | tests/ts/mount/devname | 53 | ||||
-rwxr-xr-x | tests/ts/mount/encryption | 64 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-broken | 62 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-devname | 53 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-devname2label | 49 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-devname2uuid | 49 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-label | 60 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-label2devname | 55 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-label2uuid | 60 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-none | 30 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-symlink | 68 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-uuid | 60 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-uuid2devname | 55 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-uuid2label | 59 | ||||
-rwxr-xr-x | tests/ts/mount/label | 53 | ||||
-rwxr-xr-x | tests/ts/mount/move | 53 | ||||
-rwxr-xr-x | tests/ts/mount/noncanonical | 37 | ||||
-rwxr-xr-x | tests/ts/mount/paths | 31 | ||||
-rwxr-xr-x | tests/ts/mount/regfile | 37 | ||||
-rwxr-xr-x | tests/ts/mount/remount | 52 | ||||
-rwxr-xr-x | tests/ts/mount/rlimit | 78 | ||||
-rwxr-xr-x | tests/ts/mount/shared-subtree | 58 | ||||
-rwxr-xr-x | tests/ts/mount/special | 40 | ||||
-rwxr-xr-x | tests/ts/mount/uuid | 52 |
24 files changed, 1268 insertions, 0 deletions
diff --git a/tests/ts/mount/devname b/tests/ts/mount/devname new file mode 100755 index 0000000..8f32ef1 --- /dev/null +++ b/tests/ts/mount/devname @@ -0,0 +1,53 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by devname" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot find ext3 on $DEVICE" $DEVICE + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT + +ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" $DEVICE + +grep -q $DEVICE /etc/mtab || + echo "mount failed: cannot find $DEVICE in mtab" >> $TS_OUTPUT 2>&1 + +$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" $DEVICE + +grep -q $DEVICE /etc/mtab && + echo "umount failed: found $DEVICE in mtab" >> $TS_OUTPUT 2>&1 + +ts_device_deinit $DEVICE + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/encryption b/tests/ts/mount/encryption new file mode 100755 index 0000000..bf452a0 --- /dev/null +++ b/tests/ts/mount/encryption @@ -0,0 +1,64 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by devname" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +modprobe --dry-run --quiet cryptoloop +[ "$?" == 0 ] || ts_skip "missing cryptoloop module" + +modprobe cryptoloop &> /dev/null + +PASSFILE=$TS_OUTPUT.pwd +IMAGE=$(ts_image_init) + +echo "password" > $PASSFILE +exec 9<> $PASSFILE + +DEVICE=$($TS_CMD_LOSETUP --pass-fd 9 --show --encryption blowfish --find $IMAGE) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +sleep 3 +$TS_CMD_LOSETUP --detach $DEVICE + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +# reopen (we need SEEK_SET 0, but this is shell...) +exec 9>&- +exec 9<> $PASSFILE + +$TS_CMD_MOUNT --pass-fd 9 -o encryption=blowfish $IMAGE $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT + +$TS_CMD_FINDMNT --kernel --target $TS_MOUNTPOINT &> /dev/null +[ "$?" == "0" ] || ts_die "Cannot find $TS_MOUNTPOINT in /proc/self/mountinfo" + +$TS_CMD_UMOUNT $TS_MOUNTPOINT || ts_die "Cannot umount $TS_MOUNTPOINT" $DEVICE + +ts_device_deinit $DEVICE + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-broken b/tests/ts/mount/fstab-broken new file mode 100755 index 0000000..48fe1a1 --- /dev/null +++ b/tests/ts/mount/fstab-broken @@ -0,0 +1,62 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="broken fstab" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +# Let's use the same mountpoint for all subtests +MNT=$TS_MOUNTPOINT +mkdir -p $MNT + +ts_fstab_open +echo "tmpd $MNT tmpfs" >> /etc/fstab +ts_fstab_close + +ts_init_subtest "mount" +$TS_CMD_MOUNT $MNT &> /dev/null +$TS_CMD_FINDMNT --kernel --target "$MNT" &> /dev/null +if [ "$?" != "0" ]; then + ts_log "Cannot find $MNT in /proc/self/mountinfo" +else + ts_log "OK" +fi +$TS_CMD_UMOUNT $MNT &> /dev/null +ts_finalize_subtest + + +ts_init_subtest "mount-all" +$TS_CMD_MOUNT -a &> /dev/null +$TS_CMD_FINDMNT --kernel --target "$MNT" &> /dev/null +if [ "$?" != "0" ]; then + ts_log "Cannot find $MNT in /proc/self/mountinfo" +else + ts_log "OK" +fi +$TS_CMD_UMOUNT $MNT &> /dev/null +ts_finalize_subtest + +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-devname b/tests/ts/mount/fstab-devname new file mode 100755 index 0000000..9af8db6 --- /dev/null +++ b/tests/ts/mount/fstab-devname @@ -0,0 +1,53 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by devname (fstab)" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot find ext3 on $DEVICE" $DEVICE + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_fstab_add $DEVICE + +# variant A) +$TS_CMD_MOUNT $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE + +# variant B) +$TS_CMD_MOUNT $DEVICE 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE + +ts_device_deinit $DEVICE +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-devname2label b/tests/ts/mount/fstab-devname2label new file mode 100755 index 0000000..34214db --- /dev/null +++ b/tests/ts/mount/fstab-devname2label @@ -0,0 +1,49 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by devname (fstab label)" +LABEL="testMountD2L" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" $DEVICE + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_fstab_add "LABEL=$LABEL" + +$TS_CMD_MOUNT $DEVICE 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" $DEVICE + +ts_device_deinit $DEVICE +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-devname2uuid b/tests/ts/mount/fstab-devname2uuid new file mode 100755 index 0000000..859bcda --- /dev/null +++ b/tests/ts/mount/fstab-devname2uuid @@ -0,0 +1,49 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by devname (fstab uuid)" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" $DEVICE + +UUID=$(ts_uuid_by_devname $DEVICE) + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_fstab_add "UUID=$UUID" + +$TS_CMD_MOUNT $DEVICE 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" $DEVICE + +ts_device_deinit $DEVICE +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-label b/tests/ts/mount/fstab-label new file mode 100755 index 0000000..2c1e7eb --- /dev/null +++ b/tests/ts/mount/fstab-label @@ -0,0 +1,60 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by label (fstab)" +LABEL="testFstabLabel" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" $DEVICE + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_fstab_add "LABEL=$LABEL" + +# variant A) +$TS_CMD_MOUNT $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE + +# variant B) +$TS_CMD_MOUNT -L $LABEL 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE + +# variant C) +$TS_CMD_MOUNT LABEL=$LABEL 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "C) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "C) Cannot umount $DEVICE" $DEVICE + +ts_device_deinit $DEVICE +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-label2devname b/tests/ts/mount/fstab-label2devname new file mode 100755 index 0000000..0d10f1b --- /dev/null +++ b/tests/ts/mount/fstab-label2devname @@ -0,0 +1,55 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by label (fstab devname)" +LABEL="testMountL2D" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" $DEVICE + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_fstab_add "$DEVICE" + +# variant A) +$TS_CMD_MOUNT -L $LABEL 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE + +# variant B) +$TS_CMD_MOUNT "LABEL=$LABEL" 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE + +ts_device_deinit $DEVICE +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-label2uuid b/tests/ts/mount/fstab-label2uuid new file mode 100755 index 0000000..0ad4f05 --- /dev/null +++ b/tests/ts/mount/fstab-label2uuid @@ -0,0 +1,60 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by label (fstab uuid)" +LABEL="testMountL2U" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" $DEVICE + +ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" $DEVICE + +UUID=$(ts_uuid_by_devname $DEVICE) + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_fstab_add "UUID=$UUID" + +# variant A) +$TS_CMD_MOUNT -L $LABEL 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE + +# variant B) +$TS_CMD_MOUNT "LABEL=$LABEL" 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE + +ts_device_deinit $DEVICE +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-none b/tests/ts/mount/fstab-none new file mode 100755 index 0000000..62a89ca --- /dev/null +++ b/tests/ts/mount/fstab-none @@ -0,0 +1,30 @@ +#!/bin/bash + +TS_TOPDIR="$(dirname $0)/../.." +TS_DESC="none" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +ts_fstab_add "none" "$TS_MOUNTPOINT" "tmpfs" "rw,nosuid,nodev,relatime" + +mkdir -p $TS_MOUNTPOINT + +$TS_CMD_MOUNT $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT + +$TS_CMD_FINDMNT --target "$TS_MOUNTPOINT" &> /dev/null +[ $? -eq 0 ] || ts_die "Not found target (mount failed?)" + +$TS_CMD_FINDMNT --source "none" --target "$TS_MOUNTPOINT" &> /dev/null +[ $? -eq 0 ] || ts_die "Not found source and target" + +$TS_CMD_UMOUNT $TS_MOUNTPOINT || ts_die "Cannot umount $TS_MOUNTPOINT" + +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-symlink b/tests/ts/mount/fstab-symlink new file mode 100755 index 0000000..7f9d91f --- /dev/null +++ b/tests/ts/mount/fstab-symlink @@ -0,0 +1,68 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by devname (fstab symlink)" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +LINKNAME="$TS_OUTDIR/${TS_TESTNAME}_lnk" + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot find ext3 on $DEVICE" $DEVICE + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +rm -rf $LINKNAME +ln -s $DEVICE $LINKNAME + +ts_fstab_add $LINKNAME $TS_MOUNTPOINT "auto" "defaults,user" + +# variant A) -- UID=0 +$TS_CMD_MOUNT $LINKNAME 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $LINKNAME || ts_die "A) Cannot umount $LINKNAME" $DEVICE + +# varian B) -- disabled, the $TS_CMD_MOUNT is usually not a real program, but +# libtool wrapper and the real mount is exec()ed with +# LD_LIBRARY_PATH. This all is bad for suid programs... + +#ts_init_suid $TS_CMD_MOUNT +#ts_init_suid $TS_CMD_UMOUNT +# +#su $TS_TESTUSER -c "$TS_CMD_MOUNT -v -v -v $LINKNAME" 2>&1 >> $TS_OUTPUT +#ts_is_mounted $DEVICE +# || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE +#su $TS_TESTUSER -c "$TS_CMD_UMOUNT $LINKNAME" 2>&1 >> $TS_OUTPUT \ +# || ts_die "B) Cannot umount $LINKNAME" $DEVICE + +ts_device_deinit $DEVICE +ts_fstab_clean +rm -f $LINKNAME + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-uuid b/tests/ts/mount/fstab-uuid new file mode 100755 index 0000000..8c65b4d --- /dev/null +++ b/tests/ts/mount/fstab-uuid @@ -0,0 +1,60 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by uuid (fstab)" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" $DEVICE + +UUID=$(ts_uuid_by_devname $DEVICE) + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_fstab_add "UUID=$UUID" + +# varian A) +$TS_CMD_MOUNT $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE + +# varian B) +$TS_CMD_MOUNT -U $UUID 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE + +# varian C) +$TS_CMD_MOUNT UUID=$UUID 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "C) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "C) Cannot umount $DEVICE" $DEVICE + +ts_device_deinit $DEVICE +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-uuid2devname b/tests/ts/mount/fstab-uuid2devname new file mode 100755 index 0000000..51bac14 --- /dev/null +++ b/tests/ts/mount/fstab-uuid2devname @@ -0,0 +1,55 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by uuid (fstab devname)" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" $DEVICE + +UUID=$(ts_uuid_by_devname $DEVICE) + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_fstab_add "$DEVICE" + +# variant A) +$TS_CMD_MOUNT -U $UUID 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE + +# variant B) +$TS_CMD_MOUNT "UUID=$UUID" 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE + +ts_device_deinit $DEVICE +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/fstab-uuid2label b/tests/ts/mount/fstab-uuid2label new file mode 100755 index 0000000..442cdb7 --- /dev/null +++ b/tests/ts/mount/fstab-uuid2label @@ -0,0 +1,59 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by uuid (fstab label)" +LABEL="testMountU2L" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" $DEVICE + +ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" $DEVICE + +UUID=$(ts_uuid_by_devname $DEVICE) + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +ts_fstab_add "LABEL=$LABEL" + +# variant A) +$TS_CMD_MOUNT -U $UUID 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE + +# variant B) +$TS_CMD_MOUNT "UUID=$UUID" 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE + +ts_device_deinit $DEVICE +ts_fstab_clean + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/label b/tests/ts/mount/label new file mode 100755 index 0000000..873ea95 --- /dev/null +++ b/tests/ts/mount/label @@ -0,0 +1,53 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by label" +LABEL="testMountLabel" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has "LABEL" $LABEL $DEVICE \ + || ts_die "Cannot find LABEL '$LABEL' on $DEVICE" $DEVICE + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +# variant A) +$TS_CMD_MOUNT -L $LABEL $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE + +# variant B) +$TS_CMD_MOUNT LABEL=$LABEL $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE + +ts_device_deinit $DEVICE + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/move b/tests/ts/mount/move new file mode 100755 index 0000000..3862f46 --- /dev/null +++ b/tests/ts/mount/move @@ -0,0 +1,53 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="move" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +DIR_SRC="$TS_OUTDIR/mnt-move-src" +DIR_A="$TS_OUTDIR/mnt-move-A" +DIR_B="$TS_OUTDIR/mnt-move-B" + +[ -d $DIR_SRC ] || mkdir $DIR_SRC +[ -d $DIR_A ] || mkdir $DIR_A +[ -d $DIR_B ] || mkdir $DIR_B + +# bind +$TS_CMD_MOUNT --bind $DIR_SRC $DIR_A + +# check the bind +$TS_CMD_FINDMNT --kernel --target "$DIR_A" &> /dev/null +[ "$?" == "0" ] || ts_die "Cannot find binded $DIR_A in /proc/self/mountinfo" + +# move +$TS_CMD_MOUNT --move $DIR_A $DIR_B + +# check the move +$TS_CMD_FINDMNT --kernel --target "$DIR_B" &> /dev/null +[ "$?" == "0" ] || ts_die "Cannot find binded $DIR_B in /proc/self/mountinfo" + +# clean up +$TS_CMD_UMOUNT $DIR_B +rmdir $DIR_SRC $DIR_A $DIR_B + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/noncanonical b/tests/ts/mount/noncanonical new file mode 100755 index 0000000..1d28304 --- /dev/null +++ b/tests/ts/mount/noncanonical @@ -0,0 +1,37 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="non canonical path" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +[ ! -e "/etc" ] && ts_skip "/etc not such file of directory" + +$TS_CMD_MOUNT -V | grep -q "libmount" +[ $? -eq 0 ] && ts_skip "libmount version" + +# Don't canonicalize SPEC for cifs, nfs, smbfs, ... +$TS_CMD_MOUNT -v -v -v -f -i -n -t cifs //etc /foo | grep "spec:" >> $TS_OUTPUT 2>&1 + +# Canonicalize when FS type undefined and the SPEC exists +$TS_CMD_MOUNT -v -v -v -f -i -n //etc /foo | grep "spec:" >> $TS_OUTPUT 2>&1 + +ts_finalize + diff --git a/tests/ts/mount/paths b/tests/ts/mount/paths new file mode 100755 index 0000000..0b3432b --- /dev/null +++ b/tests/ts/mount/paths @@ -0,0 +1,31 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="basic paths" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +$TS_CMD_MOUNT -V | grep -q "libmount" +[ $? -eq 0 ] && ts_skip "libmount version" + +$TS_CMD_MOUNT -n -f -v -v -v /dev/dummy /mnt &> $TS_OUTPUT + +ts_finalize + diff --git a/tests/ts/mount/regfile b/tests/ts/mount/regfile new file mode 100755 index 0000000..8d786ad --- /dev/null +++ b/tests/ts/mount/regfile @@ -0,0 +1,37 @@ +#!/bin/bash + +# Copyright (C) 2011 Karel Zak <kzak@redhat.com> +# This file is part of util-linux. + +TS_TOPDIR="$(dirname $0)/../.." +TS_DESC="regular file" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +IMAGE=$(ts_image_init) +mkfs.ext3 -F $IMAGE &> /dev/null || ts_die "Cannot make ext3 on $IMAGE" + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +$TS_CMD_MOUNT $IMAGE $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT + +DEVICE=$(awk '/regfile/ { print $1 }' /proc/mounts) + +ts_is_mounted "$TS_MOUNTPOINT" || ts_die "Cannot find $TS_MOUNTPOINT in /proc/mounts" + +if [ -f "/sys/block/$(basename $DEVICE)/loop/backing_file" ]; then + $TS_CMD_UMOUNT $IMAGE || ts_die "Cannot umount $IMAGE" +else + $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null + ts_skip "too old kernel" +fi + +ts_is_mounted "$TS_MOUNTPOINT" && ts_die "$TS_MOUNTPOINT still in /proc/mounts" + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/remount b/tests/ts/mount/remount new file mode 100755 index 0000000..051c595 --- /dev/null +++ b/tests/ts/mount/remount @@ -0,0 +1,52 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="remount" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +# mountpoint +[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" $DEVICE + +# mount read-write +$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT || ts_die "Cannot mount $TS_MOUNTPOINT" $DEVICE + +# check the mount +egrep -q "^$DEVICE $TS_MOUNTPOINT" /etc/mtab \ + || ts_die "Cannot find $TS_MOUNTPOINT in /etc/mtab" $DEVICE + +# remount +$TS_CMD_MOUNT -o remount,ro $TS_MOUNTPOINT \ + || ts_die "Cannot remount $TS_MOUNTPOINT" $DEVICE + +# check the remount +$TS_CMD_FINDMNT --kernel --target "$TS_MOUNTPOINT" --options "ro" &> /dev/null +[ "$?" == "0" ] || ts_die "Cannot find read-only in $TS_MOUNTPOINT in /proc/self/mountinfo" + +ts_device_deinit $DEVICE + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/rlimit b/tests/ts/mount/rlimit new file mode 100755 index 0000000..7d7e42b --- /dev/null +++ b/tests/ts/mount/rlimit @@ -0,0 +1,78 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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. +# + +# +# The /etc/mtab file should not be modified if RLIMIT_FSIZE (ulimit -f) +# is too low, otherwise the file could be corrupted (incomplete write). +# The [u]mount(8) has to block SIGXFSZ and check if all writes and fflush +# calls are successful. +# + +TS_TOPDIR="$(dirname $0)/../.." +TS_DESC="rlimit-fsize" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +[ -L /etc/mtab ] && ts_skip "mtab is symlink" +[ "$(stat --format '%s' /etc/mtab)" -gt "1024" ] || ts_skip "mtab is too small" + +set -o pipefail + +function mtab_checksum() +{ + md5sum /etc/mtab | awk '{printf $1}' +} + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + + +ts_init_subtest "mount" +OLD_SUM=$(mtab_checksum) +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +( + ulimit -f 1 + $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT +) &> /dev/null +NEW_SUM=$(mtab_checksum) +$TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null +[ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by mount" >> $TS_OUTPUT +ts_finalize_subtest + + +ts_init_subtest "umount" +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT +$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT &> /dev/null +OLD_SUM=$(mtab_checksum) +( + ulimit -f 1 + $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null +) &> /dev/null +NEW_SUM=$(mtab_checksum) +$TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null +[ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by umount" >> $TS_OUTPUT +ts_finalize_subtest + + +ts_device_deinit $DEVICE +ts_log "Success" +ts_finalize diff --git a/tests/ts/mount/shared-subtree b/tests/ts/mount/shared-subtree new file mode 100755 index 0000000..a0a76c5 --- /dev/null +++ b/tests/ts/mount/shared-subtree @@ -0,0 +1,58 @@ +#!/bin/bash + +TS_TOPDIR="$(dirname $0)/../.." +TS_DESC="shared-subtree" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +function get_attr() +{ + # It's usually stupid idea to use 'grep | awk', + # but use paths in awk /regex/ is too tricky... + # + # TODO; improve libmount and findmnt to return the + # shared-subtree flags + # + echo $(grep "$1" /proc/self/mountinfo | \ + awk '{print $7}' | \ + awk -F ':' '{ print $1 }') +} + +[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT + +# bind +$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT + +# check the bind +$TS_CMD_FINDMNT --kernel --target $TS_MOUNTPOINT &> /dev/null +[ "$?" == "0" ] || ts_die "Cannot find binded $TS_MOUNTPOINT in /proc/self/mountinfo" + +# use the same mounpoint for all sub-tests +MOUNTPOINT="$TS_MOUNTPOINT" + + +ts_init_subtest "make-shared" +$TS_CMD_MOUNT --make-shared $MOUNTPOINT >> $TS_OUTPUT 2>&1 +echo "$(get_attr $MOUNTPOINT)" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "make-private" +$TS_CMD_MOUNT --make-private $MOUNTPOINT >> $TS_OUTPUT 2>&1 +echo "$(get_attr $MOUNTPOINT)" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "make-unbindable" +$TS_CMD_MOUNT --make-unbindable $MOUNTPOINT >> $TS_OUTPUT 2>&1 +echo "$(get_attr $MOUNTPOINT)" >> $TS_OUTPUT +ts_finalize_subtest + + +# clean up +$TS_CMD_UMOUNT $TS_MOUNTPOINT +rmdir $TS_MOUNTPOINT + +ts_log "Success" +ts_finalize + diff --git a/tests/ts/mount/special b/tests/ts/mount/special new file mode 100755 index 0000000..6e198b3 --- /dev/null +++ b/tests/ts/mount/special @@ -0,0 +1,40 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="call mount.<type>" +MOUNTER="/sbin/mount.mytest" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +cat > $MOUNTER <<\EOF +#!/bin/bash +# This util-linux regression test component +# It's safe to remove me... +# +echo "$0 called with \"$*\"" +EOF +chmod +x $MOUNTER + +$TS_CMD_MOUNT -t mytest /foo /bar &> $TS_OUTPUT + +rm -f $MOUNTER + +ts_finalize + diff --git a/tests/ts/mount/uuid b/tests/ts/mount/uuid new file mode 100755 index 0000000..e29ad39 --- /dev/null +++ b/tests/ts/mount/uuid @@ -0,0 +1,52 @@ +#!/bin/bash + +# +# Copyright (C) 2007 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="$(dirname $0)/../.." +TS_DESC="by uuid" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +set -o pipefail + +DEVICE=$(ts_device_init) +[ "$?" == 0 ] || ts_die "Cannot init device" + +mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE + +ts_device_has_uuid $DEVICE || ts_die "Cannot find UUID on $DEVICE" $DEVICE + +UUID=$(ts_uuid_by_devname $DEVICE) + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +# variant A) +$TS_CMD_MOUNT -U $UUID $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE + +# variant B) +$TS_CMD_MOUNT UUID=$UUID $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT +ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE +$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE + +ts_device_deinit $DEVICE + +ts_log "Success" +ts_finalize + |