summaryrefslogtreecommitdiffstats
path: root/tests/ts/mount/fstab-all
blob: acc64e462e08510891b6682fcddf625d94604474 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash

# Copyright (C) 2019 Karel Zak <kzak@redhat.com>

TS_TOPDIR="${0%/*}/../.."
TS_DESC="all (fstab)"

. $TS_TOPDIR/functions.sh
ts_init "$*"

ts_check_test_command "$TS_CMD_MOUNT"
ts_check_test_command "$TS_CMD_UMOUNT"
ts_check_test_command "$TS_CMD_FDISK"

ts_skip_nonroot
ts_check_prog "mkfs.ext2"
ts_check_prog "mkfs.ext4"


# set global variable TS_DEVICE
ts_scsi_debug_init dev_size_mb=50

ts_log "Create partitions"
$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
o
n
p
1

+10M
n
p
2

+10M
n
p
3

+10M
n
p

+10M
w
q
EOF

udevadm settle

ts_log "Create filesystem A"
mkfs.ext2 ${TS_DEVICE}1 &> /dev/null
ts_log "Create filesystem B"
mkfs.ext2 ${TS_DEVICE}2 &> /dev/null
ts_log "Create filesystem C"
mkfs.ext2 ${TS_DEVICE}3 &> /dev/null
ts_log "Create filesystem D"
mkfs.ext4 ${TS_DEVICE}4 &> /dev/null

udevadm settle

# use the same top-level mountpoint for all sub-tests
MOUNTPOINT=$TS_MOUNTPOINT

[ -d "${MOUNTPOINT}A" ] || mkdir -p ${MOUNTPOINT}A
[ -d "${MOUNTPOINT}B" ] || mkdir -p ${MOUNTPOINT}B
[ -d "${MOUNTPOINT}C" ] || mkdir -p ${MOUNTPOINT}C
[ -d "${MOUNTPOINT}D" ] || mkdir -p ${MOUNTPOINT}D

# generic fstab
MY_FSTAB="$TS_OUTDIR/${TS_TESTNAME}.fstab"
rm -rf $MY_FSTAB
echo  "${TS_DEVICE}1 ${MOUNTPOINT}A ext2 rw,defaults 0 0" >> $MY_FSTAB 
echo  "${TS_DEVICE}2 ${MOUNTPOINT}B ext2 rw,defaults 0 0" >> $MY_FSTAB
echo  "${TS_DEVICE}3 ${MOUNTPOINT}C ext2 ro,defaults 0 0" >> $MY_FSTAB
echo  "${TS_DEVICE}4 ${MOUNTPOINT}D ext4 rw,defaults 0 0" >> $MY_FSTAB


ts_init_subtest "basic"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest


ts_init_subtest "filter-type"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t ext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
$TS_CMD_UMOUNT ${MOUNTPOINT}D
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest


ts_init_subtest "filter-notype"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t noext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest


ts_init_subtest "filter-option"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -O ro >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
$TS_CMD_UMOUNT ${MOUNTPOINT}C
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest


ts_init_subtest "override-option"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -o ro >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest


ts_init_subtest "prefix"
MY_ROOT="$TS_OUTDIR/${TS_TESTNAME}-rootdir"
[ -d "${MY_ROOT}" ] || mkdir -p ${MY_ROOT}
# sub-test specific fstab
MY_FSTAB="$TS_OUTDIR/${TS_TESTNAME}.fstab"
rm -rf $MY_FSTAB
echo  "${TS_DEVICE}1 /foo/A ext2 rw,defaults 0 0" >> $MY_FSTAB
echo  "${TS_DEVICE}2 /foo/B ext2 rw,defaults 0 0" >> $MY_FSTAB
echo  "${TS_DEVICE}3 /foo/C ext2 rw,defaults 0 0" >> $MY_FSTAB
echo  "${TS_DEVICE}4 /foo/D ext4 rw,defaults 0 0" >> $MY_FSTAB
# mount all to prefix
$TS_CMD_MOUNT	--all \
		--fstab $MY_FSTAB \
		--target-prefix $MY_ROOT \
		-o X-mount.mkdir >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
$TS_CMD_UMOUNT $MY_ROOT/foo/{A,B,C,D}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest

ts_finalize