Debian Codegraph @

tests/ts/libmount/tabfiles-tags

raw
1 #!/bin/bash
2
3 TS_TOPDIR="${0%/*}/../.."
4 TS_DESC="tags"
5
6 . "$TS_TOPDIR"/functions.sh
7 ts_init "$*"
8
9 ts_skip_nonroot
10
11 if [ "$TS_ENABLE_ASAN" == "yes" ]; then
12 TS_KNOWN_FAIL="yes"
13 fi
14
15 TESTPROG="$TS_HELPER_LIBMOUNT_TAB"
16
17 [ -x $TESTPROG ] || ts_skip "test not compiled"
18 ts_check_prog "mkfs.ext2"
19
20 # set global variable TS_DEVICE
21 ts_scsi_debug_init dev_size_mb=50 sector_size=512
22 LABEL="testLibmount"
23 UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9"
24
25 #
26 # Create filesystem
27 #
28 mkfs.ext2 -F -L $LABEL $TS_DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext2 on $TS_DEVICE"
29 ts_device_has "LABEL" "$LABEL" "$TS_DEVICE" || ts_die "Cannot find LABEL '$LABEL' on $TS_DEVICE"
30 ts_device_has "UUID" "$UUID" "$TS_DEVICE" || ts_die "Cannot find $UUID on $TS_DEVICE"
31
32 FSTAB="$TS_OUTDIR/fstab"
33
34 #
35 # Label in fstab
36 #
37 echo "LABEL=$LABEL /mnt/mountpoint auto defaults" > $FSTAB
38 ts_udevadm_settle "$TS_DEVICE" "LABEL" "UUID"
39
40 ts_init_subtest "fstab-label2uuid"
41 ts_run $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT
42 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
43 ts_finalize_subtest
44
45 ts_init_subtest "fstab-label2dev"
46 ts_run $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT
47 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
48 ts_finalize_subtest
49
50 #
51 # Add more enties for the same device
52 #
53 echo "UUID=$UUID /mnt/mountpoint2 auto defaults" >> $FSTAB
54
55 ts_init_subtest "fstab-uuid"
56 # has to return /mnt/mountpoint2
57 ts_run $TESTPROG --find-forward $FSTAB source "UUID=$UUID" &> $TS_OUTPUT
58 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
59 ts_finalize_subtest
60
61 ts_init_subtest "fstab-label"
62 # has to return /mnt/mountpoint
63 ts_run $TESTPROG --find-forward $FSTAB source "LABEL=$LABEL" &> $TS_OUTPUT
64 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
65 ts_finalize_subtest
66
67
68 ts_init_subtest "fstab-dev2label"
69 # has to return /mnt/mountpoint
70 ts_run $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT
71 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
72 ts_finalize_subtest
73
74 #
75 # Add devname
76 #
77 echo "$TS_DEVICE /mnt/mountpoint3 auto defaults" >> $FSTAB
78
79 ts_init_subtest "fstab-dev"
80 # has to return /mnt/mountpoint3
81 ts_run $TESTPROG --find-forward $FSTAB source $TS_DEVICE &> $TS_OUTPUT
82 sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
83 sed -i -e 's/source: .*//g' $TS_OUTPUT # devname is generated, remove it
84 ts_finalize_subtest
85
86 ts_finalize