blob: 0b2285627912c76e3d162600ee13e58e7b98896d (
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
#!/bin/sh
# Copyright (c), 2024, Huawei Technologies Co, Ltd.
# Author: Zhihao Cheng <chengzhihao1@huawei.com>
#
# Test Description:
# Initialize UBIFS image from a given directory, then check whether the
# fs content in mounted UBIFS is consistent with the original directory.
# Both UBI volume and file are chosen as storage mediums to test.
# Running time: 10min
TESTBINDIR=@TESTBINDIR@
source $TESTBINDIR/common.sh
function run_test()
{
local simulator="$1";
local size="$2";
local peb_size="$3";
local page_size="$4";
local vid_offs=$page_size;
local encryption=$5;
local test_medium=$6;
local space_fix=$7;
local need_fsck=$8;
local double_mkfs=$9;
local leb_size=$(($(($peb_size*1024))-$page_size));
VIDHDR_SZ=64;
option=""
if [[ "$space_fix" == "fix_space" ]]; then
option="-F"
fi
echo "======================================================================"
printf "%s" "$simulator: ${size}MiB PEB size ${peb_size}KiB"
if [ "$simulator" = "mtdram" ]; then
page_size=8
leb_size=$(($leb_size-$VIDHDR_SZ))
else
leb_size=$(($leb_size-$page_size))
fi
printf " %s" "page size ${page_size}Bytes"
printf " $encryption $test_medium $space_fix $need_fsck $double_mkfs\n"
if [ "$simulator" = "nandsim" ]; then
$TESTBINDIR/load_nandsim.sh "$size" "$peb_size" "$page_size" || echo "cannot load nandsim";
mtdnum="$(find_mtd_device "$nandsim_patt")"
elif [ "$simulator" = "mtdram" ]; then
load_mtdram "$size" "$peb_size" || echo "cannot load mtdram"
mtdnum="$(find_mtd_device "$mtdram_patt")"
else
fatal "$simulator is not supported"
fi
dmesg -c > /dev/null
flash_eraseall /dev/mtd$mtdnum
modprobe ubi mtd="$mtdnum,$vid_offs" || fatal "modprobe ubi fail"
ubimkvol -N vol_test -m -n 0 /dev/ubi$UBI_NUM || fatal "mkvol fail"
modprobe ubifs || fatal "modprobe ubifs fail"
if [[ "$encryption" == "encrypted" ]]; then
encryption_gen_key
option="$option --cipher AES-256-XTS --key $KEY_FILE"
fi
if [[ "$test_medium" == "volume" ]]; then
mkfs.ubifs $option -m${page_size} -c 1024 -e $leb_size -f 4 -r $TMP_MNT $DEV
if [[ $? != 0 ]]; then
fatal "mkfs failed"
fi
if [[ "$double_mkfs" == "double_format" ]]; then
mkfs.ubifs -y $option -m${page_size} -c 1024 -e $leb_size -f 4 -r $TMP_MNT $DEV
if [[ $? != 0 ]]; then
fatal "mkfs failed"
fi
fi
else
mkfs.ubifs $option -m${page_size} -c 1024 -e $leb_size -f 4 -r $TMP_MNT -o $IMG_FILE
if [[ $? != 0 ]]; then
fatal "mkfs failed"
fi
ubiupdatevol $DEV $IMG_FILE
if [[ $? != 0 ]]; then
fatal "ubiupdatevol failed"
fi
fi
if [[ "$need_fsck" == "do_fsck" ]]; then
fsck.ubifs -a $DEV # 'fsck.ubifs $DEV' is fine too.
res=$?
if [[ $res != $FSCK_OK ]]
then
fatal "fsck expects result $FSCK_OK, but $res is returned"
fi
fi
enable_chkfs
mount_ubifs $DEV $MNT "noauthentication" "noatime"
res=$?
if [[ $res != 0 ]]
then
fatal "mount fail $res"
fi
if [[ "$encryption" != "encrypted" ]]; then
# Check filesystem information, skip encrypted image.
# fscryptctl is not compatible with fscryptctl in mtd-utils.
# See https://github.com/google/fscryptctl/issues/33
du -sh $MNT > /dev/null # Make sure all files are accessible
ret=$?
if [[ $ret != 0 ]]; then
fatal "Cannot access all files"
fi
parse_dir "md5sum"
fi
check_err_msg
umount $MNT
res=$?
if [[ $res != 0 ]]
then
fatal "unmount fail $res"
fi
check_err_msg
disable_chkfs
if [[ "$test_medium" != "volume" ]]; then
rm -f $IMG_FILE
fi
modprobe -r ubifs
modprobe -r ubi
modprobe -r $simulator
echo "----------------------------------------------------------------------"
}
check_fsstress
start_t=$(date +%s)
echo "Do mkfs+fsck+mount test in kinds of flashes"
mount -t tmpfs -osize=50m none $TMP_MNT || fatal "cannot mount tmpfs"
echo 123 > $TMP_MNT/file
setfattr -n user.xyz -v 123abc $TMP_MNT/file
fsstress -d $TMP_MNT -l30 -n10 -p4
# Record filesystem information
rm -f $TMP_FILE 2>/dev/null
read_dir $TMP_MNT "md5sum"
# No authentication tests, which needs a specific key from certs directory corresponding to linux source code..
# See https://patchwork.ozlabs.org/project/linux-mtd/cover/20190806104928.1224-1-s.hauer@pengutronix.de/
for simulator in "mtdram" "nandsim"; do
for encryption in "encrypted" "noencrypted"; do
for test_medium in "volume" "file"; do
for space_fix in "fix_space" "nofix_space"; do
for need_fsck in "do_fsck" "no_fsck"; do
for double_mkfs in "double_format" "format_once"; do
run_test "$simulator" "64" "64" "2048" $encryption $test_medium $space_fix $need_fsck $double_mkfs
run_test "$simulator" "128" "128" "2048" $encryption $test_medium $space_fix $need_fsck $double_mkfs
run_test "$simulator" "512" "512" "2048" $encryption $test_medium $space_fix $need_fsck $double_mkfs
run_test "$simulator" "1024" "512" "2048" $encryption $test_medium $space_fix $need_fsck $double_mkfs
done
done
done
done
done
done
umount $TMP_MNT
rm -f $TMP_FILE 2>/dev/null
end_t=$(date +%s)
time_cost=$(( end_t - start_t ))
echo "Success, cost $time_cost seconds"
exit 0
|