summaryrefslogtreecommitdiffstats
path: root/tests/ts/libmount/tabfiles
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtests/ts/libmount/tabfiles85
-rwxr-xr-xtests/ts/libmount/tabfiles-py75
-rwxr-xr-xtests/ts/libmount/tabfiles-tags86
-rwxr-xr-xtests/ts/libmount/tabfiles-tags-py90
4 files changed, 336 insertions, 0 deletions
diff --git a/tests/ts/libmount/tabfiles b/tests/ts/libmount/tabfiles
new file mode 100755
index 0000000..716fed8
--- /dev/null
+++ b/tests/ts/libmount/tabfiles
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="tab files"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+TESTPROG="$TS_HELPER_LIBMOUNT_TAB"
+
+[ -x $TESTPROG ] || ts_skip "test not compiled"
+
+ts_init_subtest "parse-fstab"
+ts_run $TESTPROG --parse "$TS_SELF/files/fstab" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-fstab-full"
+ts_run $TESTPROG --parse "$TS_SELF/files/fstab.comment" --comments &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-mtab"
+ts_run $TESTPROG --parse "$TS_SELF/files/mtab" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-fstab-broken"
+ts_run $TESTPROG --parse "$TS_SELF/files/fstab.broken" &> $TS_OUTPUT
+sed -i -e 's/.*fstab.broken:[[:digit:]]*: parse error//g; s/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-mountinfo"
+ts_run $TESTPROG --parse "$TS_SELF/files/mountinfo" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-mountinfo-nosrc"
+ts_run $TESTPROG --parse "$TS_SELF/files/mountinfo_nosrc" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-swaps"
+ts_run $TESTPROG --parse "$TS_SELF/files/swaps" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "copy"
+ts_run $TESTPROG --copy-fs "$TS_SELF/files/fstab" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-source"
+ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" source UUID=fef7ccb3-821c-4de8-88dc-71472be5946f &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-target"
+ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" target /home/foo &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-target2"
+ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-target3"
+ts_run $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo/ &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-pair"
+ts_run $TESTPROG --find-pair "$TS_SELF/files/mtab" /dev/mapper/kzak-home /home/kzak &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-fs"
+ts_run $TESTPROG --find-fs "$TS_SELF/files/mountinfo" /home/kzak &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/libmount/tabfiles-py b/tests/ts/libmount/tabfiles-py
new file mode 100755
index 0000000..9754afe
--- /dev/null
+++ b/tests/ts/libmount/tabfiles-py
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="tab files-py"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+ts_init_py libmount
+
+if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then
+ TS_KNOWN_FAIL="yes"
+fi
+
+PYDBG="$PYTHON -m pdb"
+TESTPROG="$TS_HELPER_PYLIBMOUNT_TAB"
+[ -x $TESTPROG ] || ts_die "test script missing"
+
+ts_init_subtest "parse-fstab"
+$PYTHON $TESTPROG --parse "$TS_SELF/files/fstab" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-fstab-full"
+$PYTHON $TESTPROG --parse "$TS_SELF/files/fstab.comment" --comments &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-mtab"
+$PYTHON $TESTPROG --parse "$TS_SELF/files/mtab" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-fstab-broken"
+$PYTHON $TESTPROG --parse "$TS_SELF/files/fstab.broken" &> $TS_OUTPUT
+sed -i -e 's/.*fstab.broken:[[:digit:]]*: parse error//g; s/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-mountinfo"
+$PYTHON $TESTPROG --parse "$TS_SELF/files/mountinfo" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "copy"
+$PYTHON $TESTPROG --copy-fs "$TS_SELF/files/fstab" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-source"
+$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" source UUID=fef7ccb3-821c-4de8-88dc-71472be5946f &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-target"
+$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" target /home/foo &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-target2"
+$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-target3"
+$PYTHON $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo/ &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-pair"
+$PYTHON $TESTPROG --find-pair "$TS_SELF/files/mtab" /dev/mapper/kzak-home /home/kzak &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/libmount/tabfiles-tags b/tests/ts/libmount/tabfiles-tags
new file mode 100755
index 0000000..c5452cf
--- /dev/null
+++ b/tests/ts/libmount/tabfiles-tags
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="tags"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_skip_nonroot
+
+if [ "$TS_ENABLE_ASAN" == "yes" ]; then
+ TS_KNOWN_FAIL="yes"
+fi
+
+TESTPROG="$TS_HELPER_LIBMOUNT_TAB"
+
+[ -x $TESTPROG ] || ts_skip "test not compiled"
+ts_check_prog "mkfs.ext2"
+
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=50 sector_size=512
+LABEL="testLibmount"
+UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9"
+
+#
+# Create filesystem
+#
+mkfs.ext2 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext2 on $TS_DEVICE"
+ts_device_has "LABEL" "$LABEL" "$TS_DEVICE" || ts_die "Cannot find LABEL '$LABEL' on $TS_DEVICE"
+ts_device_has "UUID" "$UUID" "$TS_DEVICE" || ts_die "Cannot find $UUID on $TS_DEVICE"
+
+FSTAB="$TS_OUTDIR/fstab"
+
+#
+# Label in fstab
+#
+echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB
+ts_udevadm_settle "$TS_DEVICE" "LABEL" "UUID"
+
+ts_init_subtest "fstab-label2uuid"
+ts_run $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"
+ts_run $TESTPROG --find-forward $FSTAB source $TS_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
+ts_run $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
+ts_run $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
+ts_run $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+#
+# Add devname
+#
+echo "$TS_DEVICE /mnt/mountpoint3 auto defaults" >> $FSTAB
+
+ts_init_subtest "fstab-dev"
+# has to return /mnt/mountpoint3
+ts_run $TESTPROG --find-forward $FSTAB source $TS_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
+
+ts_finalize
diff --git a/tests/ts/libmount/tabfiles-tags-py b/tests/ts/libmount/tabfiles-tags-py
new file mode 100755
index 0000000..171f189
--- /dev/null
+++ b/tests/ts/libmount/tabfiles-tags-py
@@ -0,0 +1,90 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="tags-py"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_skip_nonroot
+
+ts_init_py libmount
+
+if [ "$TS_ENABLE_ASAN" == "yes" -o "$TS_ENABLE_UBSAN" == "yes" ]; then
+ TS_KNOWN_FAIL="yes"
+fi
+
+TESTPROG="$TS_HELPER_PYLIBMOUNT_TAB"
+[ -x $TESTPROG ] || ts_die "test script missing"
+
+ts_check_prog "mkfs.ext2"
+
+PYDBG="$PYTHON -m pdb"
+
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=50 sector_size=512
+LABEL="testLibmount"
+UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9"
+
+#
+# Create filesystem
+#
+mkfs.ext2 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext2 on $TS_DEVICE"
+ts_device_has "LABEL" "$LABEL" "$TS_DEVICE" || ts_die "Cannot find LABEL '$LABEL' on $TS_DEVICE"
+ts_device_has "UUID" "$UUID" "$TS_DEVICE" || ts_die "Cannot find $UUID on $TS_DEVICE"
+
+FSTAB="$TS_OUTDIR/fstab"
+
+#
+# Label in fstab
+#
+echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB
+ts_udevadm_settle "$DEVICE" "LABEL" "UUID"
+
+ts_init_subtest "fstab-label2uuid"
+$PYTHON $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"
+$PYTHON $TESTPROG --find-forward $FSTAB source $TS_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
+$PYTHON $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
+$PYTHON $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
+$PYTHON $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+#
+# Add devname
+#
+echo "$TS_DEVICE /mnt/mountpoint3 auto defaults" >> $FSTAB
+
+ts_init_subtest "fstab-dev"
+# has to return /mnt/mountpoint3
+$PYTHON $TESTPROG --find-forward $FSTAB source $TS_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
+
+ts_finalize