~ [ 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-4.16.18)


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