~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/firmware/fw_filesystem.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/firmware/fw_filesystem.sh (Version linux-6.12-rc7) and /tools/testing/selftests/firmware/fw_filesystem.sh (Version linux-5.12.19)


  1 #!/bin/bash                                         1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3 # This validates that the kernel will load fir      3 # This validates that the kernel will load firmware out of its list of
  4 # firmware locations on disk. Since the user h      4 # firmware locations on disk. Since the user helper does similar work,
  5 # we reset the custom load directory to a loca      5 # we reset the custom load directory to a location the user helper doesn't
  6 # know so we can be sure we're not accidentall      6 # know so we can be sure we're not accidentally testing the user helper.
  7 set -e                                              7 set -e
  8                                                     8 
  9 TEST_REQS_FW_SYSFS_FALLBACK="no"                    9 TEST_REQS_FW_SYSFS_FALLBACK="no"
 10 TEST_REQS_FW_SET_CUSTOM_PATH="yes"                 10 TEST_REQS_FW_SET_CUSTOM_PATH="yes"
 11 TEST_DIR=$(dirname $0)                             11 TEST_DIR=$(dirname $0)
 12 source $TEST_DIR/fw_lib.sh                         12 source $TEST_DIR/fw_lib.sh
 13                                                    13 
 14 RUN_XZ="xz -C crc32 --lzma2=dict=2MiB"         << 
 15 RUN_ZSTD="zstd -q"                             << 
 16                                                << 
 17 check_mods                                         14 check_mods
 18 check_setup                                        15 check_setup
 19 verify_reqs                                        16 verify_reqs
 20 setup_tmp_file                                     17 setup_tmp_file
 21                                                    18 
 22 trap "test_finish" EXIT                            19 trap "test_finish" EXIT
 23                                                    20 
 24 if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; t     21 if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
 25         # Turn down the timeout so failures do     22         # Turn down the timeout so failures don't take so long.
 26         echo 1 >/sys/class/firmware/timeout        23         echo 1 >/sys/class/firmware/timeout
 27 fi                                                 24 fi
 28                                                    25 
 29 if printf '\000' >"$DIR"/trigger_request 2> /d     26 if printf '\000' >"$DIR"/trigger_request 2> /dev/null; then
 30         echo "$0: empty filename should not su     27         echo "$0: empty filename should not succeed" >&2
 31         exit 1                                     28         exit 1
 32 fi                                                 29 fi
 33                                                    30 
 34 if [ ! -e "$DIR"/trigger_async_request ]; then     31 if [ ! -e "$DIR"/trigger_async_request ]; then
 35         echo "$0: empty filename: async trigge     32         echo "$0: empty filename: async trigger not present, ignoring test" >&2
 36         exit $ksft_skip                            33         exit $ksft_skip
 37 else                                               34 else
 38         if printf '\000' >"$DIR"/trigger_async     35         if printf '\000' >"$DIR"/trigger_async_request 2> /dev/null; then
 39                 echo "$0: empty filename shoul     36                 echo "$0: empty filename should not succeed (async)" >&2
 40                 exit 1                             37                 exit 1
 41         fi                                         38         fi
 42 fi                                                 39 fi
 43                                                    40 
 44 # Request a firmware that doesn't exist, it sh     41 # Request a firmware that doesn't exist, it should fail.
 45 if echo -n "nope-$NAME" >"$DIR"/trigger_reques     42 if echo -n "nope-$NAME" >"$DIR"/trigger_request 2> /dev/null; then
 46         echo "$0: firmware shouldn't have load     43         echo "$0: firmware shouldn't have loaded" >&2
 47         exit 1                                     44         exit 1
 48 fi                                                 45 fi
 49 if diff -q "$FW" /dev/test_firmware >/dev/null     46 if diff -q "$FW" /dev/test_firmware >/dev/null ; then
 50         echo "$0: firmware was not expected to     47         echo "$0: firmware was not expected to match" >&2
 51         exit 1                                     48         exit 1
 52 else                                               49 else
 53         if [ "$HAS_FW_LOADER_USER_HELPER" = "y     50         if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
 54                 echo "$0: timeout works"           51                 echo "$0: timeout works"
 55         fi                                         52         fi
 56 fi                                                 53 fi
 57                                                    54 
 58 # This should succeed via kernel load or will      55 # This should succeed via kernel load or will fail after 1 second after
 59 # being handed over to the user helper, which      56 # being handed over to the user helper, which won't find the fw either.
 60 if ! echo -n "$NAME" >"$DIR"/trigger_request ;     57 if ! echo -n "$NAME" >"$DIR"/trigger_request ; then
 61         echo "$0: could not trigger request" >     58         echo "$0: could not trigger request" >&2
 62         exit 1                                     59         exit 1
 63 fi                                                 60 fi
 64                                                    61 
 65 # Verify the contents are what we expect.          62 # Verify the contents are what we expect.
 66 if ! diff -q "$FW" /dev/test_firmware >/dev/nu     63 if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
 67         echo "$0: firmware was not loaded" >&2     64         echo "$0: firmware was not loaded" >&2
 68         exit 1                                     65         exit 1
 69 else                                               66 else
 70         echo "$0: filesystem loading works"        67         echo "$0: filesystem loading works"
 71 fi                                                 68 fi
 72                                                    69 
 73 # Try the asynchronous version too                 70 # Try the asynchronous version too
 74 if [ ! -e "$DIR"/trigger_async_request ]; then     71 if [ ! -e "$DIR"/trigger_async_request ]; then
 75         echo "$0: firmware loading: async trig     72         echo "$0: firmware loading: async trigger not present, ignoring test" >&2
 76         exit $ksft_skip                            73         exit $ksft_skip
 77 else                                               74 else
 78         if ! echo -n "$NAME" >"$DIR"/trigger_a     75         if ! echo -n "$NAME" >"$DIR"/trigger_async_request ; then
 79                 echo "$0: could not trigger as     76                 echo "$0: could not trigger async request" >&2
 80                 exit 1                             77                 exit 1
 81         fi                                         78         fi
 82                                                    79 
 83         # Verify the contents are what we expe     80         # Verify the contents are what we expect.
 84         if ! diff -q "$FW" /dev/test_firmware      81         if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
 85                 echo "$0: firmware was not loa     82                 echo "$0: firmware was not loaded (async)" >&2
 86                 exit 1                             83                 exit 1
 87         else                                       84         else
 88                 echo "$0: async filesystem loa     85                 echo "$0: async filesystem loading works"
 89         fi                                         86         fi
 90 fi                                                 87 fi
 91                                                    88 
 92 # Try platform (EFI embedded fw) loading too       89 # Try platform (EFI embedded fw) loading too
 93 if [ ! -e "$DIR"/trigger_request_platform ]; t     90 if [ ! -e "$DIR"/trigger_request_platform ]; then
 94         echo "$0: firmware loading: platform t     91         echo "$0: firmware loading: platform trigger not present, ignoring test" >&2
 95 else                                               92 else
 96         if printf '\000' >"$DIR"/trigger_reque     93         if printf '\000' >"$DIR"/trigger_request_platform 2> /dev/null; then
 97                 echo "$0: empty filename shoul     94                 echo "$0: empty filename should not succeed (platform)" >&2
 98                 exit 1                             95                 exit 1
 99         fi                                         96         fi
100                                                    97 
101         # Note we echo a non-existing name, si     98         # Note we echo a non-existing name, since files on the file-system
102         # are preferred over firmware embedded     99         # are preferred over firmware embedded inside the platform's firmware
103         # The test adds a fake entry with the     100         # The test adds a fake entry with the requested name to the platform's
104         # fw list, so the name does not matter    101         # fw list, so the name does not matter as long as it does not exist
105         if ! echo -n "nope-$NAME" >"$DIR"/trig    102         if ! echo -n "nope-$NAME" >"$DIR"/trigger_request_platform ; then
106                 echo "$0: could not trigger re    103                 echo "$0: could not trigger request platform" >&2
107                 exit 1                            104                 exit 1
108         fi                                        105         fi
109                                                   106 
110         # The test verifies itself that the lo    107         # The test verifies itself that the loaded firmware contents matches
111         # the contents for the fake platform f    108         # the contents for the fake platform fw entry it added.
112         echo "$0: platform loading works"         109         echo "$0: platform loading works"
113 fi                                                110 fi
114                                                   111 
115 ### Batched requests tests                        112 ### Batched requests tests
116 test_config_present()                             113 test_config_present()
117 {                                                 114 {
118         if [ ! -f $DIR/reset ]; then              115         if [ ! -f $DIR/reset ]; then
119                 echo "Configuration triggers n    116                 echo "Configuration triggers not present, ignoring test"
120                 exit $ksft_skip                   117                 exit $ksft_skip
121         fi                                        118         fi
122 }                                                 119 }
123                                                   120 
124 # Defaults :                                      121 # Defaults :
125 #                                                 122 #
126 # send_uevent: 1                                  123 # send_uevent: 1
127 # sync_direct: 0                                  124 # sync_direct: 0
128 # name: test-firmware.bin                         125 # name: test-firmware.bin
129 # num_requests: 4                                 126 # num_requests: 4
130 config_reset()                                    127 config_reset()
131 {                                                 128 {
132         echo 1 >  $DIR/reset                      129         echo 1 >  $DIR/reset
133 }                                                 130 }
134                                                   131 
135 release_all_firmware()                            132 release_all_firmware()
136 {                                                 133 {
137         echo 1 >  $DIR/release_all_firmware       134         echo 1 >  $DIR/release_all_firmware
138 }                                                 135 }
139                                                   136 
140 config_set_name()                                 137 config_set_name()
141 {                                                 138 {
142         echo -n $1 >  $DIR/config_name            139         echo -n $1 >  $DIR/config_name
143 }                                                 140 }
144                                                   141 
145 config_set_into_buf()                             142 config_set_into_buf()
146 {                                                 143 {
147         echo 1 >  $DIR/config_into_buf            144         echo 1 >  $DIR/config_into_buf
148 }                                                 145 }
149                                                   146 
150 config_unset_into_buf()                           147 config_unset_into_buf()
151 {                                                 148 {
152         echo 0 >  $DIR/config_into_buf            149         echo 0 >  $DIR/config_into_buf
153 }                                                 150 }
154                                                   151 
155 config_set_buf_size()                             152 config_set_buf_size()
156 {                                                 153 {
157         echo $1 >  $DIR/config_buf_size           154         echo $1 >  $DIR/config_buf_size
158 }                                                 155 }
159                                                   156 
160 config_set_file_offset()                          157 config_set_file_offset()
161 {                                                 158 {
162         echo $1 >  $DIR/config_file_offset        159         echo $1 >  $DIR/config_file_offset
163 }                                                 160 }
164                                                   161 
165 config_set_partial()                              162 config_set_partial()
166 {                                                 163 {
167         echo 1 >  $DIR/config_partial             164         echo 1 >  $DIR/config_partial
168 }                                                 165 }
169                                                   166 
170 config_unset_partial()                            167 config_unset_partial()
171 {                                                 168 {
172         echo 0 >  $DIR/config_partial             169         echo 0 >  $DIR/config_partial
173 }                                                 170 }
174                                                   171 
175 config_set_sync_direct()                          172 config_set_sync_direct()
176 {                                                 173 {
177         echo 1 >  $DIR/config_sync_direct         174         echo 1 >  $DIR/config_sync_direct
178 }                                                 175 }
179                                                   176 
180 config_unset_sync_direct()                        177 config_unset_sync_direct()
181 {                                                 178 {
182         echo 0 >  $DIR/config_sync_direct         179         echo 0 >  $DIR/config_sync_direct
183 }                                                 180 }
184                                                   181 
185 config_set_uevent()                               182 config_set_uevent()
186 {                                                 183 {
187         echo 1 >  $DIR/config_send_uevent         184         echo 1 >  $DIR/config_send_uevent
188 }                                                 185 }
189                                                   186 
190 config_unset_uevent()                             187 config_unset_uevent()
191 {                                                 188 {
192         echo 0 >  $DIR/config_send_uevent         189         echo 0 >  $DIR/config_send_uevent
193 }                                                 190 }
194                                                   191 
195 config_trigger_sync()                             192 config_trigger_sync()
196 {                                                 193 {
197         echo -n 1 > $DIR/trigger_batched_reque    194         echo -n 1 > $DIR/trigger_batched_requests 2>/dev/null
198 }                                                 195 }
199                                                   196 
200 config_trigger_async()                            197 config_trigger_async()
201 {                                                 198 {
202         echo -n 1 > $DIR/trigger_batched_reque    199         echo -n 1 > $DIR/trigger_batched_requests_async 2> /dev/null
203 }                                                 200 }
204                                                   201 
205 config_set_read_fw_idx()                          202 config_set_read_fw_idx()
206 {                                                 203 {
207         echo -n $1 > $DIR/config_read_fw_idx 2    204         echo -n $1 > $DIR/config_read_fw_idx 2> /dev/null
208 }                                                 205 }
209                                                   206 
210 read_firmwares()                                  207 read_firmwares()
211 {                                                 208 {
212         if [ "$(cat $DIR/config_into_buf)" ==     209         if [ "$(cat $DIR/config_into_buf)" == "1" ]; then
213                 fwfile="$FW_INTO_BUF"             210                 fwfile="$FW_INTO_BUF"
214         else                                      211         else
215                 fwfile="$FW"                      212                 fwfile="$FW"
216         fi                                        213         fi
217         if [ "$1" = "componly" ]; then         !! 214         if [ "$1" = "xzonly" ]; then
218                 fwfile="${fwfile}-orig"           215                 fwfile="${fwfile}-orig"
219         fi                                        216         fi
220         for i in $(seq 0 3); do                   217         for i in $(seq 0 3); do
221                 config_set_read_fw_idx $i         218                 config_set_read_fw_idx $i
222                 # Verify the contents are what    219                 # Verify the contents are what we expect.
223                 # -Z required for now -- check    220                 # -Z required for now -- check for yourself, md5sum
224                 # on $FW and DIR/read_firmware    221                 # on $FW and DIR/read_firmware will yield the same. Even
225                 # cmp agrees, so something is     222                 # cmp agrees, so something is off.
226                 if ! diff -q -Z "$fwfile" $DIR    223                 if ! diff -q -Z "$fwfile" $DIR/read_firmware 2>/dev/null ; then
227                         echo "request #$i: fir    224                         echo "request #$i: firmware was not loaded" >&2
228                         exit 1                    225                         exit 1
229                 fi                                226                 fi
230         done                                      227         done
231 }                                                 228 }
232                                                   229 
233 read_partial_firmwares()                          230 read_partial_firmwares()
234 {                                                 231 {
235         if [ "$(cat $DIR/config_into_buf)" ==     232         if [ "$(cat $DIR/config_into_buf)" == "1" ]; then
236                 fwfile="${FW_INTO_BUF}"           233                 fwfile="${FW_INTO_BUF}"
237         else                                      234         else
238                 fwfile="${FW}"                    235                 fwfile="${FW}"
239         fi                                        236         fi
240                                                   237 
241         if [ "$1" = "componly" ]; then         !! 238         if [ "$1" = "xzonly" ]; then
242                 fwfile="${fwfile}-orig"           239                 fwfile="${fwfile}-orig"
243         fi                                        240         fi
244                                                   241 
245         # Strip fwfile down to match partial o    242         # Strip fwfile down to match partial offset and length
246         partial_data="$(cat $fwfile)"             243         partial_data="$(cat $fwfile)"
247         partial_data="${partial_data:$2:$3}"      244         partial_data="${partial_data:$2:$3}"
248                                                   245 
249         for i in $(seq 0 3); do                   246         for i in $(seq 0 3); do
250                 config_set_read_fw_idx $i         247                 config_set_read_fw_idx $i
251                                                   248 
252                 read_firmware="$(cat $DIR/read    249                 read_firmware="$(cat $DIR/read_firmware)"
253                                                   250 
254                 # Verify the contents are what    251                 # Verify the contents are what we expect.
255                 if [ $read_firmware != $partia    252                 if [ $read_firmware != $partial_data ]; then
256                         echo "request #$i: par    253                         echo "request #$i: partial firmware was not loaded" >&2
257                         exit 1                    254                         exit 1
258                 fi                                255                 fi
259         done                                      256         done
260 }                                                 257 }
261                                                   258 
262 read_firmwares_expect_nofile()                    259 read_firmwares_expect_nofile()
263 {                                                 260 {
264         for i in $(seq 0 3); do                   261         for i in $(seq 0 3); do
265                 config_set_read_fw_idx $i         262                 config_set_read_fw_idx $i
266                 # Ensures contents differ         263                 # Ensures contents differ
267                 if diff -q -Z "$FW" $DIR/read_    264                 if diff -q -Z "$FW" $DIR/read_firmware 2>/dev/null ; then
268                         echo "request $i: file    265                         echo "request $i: file was not expected to match" >&2
269                         exit 1                    266                         exit 1
270                 fi                                267                 fi
271         done                                      268         done
272 }                                                 269 }
273                                                   270 
274 test_batched_request_firmware_nofile()            271 test_batched_request_firmware_nofile()
275 {                                                 272 {
276         echo -n "Batched request_firmware() no    273         echo -n "Batched request_firmware() nofile try #$1: "
277         config_reset                              274         config_reset
278         config_set_name nope-test-firmware.bin    275         config_set_name nope-test-firmware.bin
279         config_trigger_sync                       276         config_trigger_sync
280         read_firmwares_expect_nofile              277         read_firmwares_expect_nofile
281         release_all_firmware                      278         release_all_firmware
282         echo "OK"                                 279         echo "OK"
283 }                                                 280 }
284                                                   281 
285 test_batched_request_firmware_into_buf_nofile(    282 test_batched_request_firmware_into_buf_nofile()
286 {                                                 283 {
287         echo -n "Batched request_firmware_into    284         echo -n "Batched request_firmware_into_buf() nofile try #$1: "
288         config_reset                              285         config_reset
289         config_set_name nope-test-firmware.bin    286         config_set_name nope-test-firmware.bin
290         config_set_into_buf                       287         config_set_into_buf
291         config_trigger_sync                       288         config_trigger_sync
292         read_firmwares_expect_nofile              289         read_firmwares_expect_nofile
293         release_all_firmware                      290         release_all_firmware
294         echo "OK"                                 291         echo "OK"
295 }                                                 292 }
296                                                   293 
297 test_request_partial_firmware_into_buf_nofile(    294 test_request_partial_firmware_into_buf_nofile()
298 {                                                 295 {
299         echo -n "Test request_partial_firmware    296         echo -n "Test request_partial_firmware_into_buf() off=$1 size=$2 nofile: "
300         config_reset                              297         config_reset
301         config_set_name nope-test-firmware.bin    298         config_set_name nope-test-firmware.bin
302         config_set_into_buf                       299         config_set_into_buf
303         config_set_partial                        300         config_set_partial
304         config_set_buf_size $2                    301         config_set_buf_size $2
305         config_set_file_offset $1                 302         config_set_file_offset $1
306         config_trigger_sync                       303         config_trigger_sync
307         read_firmwares_expect_nofile              304         read_firmwares_expect_nofile
308         release_all_firmware                      305         release_all_firmware
309         echo "OK"                                 306         echo "OK"
310 }                                                 307 }
311                                                   308 
312 test_batched_request_firmware_direct_nofile()     309 test_batched_request_firmware_direct_nofile()
313 {                                                 310 {
314         echo -n "Batched request_firmware_dire    311         echo -n "Batched request_firmware_direct() nofile try #$1: "
315         config_reset                              312         config_reset
316         config_set_name nope-test-firmware.bin    313         config_set_name nope-test-firmware.bin
317         config_set_sync_direct                    314         config_set_sync_direct
318         config_trigger_sync                       315         config_trigger_sync
319         release_all_firmware                      316         release_all_firmware
320         echo "OK"                                 317         echo "OK"
321 }                                                 318 }
322                                                   319 
323 test_request_firmware_nowait_uevent_nofile()      320 test_request_firmware_nowait_uevent_nofile()
324 {                                                 321 {
325         echo -n "Batched request_firmware_nowa    322         echo -n "Batched request_firmware_nowait(uevent=true) nofile try #$1: "
326         config_reset                              323         config_reset
327         config_set_name nope-test-firmware.bin    324         config_set_name nope-test-firmware.bin
328         config_trigger_async                      325         config_trigger_async
329         release_all_firmware                      326         release_all_firmware
330         echo "OK"                                 327         echo "OK"
331 }                                                 328 }
332                                                   329 
333 test_wait_and_cancel_custom_load()                330 test_wait_and_cancel_custom_load()
334 {                                                 331 {
335         if [ "$HAS_FW_LOADER_USER_HELPER" != "    332         if [ "$HAS_FW_LOADER_USER_HELPER" != "yes" ]; then
336                 return                            333                 return
337         fi                                        334         fi
338         local timeout=10                          335         local timeout=10
339         name=$1                                   336         name=$1
340         while [ ! -e "$DIR"/"$name"/loading ];    337         while [ ! -e "$DIR"/"$name"/loading ]; do
341                 sleep 0.1                         338                 sleep 0.1
342                 timeout=$(( $timeout - 1 ))       339                 timeout=$(( $timeout - 1 ))
343                 if [ "$timeout" -eq 0 ]; then     340                 if [ "$timeout" -eq 0 ]; then
344                         echo "firmware interfa    341                         echo "firmware interface never appeared:" >&2
345                         echo "$DIR/$name/loadi    342                         echo "$DIR/$name/loading" >&2
346                         exit 1                    343                         exit 1
347                 fi                                344                 fi
348         done                                      345         done
349         echo -1 >"$DIR"/"$name"/loading           346         echo -1 >"$DIR"/"$name"/loading
350 }                                                 347 }
351                                                   348 
352 test_request_firmware_nowait_custom_nofile()      349 test_request_firmware_nowait_custom_nofile()
353 {                                                 350 {
354         echo -n "Batched request_firmware_nowa    351         echo -n "Batched request_firmware_nowait(uevent=false) nofile try #$1: "
355         config_reset                              352         config_reset
356         config_unset_uevent                       353         config_unset_uevent
357         RANDOM_FILE_PATH=$(setup_random_file_f    354         RANDOM_FILE_PATH=$(setup_random_file_fake)
358         RANDOM_FILE="$(basename $RANDOM_FILE_P    355         RANDOM_FILE="$(basename $RANDOM_FILE_PATH)"
359         config_set_name $RANDOM_FILE              356         config_set_name $RANDOM_FILE
360         config_trigger_async &                    357         config_trigger_async &
361         test_wait_and_cancel_custom_load $RAND    358         test_wait_and_cancel_custom_load $RANDOM_FILE
362         wait                                      359         wait
363         release_all_firmware                      360         release_all_firmware
364         echo "OK"                                 361         echo "OK"
365 }                                                 362 }
366                                                   363 
367 test_batched_request_firmware()                   364 test_batched_request_firmware()
368 {                                                 365 {
369         echo -n "Batched request_firmware() $2    366         echo -n "Batched request_firmware() $2 try #$1: "
370         config_reset                              367         config_reset
371         config_trigger_sync                       368         config_trigger_sync
372         read_firmwares $2                         369         read_firmwares $2
373         release_all_firmware                      370         release_all_firmware
374         echo "OK"                                 371         echo "OK"
375 }                                                 372 }
376                                                   373 
377 test_batched_request_firmware_into_buf()          374 test_batched_request_firmware_into_buf()
378 {                                                 375 {
379         echo -n "Batched request_firmware_into    376         echo -n "Batched request_firmware_into_buf() $2 try #$1: "
380         config_reset                              377         config_reset
381         config_set_name $TEST_FIRMWARE_INTO_BU    378         config_set_name $TEST_FIRMWARE_INTO_BUF_FILENAME
382         config_set_into_buf                       379         config_set_into_buf
383         config_trigger_sync                       380         config_trigger_sync
384         read_firmwares $2                         381         read_firmwares $2
385         release_all_firmware                      382         release_all_firmware
386         echo "OK"                                 383         echo "OK"
387 }                                                 384 }
388                                                   385 
389 test_batched_request_firmware_direct()            386 test_batched_request_firmware_direct()
390 {                                                 387 {
391         echo -n "Batched request_firmware_dire    388         echo -n "Batched request_firmware_direct() $2 try #$1: "
392         config_reset                              389         config_reset
393         config_set_sync_direct                    390         config_set_sync_direct
394         config_trigger_sync                       391         config_trigger_sync
395         release_all_firmware                      392         release_all_firmware
396         echo "OK"                                 393         echo "OK"
397 }                                                 394 }
398                                                   395 
399 test_request_firmware_nowait_uevent()             396 test_request_firmware_nowait_uevent()
400 {                                                 397 {
401         echo -n "Batched request_firmware_nowa    398         echo -n "Batched request_firmware_nowait(uevent=true) $2 try #$1: "
402         config_reset                              399         config_reset
403         config_trigger_async                      400         config_trigger_async
404         release_all_firmware                      401         release_all_firmware
405         echo "OK"                                 402         echo "OK"
406 }                                                 403 }
407                                                   404 
408 test_request_firmware_nowait_custom()             405 test_request_firmware_nowait_custom()
409 {                                                 406 {
410         echo -n "Batched request_firmware_nowa    407         echo -n "Batched request_firmware_nowait(uevent=false) $2 try #$1: "
411         config_reset                              408         config_reset
412         config_unset_uevent                       409         config_unset_uevent
413         RANDOM_FILE_PATH=$(setup_random_file)     410         RANDOM_FILE_PATH=$(setup_random_file)
414         RANDOM_FILE="$(basename $RANDOM_FILE_P    411         RANDOM_FILE="$(basename $RANDOM_FILE_PATH)"
415         if [ -n "$2" -a "$2" != "normal" ]; th !! 412         if [ "$2" = "both" ]; then
416                 compress_"$2"_"$COMPRESS_FORMA !! 413                 xz -9 -C crc32 -k $RANDOM_FILE_PATH
                                                   >> 414         elif [ "$2" = "xzonly" ]; then
                                                   >> 415                 xz -9 -C crc32 $RANDOM_FILE_PATH
417         fi                                        416         fi
418         config_set_name $RANDOM_FILE              417         config_set_name $RANDOM_FILE
419         config_trigger_async                      418         config_trigger_async
420         release_all_firmware                      419         release_all_firmware
421         echo "OK"                                 420         echo "OK"
422 }                                                 421 }
423                                                   422 
424 test_request_partial_firmware_into_buf()          423 test_request_partial_firmware_into_buf()
425 {                                                 424 {
426         echo -n "Test request_partial_firmware    425         echo -n "Test request_partial_firmware_into_buf() off=$1 size=$2: "
427         config_reset                              426         config_reset
428         config_set_name $TEST_FIRMWARE_INTO_BU    427         config_set_name $TEST_FIRMWARE_INTO_BUF_FILENAME
429         config_set_into_buf                       428         config_set_into_buf
430         config_set_partial                        429         config_set_partial
431         config_set_buf_size $2                    430         config_set_buf_size $2
432         config_set_file_offset $1                 431         config_set_file_offset $1
433         config_trigger_sync                       432         config_trigger_sync
434         read_partial_firmwares normal $1 $2       433         read_partial_firmwares normal $1 $2
435         release_all_firmware                      434         release_all_firmware
436         echo "OK"                                 435         echo "OK"
437 }                                                 436 }
438                                                   437 
439 do_tests ()                                    << 
440 {                                              << 
441         mode="$1"                              << 
442         suffix="$2"                            << 
443                                                << 
444         for i in $(seq 1 5); do                << 
445                 test_batched_request_firmware$ << 
446         done                                   << 
447                                                << 
448         for i in $(seq 1 5); do                << 
449                 test_batched_request_firmware_ << 
450         done                                   << 
451                                                << 
452         for i in $(seq 1 5); do                << 
453                 test_batched_request_firmware_ << 
454         done                                   << 
455                                                << 
456         for i in $(seq 1 5); do                << 
457                 test_request_firmware_nowait_u << 
458         done                                   << 
459                                                << 
460         for i in $(seq 1 5); do                << 
461                 test_request_firmware_nowait_c << 
462         done                                   << 
463 }                                              << 
464                                                << 
465 # Only continue if batched request triggers ar    438 # Only continue if batched request triggers are present on the
466 # test-firmware driver                            439 # test-firmware driver
467 test_config_present                               440 test_config_present
468                                                   441 
469 # test with the file present                      442 # test with the file present
470 echo                                              443 echo
471 echo "Testing with the file present..."           444 echo "Testing with the file present..."
472 do_tests normal                                !! 445 for i in $(seq 1 5); do
                                                   >> 446         test_batched_request_firmware $i normal
                                                   >> 447 done
                                                   >> 448 
                                                   >> 449 for i in $(seq 1 5); do
                                                   >> 450         test_batched_request_firmware_into_buf $i normal
                                                   >> 451 done
                                                   >> 452 
                                                   >> 453 for i in $(seq 1 5); do
                                                   >> 454         test_batched_request_firmware_direct $i normal
                                                   >> 455 done
                                                   >> 456 
                                                   >> 457 for i in $(seq 1 5); do
                                                   >> 458         test_request_firmware_nowait_uevent $i normal
                                                   >> 459 done
                                                   >> 460 
                                                   >> 461 for i in $(seq 1 5); do
                                                   >> 462         test_request_firmware_nowait_custom $i normal
                                                   >> 463 done
473                                                   464 
474 # Partial loads cannot use fallback, so do not    465 # Partial loads cannot use fallback, so do not repeat tests.
475 test_request_partial_firmware_into_buf 0 10       466 test_request_partial_firmware_into_buf 0 10
476 test_request_partial_firmware_into_buf 0 5        467 test_request_partial_firmware_into_buf 0 5
477 test_request_partial_firmware_into_buf 1 6        468 test_request_partial_firmware_into_buf 1 6
478 test_request_partial_firmware_into_buf 2 10       469 test_request_partial_firmware_into_buf 2 10
479                                                   470 
480 # Test for file not found, errors are expected    471 # Test for file not found, errors are expected, the failure would be
481 # a hung task, which would require a hard rese    472 # a hung task, which would require a hard reset.
482 echo                                              473 echo
483 echo "Testing with the file missing..."           474 echo "Testing with the file missing..."
484 do_tests nofile _nofile                        !! 475 for i in $(seq 1 5); do
                                                   >> 476         test_batched_request_firmware_nofile $i
                                                   >> 477 done
                                                   >> 478 
                                                   >> 479 for i in $(seq 1 5); do
                                                   >> 480         test_batched_request_firmware_into_buf_nofile $i
                                                   >> 481 done
                                                   >> 482 
                                                   >> 483 for i in $(seq 1 5); do
                                                   >> 484         test_batched_request_firmware_direct_nofile $i
                                                   >> 485 done
                                                   >> 486 
                                                   >> 487 for i in $(seq 1 5); do
                                                   >> 488         test_request_firmware_nowait_uevent_nofile $i
                                                   >> 489 done
                                                   >> 490 
                                                   >> 491 for i in $(seq 1 5); do
                                                   >> 492         test_request_firmware_nowait_custom_nofile $i
                                                   >> 493 done
485                                                   494 
486 # Partial loads cannot use fallback, so do not    495 # Partial loads cannot use fallback, so do not repeat tests.
487 test_request_partial_firmware_into_buf_nofile     496 test_request_partial_firmware_into_buf_nofile 0 10
488 test_request_partial_firmware_into_buf_nofile     497 test_request_partial_firmware_into_buf_nofile 0 5
489 test_request_partial_firmware_into_buf_nofile     498 test_request_partial_firmware_into_buf_nofile 1 6
490 test_request_partial_firmware_into_buf_nofile     499 test_request_partial_firmware_into_buf_nofile 2 10
491                                                   500 
492 test_request_firmware_compressed ()            !! 501 test "$HAS_FW_LOADER_COMPRESS" != "yes" && exit 0
493 {                                              << 
494         export COMPRESS_FORMAT="$1"            << 
495                                                << 
496         # test with both files present         << 
497         compress_both_"$COMPRESS_FORMAT" $FW   << 
498         compress_both_"$COMPRESS_FORMAT" $FW_I << 
499                                                << 
500         config_set_name $NAME                  << 
501         echo                                   << 
502         echo "Testing with both plain and $COM << 
503         do_tests both                          << 
504                                                << 
505         # test with only compressed file prese << 
506         mv "$FW" "${FW}-orig"                  << 
507         mv "$FW_INTO_BUF" "${FW_INTO_BUF}-orig << 
508                                                << 
509         config_set_name $NAME                  << 
510         echo                                   << 
511         echo "Testing with only $COMPRESS_FORM << 
512         do_tests componly                      << 
513                                                   502 
514         mv "${FW}-orig" "$FW"                  !! 503 # test with both files present
515         mv "${FW_INTO_BUF}-orig" "$FW_INTO_BUF !! 504 xz -9 -C crc32 -k $FW
516 }                                              !! 505 config_set_name $NAME
517                                                !! 506 echo
518 compress_both_XZ ()                            !! 507 echo "Testing with both plain and xz files present..."
519 {                                              !! 508 for i in $(seq 1 5); do
520         $RUN_XZ -k "$@"                        !! 509         test_batched_request_firmware $i both
521 }                                              !! 510 done
522                                                !! 511 
523 compress_componly_XZ ()                        !! 512 for i in $(seq 1 5); do
524 {                                              !! 513         test_batched_request_firmware_into_buf $i both
525         $RUN_XZ "$@"                           !! 514 done
526 }                                              !! 515 
527                                                !! 516 for i in $(seq 1 5); do
528 compress_both_ZSTD ()                          !! 517         test_batched_request_firmware_direct $i both
529 {                                              !! 518 done
530         $RUN_ZSTD -k "$@"                      !! 519 
531 }                                              !! 520 for i in $(seq 1 5); do
532                                                !! 521         test_request_firmware_nowait_uevent $i both
533 compress_componly_ZSTD ()                      !! 522 done
534 {                                              !! 523 
535         $RUN_ZSTD --rm "$@"                    !! 524 for i in $(seq 1 5); do
536 }                                              !! 525         test_request_firmware_nowait_custom $i both
537                                                !! 526 done
538 if test "$HAS_FW_LOADER_COMPRESS_XZ" = "yes";  << 
539         test_request_firmware_compressed XZ    << 
540 fi                                             << 
541                                                   527 
542 if test "$HAS_FW_LOADER_COMPRESS_ZSTD" = "yes" !! 528 # test with only xz file present
543         test_request_firmware_compressed ZSTD  !! 529 mv "$FW" "${FW}-orig"
544 fi                                             !! 530 echo
                                                   >> 531 echo "Testing with only xz file present..."
                                                   >> 532 for i in $(seq 1 5); do
                                                   >> 533         test_batched_request_firmware $i xzonly
                                                   >> 534 done
                                                   >> 535 
                                                   >> 536 for i in $(seq 1 5); do
                                                   >> 537         test_batched_request_firmware_into_buf $i xzonly
                                                   >> 538 done
                                                   >> 539 
                                                   >> 540 for i in $(seq 1 5); do
                                                   >> 541         test_batched_request_firmware_direct $i xzonly
                                                   >> 542 done
                                                   >> 543 
                                                   >> 544 for i in $(seq 1 5); do
                                                   >> 545         test_request_firmware_nowait_uevent $i xzonly
                                                   >> 546 done
                                                   >> 547 
                                                   >> 548 for i in $(seq 1 5); do
                                                   >> 549         test_request_firmware_nowait_custom $i xzonly
                                                   >> 550 done
545                                                   551 
546 exit 0                                            552 exit 0
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php