From: Karel Zak Date: Mon, 22 Nov 2010 22:15:00 +0000 (+0100) Subject: tests: add basic libmount tests for mounting X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40829d8589aee7805260f345f646512c6596e5a0;p=util-linux tests: add basic libmount tests for mounting Signed-off-by: Karel Zak --- diff --git a/tests/commands.sh.in b/tests/commands.sh.in index d39dcb98..9e568106 100644 --- a/tests/commands.sh.in +++ b/tests/commands.sh.in @@ -21,6 +21,7 @@ TS_HELPER_LIBMOUNT_TAB="$top_builddir/shlibs/mount/src/test_tab" TS_HELPER_LIBMOUNT_UTILS="$top_builddir/shlibs/mount/src/test_utils" TS_HELPER_LIBMOUNT_LOCK="$top_builddir/shlibs/mount/src/test_lock" TS_HELPER_LIBMOUNT_UPDATE="$top_builddir/shlibs/mount/src/test_tab_update" +TS_HELPER_LIBMOUNT_CONTEXT="$top_builddir/shlibs/mount/src/test_context" # TODO: use partx TS_HELPER_PARTITIONS="$top_builddir/shlibs/blkid/samples/partitions" diff --git a/tests/expected/libmount/mount b/tests/expected/libmount/mount new file mode 100644 index 00000000..5e268a31 --- /dev/null +++ b/tests/expected/libmount/mount @@ -0,0 +1,5 @@ +Init device +Create partitions +Create filesystem +Do tests... +...done. diff --git a/tests/ts/libmount/mount b/tests/ts/libmount/mount new file mode 100755 index 00000000..75fcd0a7 --- /dev/null +++ b/tests/ts/libmount/mount @@ -0,0 +1,83 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="$(dirname $0)/../.." +TS_DESC="mount" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +TESTPROG="$TS_HELPER_LIBMOUNT_CONTEXT" +LABEL=libmount-test +UUID=$(uuidgen) + +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=100 +[ "$?" == 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 found 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 +> $LIBMOUNT_MTAB + + +ts_init_subtest "by-devname" +mkdir -p $TS_MOUNTPOINT &> /dev/null +$TESTPROG --mount $DEVICE $TS_MOUNTPOINT &> $TS_OUTPUT +grep -q $DEVICE $LIBMOUNT_MTAB || \ + echo "(by device) cannot found $DEVICE in $LIBMOUNT_MTAB" &> $TS_OUTPUT +umount $TS_MOUNTPOINT +ts_finalize_subtest + + +ts_init_subtest "by-label" +mkdir -p $TS_MOUNTPOINT &> /dev/null +$TESTPROG --mount LABEL="$LABEL" $TS_MOUNTPOINT &> $TS_OUTPUT +grep -q $DEVICE $LIBMOUNT_MTAB || \ + echo "(by label) cannot found $DEVICE in $LIBMOUNT_MTAB" &> $TS_OUTPUT +umount $TS_MOUNTPOINT +ts_finalize_subtest + + +ts_init_subtest "by-uuid" +mkdir -p $TS_MOUNTPOINT &> /dev/null +$TESTPROG --mount UUID="$UUID" $TS_MOUNTPOINT &> $TS_OUTPUT +grep -q $DEVICE $LIBMOUNT_MTAB || \ + echo "(by uuid) cannot found $DEVICE in $LIBMOUNT_MTAB" &> $TS_OUTPUT +umount $TS_MOUNTPOINT +ts_finalize_subtest + +ts_log "...done." +rmmod scsi_debug +ts_finalize diff --git a/tests/ts/libmount/update b/tests/ts/libmount/update index 92c92b08..b895ba05 100755 --- a/tests/ts/libmount/update +++ b/tests/ts/libmount/update @@ -23,8 +23,6 @@ TESTPROG="$TS_HELPER_LIBMOUNT_UPDATE" # Traditional /etc/mtab # export LIBMOUNT_MTAB=$TS_OUTPUT.mtab - -rm $LIBMOUNT_MTAB > $LIBMOUNT_MTAB ts_init_subtest "mtab-mount" @@ -56,7 +54,7 @@ ts_finalize_subtest # checks the mtab # # utab # -rm $LIBMOUNT_MTAB +rm -f $LIBMOUNT_MTAB ln -s /proc/mounts $LIBMOUNT_MTAB export LIBMOUNT_UTAB=$TS_OUTPUT.utab