Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: firmware: Simplify test patterns

The test patterns are almost same in three sequential tests.
Make the unified helper function for improving the readability.

Link: https://lore.kernel.org/all/20210127154939.13288-1-tiwai@suse.de/
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20220421152908.4718-5-tiwai@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Takashi Iwai and committed by
Greg Kroah-Hartman
f18b45ff 04c826d0

+30 -76
+30 -76
tools/testing/selftests/firmware/fw_filesystem.sh
··· 437 437 echo "OK" 438 438 } 439 439 440 + do_tests () 441 + { 442 + mode="$1" 443 + suffix="$2" 444 + 445 + for i in $(seq 1 5); do 446 + test_batched_request_firmware$suffix $i $mode 447 + done 448 + 449 + for i in $(seq 1 5); do 450 + test_batched_request_firmware_into_buf$suffix $i $mode 451 + done 452 + 453 + for i in $(seq 1 5); do 454 + test_batched_request_firmware_direct$suffix $i $mode 455 + done 456 + 457 + for i in $(seq 1 5); do 458 + test_request_firmware_nowait_uevent$suffix $i $mode 459 + done 460 + 461 + for i in $(seq 1 5); do 462 + test_request_firmware_nowait_custom$suffix $i $mode 463 + done 464 + } 465 + 440 466 # Only continue if batched request triggers are present on the 441 467 # test-firmware driver 442 468 test_config_present ··· 470 444 # test with the file present 471 445 echo 472 446 echo "Testing with the file present..." 473 - for i in $(seq 1 5); do 474 - test_batched_request_firmware $i normal 475 - done 476 - 477 - for i in $(seq 1 5); do 478 - test_batched_request_firmware_into_buf $i normal 479 - done 480 - 481 - for i in $(seq 1 5); do 482 - test_batched_request_firmware_direct $i normal 483 - done 484 - 485 - for i in $(seq 1 5); do 486 - test_request_firmware_nowait_uevent $i normal 487 - done 488 - 489 - for i in $(seq 1 5); do 490 - test_request_firmware_nowait_custom $i normal 491 - done 447 + do_tests normal 492 448 493 449 # Partial loads cannot use fallback, so do not repeat tests. 494 450 test_request_partial_firmware_into_buf 0 10 ··· 482 474 # a hung task, which would require a hard reset. 483 475 echo 484 476 echo "Testing with the file missing..." 485 - for i in $(seq 1 5); do 486 - test_batched_request_firmware_nofile $i 487 - done 488 - 489 - for i in $(seq 1 5); do 490 - test_batched_request_firmware_into_buf_nofile $i 491 - done 492 - 493 - for i in $(seq 1 5); do 494 - test_batched_request_firmware_direct_nofile $i 495 - done 496 - 497 - for i in $(seq 1 5); do 498 - test_request_firmware_nowait_uevent_nofile $i 499 - done 500 - 501 - for i in $(seq 1 5); do 502 - test_request_firmware_nowait_custom_nofile $i 503 - done 477 + do_tests nofile _nofile 504 478 505 479 # Partial loads cannot use fallback, so do not repeat tests. 506 480 test_request_partial_firmware_into_buf_nofile 0 10 ··· 498 508 config_set_name $NAME 499 509 echo 500 510 echo "Testing with both plain and xz files present..." 501 - for i in $(seq 1 5); do 502 - test_batched_request_firmware $i both 503 - done 504 - 505 - for i in $(seq 1 5); do 506 - test_batched_request_firmware_into_buf $i both 507 - done 508 - 509 - for i in $(seq 1 5); do 510 - test_batched_request_firmware_direct $i both 511 - done 512 - 513 - for i in $(seq 1 5); do 514 - test_request_firmware_nowait_uevent $i both 515 - done 516 - 517 - for i in $(seq 1 5); do 518 - test_request_firmware_nowait_custom $i both 519 - done 511 + do_tests both 520 512 521 513 # test with only xz file present 522 514 mv "$FW" "${FW}-orig" 523 515 mv "$FW_INTO_BUF" "${FW_INTO_BUF}-orig" 524 516 echo 525 517 echo "Testing with only xz file present..." 526 - for i in $(seq 1 5); do 527 - test_batched_request_firmware $i xzonly 528 - done 529 - 530 - for i in $(seq 1 5); do 531 - test_batched_request_firmware_into_buf $i xzonly 532 - done 533 - 534 - for i in $(seq 1 5); do 535 - test_batched_request_firmware_direct $i xzonly 536 - done 537 - 538 - for i in $(seq 1 5); do 539 - test_request_firmware_nowait_uevent $i xzonly 540 - done 541 - 542 - for i in $(seq 1 5); do 543 - test_request_firmware_nowait_custom $i xzonly 544 - done 518 + do_tests xzonly 545 519 546 520 exit 0