]> git.ipfire.org Git - thirdparty/util-linux.git/blob - tests/ts/libmount/tabfiles-tags-py
tests: fix python tests for dist and out-of-tree builds
[thirdparty/util-linux.git] / tests / ts / libmount / tabfiles-tags-py
1 #!/bin/bash
2
3 TS_TOPDIR="${0%/*}/../.."
4 TS_DESC="tags-py"
5
6 . $TS_TOPDIR/functions.sh
7 ts_init "$*"
8 ts_init_py libmount
9 ts_skip_nonroot
10
11 TESTPROG="$TS_HELPER_PYLIBMOUNT_TAB"
12 [ -x $TESTPROG ] || ts_die "test script missing"
13
14 ts_check_prog "mkfs.ext3"
15
16 PYDBG="$PYTHON -m pdb"
17
18 # set global variable TS_DEVICE
19 ts_scsi_debug_init dev_size_mb=50 sector_size=512
20 LABEL="testLibmount"
21 UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9"
22
23 #
24 # Create filesystem
25 #
26 mkfs.ext3 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext3 on $TS_DEVICE" $TS_DEVICE
27 udevadm settle
28
29 ts_device_has_uuid $TS_DEVICE || ts_die "Cannot find UUID on $TS_DEVICE" $TS_DEVICE
30
31 FSTAB="$TS_OUTDIR/fstab"
32
33 #
34 # Label in fstab
35 #
36 echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB
37
38 ts_init_subtest "fstab-label2uuid"
39 $PYTHON $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT
40 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
41 ts_finalize_subtest
42
43 ts_init_subtest "fstab-label2dev"
44 $PYTHON $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT
45 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
46 ts_finalize_subtest
47
48 #
49 # Add more enties for the same device
50 #
51 echo "UUID=$UUID /mnt/mountpoint2 auto defaults" >> $FSTAB
52
53 ts_init_subtest "fstab-uuid"
54 # has to return /mnt/mountpoint2
55 $PYTHON $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT
56 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
57 ts_finalize_subtest
58
59 ts_init_subtest "fstab-label"
60 # has to return /mnt/mountpoint
61 $PYTHON $TESTPROG --find-forward $FSTAB source "LABEL=$LABEL" &> $TS_OUTPUT
62 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
63 ts_finalize_subtest
64
65
66 ts_init_subtest "fstab-dev2label"
67 # has to return /mnt/mountpoint
68 $PYTHON $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT
69 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
70 ts_finalize_subtest
71
72 #
73 # Add devname
74 #
75 echo "$TS_DEVICE /mnt/mountpoint3 auto defaults" >> $FSTAB
76
77 ts_init_subtest "fstab-dev"
78 # has to return /mnt/mountpoint3
79 $PYTHON $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT
80 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
81 sed -i -e 's/source: .*//g' $TS_OUTPUT # devname is generated, remove it
82 ts_finalize_subtest
83
84 udevadm settle
85 rmmod scsi_debug
86 ts_finalize