]> err.no Git - util-linux/commitdiff
tests: add libmount tags tests
authorKarel Zak <kzak@redhat.com>
Mon, 18 Oct 2010 14:22:20 +0000 (16:22 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Jan 2011 11:28:45 +0000 (12:28 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/expected/libmount/tabfiles-tags-fstab-dev [new file with mode: 0644]
tests/expected/libmount/tabfiles-tags-fstab-dev2label [new file with mode: 0644]
tests/expected/libmount/tabfiles-tags-fstab-label [new file with mode: 0644]
tests/expected/libmount/tabfiles-tags-fstab-label2dev [new file with mode: 0644]
tests/expected/libmount/tabfiles-tags-fstab-label2uuid [new file with mode: 0644]
tests/expected/libmount/tabfiles-tags-fstab-uuid [new file with mode: 0644]
tests/ts/libmount/tabfiles-tags [new file with mode: 0755]

diff --git a/tests/expected/libmount/tabfiles-tags-fstab-dev b/tests/expected/libmount/tabfiles-tags-fstab-dev
new file mode 100644 (file)
index 0000000..823a19c
--- /dev/null
@@ -0,0 +1,5 @@
+------ fs:
+
+target: /mnt/mountpoint3
+fstype: auto
+optstr: defaults
diff --git a/tests/expected/libmount/tabfiles-tags-fstab-dev2label b/tests/expected/libmount/tabfiles-tags-fstab-dev2label
new file mode 100644 (file)
index 0000000..78d04a4
--- /dev/null
@@ -0,0 +1,5 @@
+------ fs:
+source: LABEL=testLibmount
+target: /mnt/mountpoint
+fstype: auto
+optstr: defaults
diff --git a/tests/expected/libmount/tabfiles-tags-fstab-label b/tests/expected/libmount/tabfiles-tags-fstab-label
new file mode 100644 (file)
index 0000000..78d04a4
--- /dev/null
@@ -0,0 +1,5 @@
+------ fs:
+source: LABEL=testLibmount
+target: /mnt/mountpoint
+fstype: auto
+optstr: defaults
diff --git a/tests/expected/libmount/tabfiles-tags-fstab-label2dev b/tests/expected/libmount/tabfiles-tags-fstab-label2dev
new file mode 100644 (file)
index 0000000..78d04a4
--- /dev/null
@@ -0,0 +1,5 @@
+------ fs:
+source: LABEL=testLibmount
+target: /mnt/mountpoint
+fstype: auto
+optstr: defaults
diff --git a/tests/expected/libmount/tabfiles-tags-fstab-label2uuid b/tests/expected/libmount/tabfiles-tags-fstab-label2uuid
new file mode 100644 (file)
index 0000000..78d04a4
--- /dev/null
@@ -0,0 +1,5 @@
+------ fs:
+source: LABEL=testLibmount
+target: /mnt/mountpoint
+fstype: auto
+optstr: defaults
diff --git a/tests/expected/libmount/tabfiles-tags-fstab-uuid b/tests/expected/libmount/tabfiles-tags-fstab-uuid
new file mode 100644 (file)
index 0000000..67d4e7b
--- /dev/null
@@ -0,0 +1,5 @@
+------ fs:
+source: UUID=de1bc6e9-34ab-4151-a1d7-900042eee8d9
+target: /mnt/mountpoint2
+fstype: auto
+optstr: defaults
diff --git a/tests/ts/libmount/tabfiles-tags b/tests/ts/libmount/tabfiles-tags
new file mode 100755 (executable)
index 0000000..2f9f6c4
--- /dev/null
@@ -0,0 +1,92 @@
+#!/bin/bash
+
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="tags"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+
+#
+# Init device
+#
+modprobe --dry-run --quiet scsi_debug
+[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
+
+rmmod scsi_debug &> /dev/null
+modprobe scsi_debug dev_size_mb=50 sector_size=512
+[ "$?" == 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}"
+LABEL="testLibmount"
+UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9"
+
+#
+# Create filesystem
+#
+mkfs.ext3 -F -L $LABEL $DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE
+ts_device_has_uuid $DEVICE || ts_die "Cannot found UUID on $DEVICE" $DEVICE
+
+TESTPROG="$TS_HELPER_TABFILES"
+FSTAB="$TS_OUTDIR/fstab"
+
+#
+# Label in fstab
+#
+echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB
+
+ts_init_subtest "fstab-label2uuid"
+$TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "fstab-label2dev"
+$TESTPROG --find-forward $FSTAB source $DEVICE &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+#
+# Add more enties for the same device
+#
+echo "UUID=$UUID  /mnt/mountpoint2 auto defaults" >> $FSTAB
+
+ts_init_subtest "fstab-uuid"
+# has to return /mnt/mountpoint2
+$TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "fstab-label"
+# has to return /mnt/mountpoint
+$TESTPROG --find-forward $FSTAB source "LABEL=$LABEL" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+
+ts_init_subtest "fstab-dev2label"
+# has to return /mnt/mountpoint
+$TESTPROG --find-forward $FSTAB source $DEVICE &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+#
+# Add devname
+#
+echo "$DEVICE  /mnt/mountpoint3 auto defaults" >> $FSTAB
+
+ts_init_subtest "fstab-dev"
+# has to return /mnt/mountpoint3
+$TESTPROG --find-forward $FSTAB source $DEVICE &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+sed -i -e 's/source: .*//g' $TS_OUTPUT         # devname is generated, remove it
+ts_finalize_subtest
+
+
+sleep 3
+rmmod scsi_debug
+ts_finalize