| .. | .. |
|---|
| 86 | 86 | fi |
|---|
| 87 | 87 | fi |
|---|
| 88 | 88 | |
|---|
| 89 | +# Try platform (EFI embedded fw) loading too |
|---|
| 90 | +if [ ! -e "$DIR"/trigger_request_platform ]; then |
|---|
| 91 | + echo "$0: firmware loading: platform trigger not present, ignoring test" >&2 |
|---|
| 92 | +else |
|---|
| 93 | + if printf '\000' >"$DIR"/trigger_request_platform 2> /dev/null; then |
|---|
| 94 | + echo "$0: empty filename should not succeed (platform)" >&2 |
|---|
| 95 | + exit 1 |
|---|
| 96 | + fi |
|---|
| 97 | + |
|---|
| 98 | + # Note we echo a non-existing name, since files on the file-system |
|---|
| 99 | + # are preferred over firmware embedded inside the platform's firmware |
|---|
| 100 | + # The test adds a fake entry with the requested name to the platform's |
|---|
| 101 | + # fw list, so the name does not matter as long as it does not exist |
|---|
| 102 | + if ! echo -n "nope-$NAME" >"$DIR"/trigger_request_platform ; then |
|---|
| 103 | + echo "$0: could not trigger request platform" >&2 |
|---|
| 104 | + exit 1 |
|---|
| 105 | + fi |
|---|
| 106 | + |
|---|
| 107 | + # The test verifies itself that the loaded firmware contents matches |
|---|
| 108 | + # the contents for the fake platform fw entry it added. |
|---|
| 109 | + echo "$0: platform loading works" |
|---|
| 110 | +fi |
|---|
| 111 | + |
|---|
| 89 | 112 | ### Batched requests tests |
|---|
| 90 | 113 | test_config_present() |
|---|
| 91 | 114 | { |
|---|
| .. | .. |
|---|
| 114 | 137 | config_set_name() |
|---|
| 115 | 138 | { |
|---|
| 116 | 139 | echo -n $1 > $DIR/config_name |
|---|
| 140 | +} |
|---|
| 141 | + |
|---|
| 142 | +config_set_into_buf() |
|---|
| 143 | +{ |
|---|
| 144 | + echo 1 > $DIR/config_into_buf |
|---|
| 145 | +} |
|---|
| 146 | + |
|---|
| 147 | +config_unset_into_buf() |
|---|
| 148 | +{ |
|---|
| 149 | + echo 0 > $DIR/config_into_buf |
|---|
| 150 | +} |
|---|
| 151 | + |
|---|
| 152 | +config_set_buf_size() |
|---|
| 153 | +{ |
|---|
| 154 | + echo $1 > $DIR/config_buf_size |
|---|
| 155 | +} |
|---|
| 156 | + |
|---|
| 157 | +config_set_file_offset() |
|---|
| 158 | +{ |
|---|
| 159 | + echo $1 > $DIR/config_file_offset |
|---|
| 160 | +} |
|---|
| 161 | + |
|---|
| 162 | +config_set_partial() |
|---|
| 163 | +{ |
|---|
| 164 | + echo 1 > $DIR/config_partial |
|---|
| 165 | +} |
|---|
| 166 | + |
|---|
| 167 | +config_unset_partial() |
|---|
| 168 | +{ |
|---|
| 169 | + echo 0 > $DIR/config_partial |
|---|
| 117 | 170 | } |
|---|
| 118 | 171 | |
|---|
| 119 | 172 | config_set_sync_direct() |
|---|
| .. | .. |
|---|
| 153 | 206 | |
|---|
| 154 | 207 | read_firmwares() |
|---|
| 155 | 208 | { |
|---|
| 209 | + if [ "$(cat $DIR/config_into_buf)" == "1" ]; then |
|---|
| 210 | + fwfile="$FW_INTO_BUF" |
|---|
| 211 | + else |
|---|
| 212 | + fwfile="$FW" |
|---|
| 213 | + fi |
|---|
| 214 | + if [ "$1" = "xzonly" ]; then |
|---|
| 215 | + fwfile="${fwfile}-orig" |
|---|
| 216 | + fi |
|---|
| 156 | 217 | for i in $(seq 0 3); do |
|---|
| 157 | 218 | config_set_read_fw_idx $i |
|---|
| 158 | 219 | # Verify the contents are what we expect. |
|---|
| 159 | 220 | # -Z required for now -- check for yourself, md5sum |
|---|
| 160 | 221 | # on $FW and DIR/read_firmware will yield the same. Even |
|---|
| 161 | 222 | # cmp agrees, so something is off. |
|---|
| 162 | | - if ! diff -q -Z "$FW" $DIR/read_firmware 2>/dev/null ; then |
|---|
| 223 | + if ! diff -q -Z "$fwfile" $DIR/read_firmware 2>/dev/null ; then |
|---|
| 163 | 224 | echo "request #$i: firmware was not loaded" >&2 |
|---|
| 225 | + exit 1 |
|---|
| 226 | + fi |
|---|
| 227 | + done |
|---|
| 228 | +} |
|---|
| 229 | + |
|---|
| 230 | +read_partial_firmwares() |
|---|
| 231 | +{ |
|---|
| 232 | + if [ "$(cat $DIR/config_into_buf)" == "1" ]; then |
|---|
| 233 | + fwfile="${FW_INTO_BUF}" |
|---|
| 234 | + else |
|---|
| 235 | + fwfile="${FW}" |
|---|
| 236 | + fi |
|---|
| 237 | + |
|---|
| 238 | + if [ "$1" = "xzonly" ]; then |
|---|
| 239 | + fwfile="${fwfile}-orig" |
|---|
| 240 | + fi |
|---|
| 241 | + |
|---|
| 242 | + # Strip fwfile down to match partial offset and length |
|---|
| 243 | + partial_data="$(cat $fwfile)" |
|---|
| 244 | + partial_data="${partial_data:$2:$3}" |
|---|
| 245 | + |
|---|
| 246 | + for i in $(seq 0 3); do |
|---|
| 247 | + config_set_read_fw_idx $i |
|---|
| 248 | + |
|---|
| 249 | + read_firmware="$(cat $DIR/read_firmware)" |
|---|
| 250 | + |
|---|
| 251 | + # Verify the contents are what we expect. |
|---|
| 252 | + if [ $read_firmware != $partial_data ]; then |
|---|
| 253 | + echo "request #$i: partial firmware was not loaded" >&2 |
|---|
| 164 | 254 | exit 1 |
|---|
| 165 | 255 | fi |
|---|
| 166 | 256 | done |
|---|
| .. | .. |
|---|
| 183 | 273 | echo -n "Batched request_firmware() nofile try #$1: " |
|---|
| 184 | 274 | config_reset |
|---|
| 185 | 275 | config_set_name nope-test-firmware.bin |
|---|
| 276 | + config_trigger_sync |
|---|
| 277 | + read_firmwares_expect_nofile |
|---|
| 278 | + release_all_firmware |
|---|
| 279 | + echo "OK" |
|---|
| 280 | +} |
|---|
| 281 | + |
|---|
| 282 | +test_batched_request_firmware_into_buf_nofile() |
|---|
| 283 | +{ |
|---|
| 284 | + echo -n "Batched request_firmware_into_buf() nofile try #$1: " |
|---|
| 285 | + config_reset |
|---|
| 286 | + config_set_name nope-test-firmware.bin |
|---|
| 287 | + config_set_into_buf |
|---|
| 288 | + config_trigger_sync |
|---|
| 289 | + read_firmwares_expect_nofile |
|---|
| 290 | + release_all_firmware |
|---|
| 291 | + echo "OK" |
|---|
| 292 | +} |
|---|
| 293 | + |
|---|
| 294 | +test_request_partial_firmware_into_buf_nofile() |
|---|
| 295 | +{ |
|---|
| 296 | + echo -n "Test request_partial_firmware_into_buf() off=$1 size=$2 nofile: " |
|---|
| 297 | + config_reset |
|---|
| 298 | + config_set_name nope-test-firmware.bin |
|---|
| 299 | + config_set_into_buf |
|---|
| 300 | + config_set_partial |
|---|
| 301 | + config_set_buf_size $2 |
|---|
| 302 | + config_set_file_offset $1 |
|---|
| 186 | 303 | config_trigger_sync |
|---|
| 187 | 304 | read_firmwares_expect_nofile |
|---|
| 188 | 305 | release_all_firmware |
|---|
| .. | .. |
|---|
| 246 | 363 | |
|---|
| 247 | 364 | test_batched_request_firmware() |
|---|
| 248 | 365 | { |
|---|
| 249 | | - echo -n "Batched request_firmware() try #$1: " |
|---|
| 366 | + echo -n "Batched request_firmware() $2 try #$1: " |
|---|
| 250 | 367 | config_reset |
|---|
| 251 | 368 | config_trigger_sync |
|---|
| 252 | | - read_firmwares |
|---|
| 369 | + read_firmwares $2 |
|---|
| 370 | + release_all_firmware |
|---|
| 371 | + echo "OK" |
|---|
| 372 | +} |
|---|
| 373 | + |
|---|
| 374 | +test_batched_request_firmware_into_buf() |
|---|
| 375 | +{ |
|---|
| 376 | + echo -n "Batched request_firmware_into_buf() $2 try #$1: " |
|---|
| 377 | + config_reset |
|---|
| 378 | + config_set_name $TEST_FIRMWARE_INTO_BUF_FILENAME |
|---|
| 379 | + config_set_into_buf |
|---|
| 380 | + config_trigger_sync |
|---|
| 381 | + read_firmwares $2 |
|---|
| 253 | 382 | release_all_firmware |
|---|
| 254 | 383 | echo "OK" |
|---|
| 255 | 384 | } |
|---|
| 256 | 385 | |
|---|
| 257 | 386 | test_batched_request_firmware_direct() |
|---|
| 258 | 387 | { |
|---|
| 259 | | - echo -n "Batched request_firmware_direct() try #$1: " |
|---|
| 388 | + echo -n "Batched request_firmware_direct() $2 try #$1: " |
|---|
| 260 | 389 | config_reset |
|---|
| 261 | 390 | config_set_sync_direct |
|---|
| 262 | 391 | config_trigger_sync |
|---|
| .. | .. |
|---|
| 266 | 395 | |
|---|
| 267 | 396 | test_request_firmware_nowait_uevent() |
|---|
| 268 | 397 | { |
|---|
| 269 | | - echo -n "Batched request_firmware_nowait(uevent=true) try #$1: " |
|---|
| 398 | + echo -n "Batched request_firmware_nowait(uevent=true) $2 try #$1: " |
|---|
| 270 | 399 | config_reset |
|---|
| 271 | 400 | config_trigger_async |
|---|
| 272 | 401 | release_all_firmware |
|---|
| .. | .. |
|---|
| 275 | 404 | |
|---|
| 276 | 405 | test_request_firmware_nowait_custom() |
|---|
| 277 | 406 | { |
|---|
| 278 | | - echo -n "Batched request_firmware_nowait(uevent=false) try #$1: " |
|---|
| 407 | + echo -n "Batched request_firmware_nowait(uevent=false) $2 try #$1: " |
|---|
| 279 | 408 | config_reset |
|---|
| 280 | 409 | config_unset_uevent |
|---|
| 281 | 410 | RANDOM_FILE_PATH=$(setup_random_file) |
|---|
| 282 | 411 | RANDOM_FILE="$(basename $RANDOM_FILE_PATH)" |
|---|
| 412 | + if [ "$2" = "both" ]; then |
|---|
| 413 | + xz -9 -C crc32 -k $RANDOM_FILE_PATH |
|---|
| 414 | + elif [ "$2" = "xzonly" ]; then |
|---|
| 415 | + xz -9 -C crc32 $RANDOM_FILE_PATH |
|---|
| 416 | + fi |
|---|
| 283 | 417 | config_set_name $RANDOM_FILE |
|---|
| 284 | 418 | config_trigger_async |
|---|
| 419 | + release_all_firmware |
|---|
| 420 | + echo "OK" |
|---|
| 421 | +} |
|---|
| 422 | + |
|---|
| 423 | +test_request_partial_firmware_into_buf() |
|---|
| 424 | +{ |
|---|
| 425 | + echo -n "Test request_partial_firmware_into_buf() off=$1 size=$2: " |
|---|
| 426 | + config_reset |
|---|
| 427 | + config_set_name $TEST_FIRMWARE_INTO_BUF_FILENAME |
|---|
| 428 | + config_set_into_buf |
|---|
| 429 | + config_set_partial |
|---|
| 430 | + config_set_buf_size $2 |
|---|
| 431 | + config_set_file_offset $1 |
|---|
| 432 | + config_trigger_sync |
|---|
| 433 | + read_partial_firmwares normal $1 $2 |
|---|
| 285 | 434 | release_all_firmware |
|---|
| 286 | 435 | echo "OK" |
|---|
| 287 | 436 | } |
|---|
| .. | .. |
|---|
| 294 | 443 | echo |
|---|
| 295 | 444 | echo "Testing with the file present..." |
|---|
| 296 | 445 | for i in $(seq 1 5); do |
|---|
| 297 | | - test_batched_request_firmware $i |
|---|
| 446 | + test_batched_request_firmware $i normal |
|---|
| 298 | 447 | done |
|---|
| 299 | 448 | |
|---|
| 300 | 449 | for i in $(seq 1 5); do |
|---|
| 301 | | - test_batched_request_firmware_direct $i |
|---|
| 450 | + test_batched_request_firmware_into_buf $i normal |
|---|
| 302 | 451 | done |
|---|
| 303 | 452 | |
|---|
| 304 | 453 | for i in $(seq 1 5); do |
|---|
| 305 | | - test_request_firmware_nowait_uevent $i |
|---|
| 454 | + test_batched_request_firmware_direct $i normal |
|---|
| 306 | 455 | done |
|---|
| 307 | 456 | |
|---|
| 308 | 457 | for i in $(seq 1 5); do |
|---|
| 309 | | - test_request_firmware_nowait_custom $i |
|---|
| 458 | + test_request_firmware_nowait_uevent $i normal |
|---|
| 310 | 459 | done |
|---|
| 460 | + |
|---|
| 461 | +for i in $(seq 1 5); do |
|---|
| 462 | + test_request_firmware_nowait_custom $i normal |
|---|
| 463 | +done |
|---|
| 464 | + |
|---|
| 465 | +# Partial loads cannot use fallback, so do not repeat tests. |
|---|
| 466 | +test_request_partial_firmware_into_buf 0 10 |
|---|
| 467 | +test_request_partial_firmware_into_buf 0 5 |
|---|
| 468 | +test_request_partial_firmware_into_buf 1 6 |
|---|
| 469 | +test_request_partial_firmware_into_buf 2 10 |
|---|
| 311 | 470 | |
|---|
| 312 | 471 | # Test for file not found, errors are expected, the failure would be |
|---|
| 313 | 472 | # a hung task, which would require a hard reset. |
|---|
| .. | .. |
|---|
| 315 | 474 | echo "Testing with the file missing..." |
|---|
| 316 | 475 | for i in $(seq 1 5); do |
|---|
| 317 | 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 |
|---|
| 318 | 481 | done |
|---|
| 319 | 482 | |
|---|
| 320 | 483 | for i in $(seq 1 5); do |
|---|
| .. | .. |
|---|
| 329 | 492 | test_request_firmware_nowait_custom_nofile $i |
|---|
| 330 | 493 | done |
|---|
| 331 | 494 | |
|---|
| 495 | +# Partial loads cannot use fallback, so do not repeat tests. |
|---|
| 496 | +test_request_partial_firmware_into_buf_nofile 0 10 |
|---|
| 497 | +test_request_partial_firmware_into_buf_nofile 0 5 |
|---|
| 498 | +test_request_partial_firmware_into_buf_nofile 1 6 |
|---|
| 499 | +test_request_partial_firmware_into_buf_nofile 2 10 |
|---|
| 500 | + |
|---|
| 501 | +test "$HAS_FW_LOADER_COMPRESS" != "yes" && exit 0 |
|---|
| 502 | + |
|---|
| 503 | +# test with both files present |
|---|
| 504 | +xz -9 -C crc32 -k $FW |
|---|
| 505 | +config_set_name $NAME |
|---|
| 506 | +echo |
|---|
| 507 | +echo "Testing with both plain and xz files present..." |
|---|
| 508 | +for i in $(seq 1 5); do |
|---|
| 509 | + test_batched_request_firmware $i both |
|---|
| 510 | +done |
|---|
| 511 | + |
|---|
| 512 | +for i in $(seq 1 5); do |
|---|
| 513 | + test_batched_request_firmware_into_buf $i both |
|---|
| 514 | +done |
|---|
| 515 | + |
|---|
| 516 | +for i in $(seq 1 5); do |
|---|
| 517 | + test_batched_request_firmware_direct $i both |
|---|
| 518 | +done |
|---|
| 519 | + |
|---|
| 520 | +for i in $(seq 1 5); do |
|---|
| 521 | + test_request_firmware_nowait_uevent $i both |
|---|
| 522 | +done |
|---|
| 523 | + |
|---|
| 524 | +for i in $(seq 1 5); do |
|---|
| 525 | + test_request_firmware_nowait_custom $i both |
|---|
| 526 | +done |
|---|
| 527 | + |
|---|
| 528 | +# test with only xz file present |
|---|
| 529 | +mv "$FW" "${FW}-orig" |
|---|
| 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 |
|---|
| 551 | + |
|---|
| 332 | 552 | exit 0 |
|---|