#!/bin/bash # Copyright (C) 2010 Karel Zak TS_TOPDIR="$(dirname $0)/../.." TS_DESC="context (utab)" . $TS_TOPDIR/functions.sh ts_init "$*" ts_skip_nonroot TESTPROG="$TS_HELPER_LIBMOUNT_CONTEXT" LABEL=libmount-test UUID=$(uuidgen) MOUNTPOINT="$TS_MOUNTPOINT" [ -x $TESTPROG ] || ts_skip "test not compiled" modprobe --dry-run --quiet scsi_debug [ "$?" == 0 ] || ts_skip "missing scsi_debug module" ts_log "Init device" rmmod scsi_debug &> /dev/null modprobe scsi_debug dev_size_mb=260 [ "$?" == 0 ] || ts_die "Cannot init device" sleep 3 DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}') [ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device" DEVICE="/dev/${DEVNAME}" ts_log "Create partitions" $TS_CMD_FDISK ${DEVICE} >> /dev/null 2>&1 < /dev/null ts_log "Do tests..." export LIBMOUNT_MTAB=$TS_OUTPUT.mtab rm -f $LIBMOUNT_MTAB ln -s /proc/mounts $LIBMOUNT_MTAB export LIBMOUNT_UTAB=$TS_OUTPUT.utab rm -f $LIBMOUNT_UTAB > $LIBMOUNT_UTAB ts_init_subtest "mount-by-devname" mkdir -p $MOUNTPOINT &> /dev/null ts_valgrind $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1 grep -q $DEVICE /proc/mounts || \ echo "(by device) cannot find $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1 ts_finalize_subtest sleep 1 ts_init_subtest "umount-by-devname" ts_valgrind $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>&1 grep -q $DEVICE /proc/mounts && echo "umount (device) failed: found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1 ts_finalize_subtest ts_init_subtest "mount-uhelper" mkdir -p $MOUNTPOINT &> /dev/null ts_valgrind $TESTPROG --mount -o uhelper=foo,rw LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>&1 grep -q $DEVICE $LIBMOUNT_UTAB || \ echo "(by label) cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 ts_finalize_subtest sleep 1 ts_init_subtest "umount" ts_valgrind $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1 grep -q $DEVICE $LIBMOUNT_UTAB && \ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 ts_finalize_subtest if [ -x "/sbin/mkfs.btrfs" ]; then ts_log "Create filesystem [btrfs]" /sbin/mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null mount -t btrfs $DEVICE $MOUNTPOINT &> /dev/null /sbin/btrfsctl -S sub $MOUNTPOINT &> /dev/null umount $MOUNTPOINT &> /dev/null sleep 1 ts_init_subtest "mount-uhelper-subvol" mkdir -p $MOUNTPOINT &> /dev/null ts_valgrind $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1 grep -q $DEVICE $LIBMOUNT_UTAB || \ echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 ts_finalize_subtest ts_log "All mount options (btrfs subvolume + utab) ---" $TS_CMD_FINDMNT --mtab $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>&1 ts_log "---" sleep 1 ts_init_subtest "umount-subvol" ts_valgrind $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1 grep -q $DEVICE $LIBMOUNT_UTAB && \ echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 ts_finalize_subtest fi ts_log "...done." rmmod scsi_debug ts_finalize