Debian Codegraph @

tests/ts/eject/umount

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 TS_TOPDIR="${0%/*}/../.."
4 TS_DESC="umount"
5
6 . "$TS_TOPDIR"/functions.sh
7 ts_init "$*"
8
9 ts_skip_nonroot
10
11 ts_check_test_command "$TS_CMD_FDISK"
12 ts_check_test_command "$TS_CMD_EJECT"
13 ts_check_test_command "$TS_CMD_KILL"
14 ts_check_test_command "$TS_CMD_MOUNT"
15
16 ts_check_prog "mkfs.ext2"
17
18 # scsi_debug could not eject for kernel >=3.19 and <4.4
19 if x=$(echoscip-shell system . . echo. "3.19" && unamescip-shell system . . uname. -r && echoscip-shell system . . echo. "4.4") \
20 && testscip-shell system . . test. "$x" = "$(echoscip-shell system . . echo. "$x" | sortscip-shell system . . sort. --version-sort)"
21 then
22 ts_skip "3.19 <= $(unamescip-shell system . . uname. -sr) < 4.4"
23 fi
24
25 #
26 # Note that eject --force is required because scsi_debug is
27 # not removable device.
28 #
29
30 # set global variable TS_DEVICE
31 function init_devicescip-shell shell util-linux 2.42.2-1 init_device(). {
32 ts_scsi_debug_init dev_size_mb=100
33 }
34
35 function init_partitionsscip-shell shell util-linux 2.42.2-1 init_partitions(). {
36 local dev=$1
37
38 ts_log "Create partitions"
39 $TS_CMD_FDISK --noauto-pt $dev >> /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 <<EOF
40 o
41 n
42 p
43 1
44
45 +50M
46 n
47 p
48 2
49
50
51 p
52 w
53 EOF
54 udevadm settle
55 mkfs.ext2 -q ${dev}1
56 mkfs.ext2 -q ${dev}2
57 udevadm settle
58 }
59
60 function deinit_devicescip-shell shell util-linux 2.42.2-1 deinit_device(). {
61 ts_scsi_debug_rmmod
62 }
63
64 if [scip-shell system . . `[`. "$TS_USE_SYSTEM_COMMANDS" != "yes" ]; then
65 # As the eject binary execl()s an uninstrumented /bin/umount binary, we need
66 # to explicitly $LD_PRELOAD the ASan's runtime DSO, otherwise ASan will complain.
67 # Since all three utilities used by this test (eject, fdisk, mount) are just
68 # libtool wrappers, let's check the kill binary instead, which should have
69 # the needed DSO information.
70 ASAN_RT_PATH="$(ts_get_asan_rt_path "$TS_CMD_KILL")"
71 [scip-shell system . . `[`. -n "$ASAN_RT_PATH" ] && export LD_PRELOAD="$ASAN_RT_PATH:$LD_PRELOAD"
72 fi
73
74 ts_init_subtest "by-disk"
75 init_devicescip-shell shell util-linux 2.42.2-1 init_device().
76 $TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
77 deinit_devicescip-shell shell util-linux 2.42.2-1 deinit_device().
78 ts_finalize_subtest
79
80
81 ts_init_subtest "by-disk-mounted"
82 init_devicescip-shell shell util-linux 2.42.2-1 init_device().
83 mkfs.ext2 -q -F $TS_DEVICE
84 udevadm settle
85 mkdirscip-shell system . . mkdir. -p $TS_MOUNTPOINT
86 $TS_CMD_MOUNT $TS_DEVICE $TS_MOUNTPOINT &> /dev/nullscip-shell filesystem . . `/dev/null`.
87 udevadm settle
88 $TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
89 deinit_devicescip-shell shell util-linux 2.42.2-1 deinit_device().
90 ts_finalize_subtest
91
92
93 ts_init_subtest "by-disk-mounted-partition"
94 init_devicescip-shell shell util-linux 2.42.2-1 init_device().
95 init_partitionsscip-shell shell util-linux 2.42.2-1 init_partitions(). $TS_DEVICE
96 mkdirscip-shell system . . mkdir. -p ${TS_MOUNTPOINT}1
97 mkdirscip-shell system . . mkdir. -p ${TS_MOUNTPOINT}2
98 $TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1 &> /dev/nullscip-shell filesystem . . `/dev/null`.
99 $TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2 &> /dev/nullscip-shell filesystem . . `/dev/null`.
100 udevadm settle
101 $TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
102 deinit_devicescip-shell shell util-linux 2.42.2-1 deinit_device().
103 ts_finalize_subtest
104
105
106 ts_init_subtest "by-partition"
107 init_devicescip-shell shell util-linux 2.42.2-1 init_device().
108 init_partitionsscip-shell shell util-linux 2.42.2-1 init_partitions(). $TS_DEVICE
109 $TS_CMD_EJECT --force ${TS_DEVICE}1 && ts_log "Success"
110 deinit_devicescip-shell shell util-linux 2.42.2-1 deinit_device().
111 ts_finalize_subtest
112
113
114 ts_init_subtest "by-partition-mounted"
115 init_devicescip-shell shell util-linux 2.42.2-1 init_device().
116 init_partitionsscip-shell shell util-linux 2.42.2-1 init_partitions(). $TS_DEVICE
117 mkdirscip-shell system . . mkdir. -p ${TS_MOUNTPOINT}1
118 mkdirscip-shell system . . mkdir. -p ${TS_MOUNTPOINT}2
119 $TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1 &> /dev/nullscip-shell filesystem . . `/dev/null`.
120 $TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2 &> /dev/nullscip-shell filesystem . . `/dev/null`.
121 udevadm settle
122 $TS_CMD_EJECT --force ${TS_DEVICE}1 && ts_log "Success"
123 deinit_devicescip-shell shell util-linux 2.42.2-1 deinit_device().
124 ts_finalize_subtest
125
126
127 ts_finalize