Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp590990pxb; Wed, 27 Jan 2021 16:04:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOiZakErMe8IGDKYm345YVJr95HyhJiCwE6gNsqrFFb+IEOM0dGQpO50OK+JwnDHEqSoBp X-Received: by 2002:aa7:d4d2:: with SMTP id t18mr11646794edr.238.1611792262691; Wed, 27 Jan 2021 16:04:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611792262; cv=none; d=google.com; s=arc-20160816; b=lTZzCMFffvKyUp6W6vC1Z0TXFTUsV5YeNk54b+RxeNHP6JVR8r4pfjJ26FrRcSE8DH 58n/hZkcOWZnCCOQJeTGOpRSA8l90wfst9yoN1IUlHE7Sz+AxNT18gWTS1FqZU/3iOwp Pnx8Tb5IU1AZeBDv69H3WQQIpej6B+4ppj0C3uZfrm8yLbsELuFcGxRmYg7+q3MW4AsP OUlsdiPH6P+lAbQIrwSfV7UCXLoJisWtgQUuqWq0Y2cS21YXE9+83HyF6Rl0tpt/AKAV dSJtRfD79xp7Dyajw1+cZ+OfPAO5g0WbbY6LlzAiG6sEigRsyhEYoK/suub2PzW8iyjU CVOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zf4nuOtYNQzxyGF1ulk4CuHh8mAjB8flzLELFBhO0vQ=; b=qmCIp4RSBlQ2KoQntaGBO6RYxEs//um+phvk0ENH9viORfyl9dx2CNF6zMcRY9reL8 hGmZynprc29nJ2fWDOiWVUjXrxtSS1t1zJBDBEyKQP0NtAD7PxM7d9SakOBTuDmV4f+3 uNlz/Tel2bt29rdzwEjM3tHnKI4M7WWtKEIakUDOgoa+iXe4++itzysL5lf8EeBvrpHB 01HOA/LapqYIJIhqdBTz2aYlNNY/JDSJcaFMV97+96xPiiIym9MvlcZCsdDUARgfV2/f MU+YIlW2VW1EQzdfEzM3dHio4swP5HDAwZUnIu8TkEPZHPiArfoH1t/kwxoknP5Zfled rViA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si1505909ejb.482.2021.01.27.16.03.58; Wed, 27 Jan 2021 16:04:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236607AbhA0PwJ (ORCPT + 99 others); Wed, 27 Jan 2021 10:52:09 -0500 Received: from mx2.suse.de ([195.135.220.15]:50362 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236003AbhA0PuY (ORCPT ); Wed, 27 Jan 2021 10:50:24 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D2623AE47; Wed, 27 Jan 2021 15:49:40 +0000 (UTC) From: Takashi Iwai To: Luis Chamberlain Cc: Greg Kroah-Hartman , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH RFC 2/4] selftests: firmware: Simplify test patterns Date: Wed, 27 Jan 2021 16:49:37 +0100 Message-Id: <20210127154939.13288-3-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210127154939.13288-1-tiwai@suse.de> References: <20210127154939.13288-1-tiwai@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The test patterns are almost same in three sequential tests. Make the unified helper function for improving the readability. Signed-off-by: Takashi Iwai --- .../selftests/firmware/fw_filesystem.sh | 106 +++++------------- 1 file changed, 30 insertions(+), 76 deletions(-) diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh index c2a2a100114b..2424a97da65b 100755 --- a/tools/testing/selftests/firmware/fw_filesystem.sh +++ b/tools/testing/selftests/firmware/fw_filesystem.sh @@ -435,6 +435,32 @@ test_request_partial_firmware_into_buf() echo "OK" } +do_tests () +{ + mode="$1" + suffix="$2" + + for i in $(seq 1 5); do + test_batched_request_firmware$suffix $i $mode + done + + for i in $(seq 1 5); do + test_batched_request_firmware_into_buf$suffix $i $mode + done + + for i in $(seq 1 5); do + test_batched_request_firmware_direct$suffix $i $mode + done + + for i in $(seq 1 5); do + test_request_firmware_nowait_uevent$suffix $i $mode + done + + for i in $(seq 1 5); do + test_request_firmware_nowait_custom$suffix $i $mode + done +} + # Only continue if batched request triggers are present on the # test-firmware driver test_config_present @@ -442,25 +468,7 @@ test_config_present # test with the file present echo echo "Testing with the file present..." -for i in $(seq 1 5); do - test_batched_request_firmware $i normal -done - -for i in $(seq 1 5); do - test_batched_request_firmware_into_buf $i normal -done - -for i in $(seq 1 5); do - test_batched_request_firmware_direct $i normal -done - -for i in $(seq 1 5); do - test_request_firmware_nowait_uevent $i normal -done - -for i in $(seq 1 5); do - test_request_firmware_nowait_custom $i normal -done +do_tests normal # Partial loads cannot use fallback, so do not repeat tests. test_request_partial_firmware_into_buf 0 10 @@ -472,25 +480,7 @@ test_request_partial_firmware_into_buf 2 10 # a hung task, which would require a hard reset. echo echo "Testing with the file missing..." -for i in $(seq 1 5); do - test_batched_request_firmware_nofile $i -done - -for i in $(seq 1 5); do - test_batched_request_firmware_into_buf_nofile $i -done - -for i in $(seq 1 5); do - test_batched_request_firmware_direct_nofile $i -done - -for i in $(seq 1 5); do - test_request_firmware_nowait_uevent_nofile $i -done - -for i in $(seq 1 5); do - test_request_firmware_nowait_custom_nofile $i -done +do_tests nofile _nofile # Partial loads cannot use fallback, so do not repeat tests. test_request_partial_firmware_into_buf_nofile 0 10 @@ -505,48 +495,12 @@ xz -9 -C crc32 -k $FW config_set_name $NAME echo echo "Testing with both plain and xz files present..." -for i in $(seq 1 5); do - test_batched_request_firmware $i both -done - -for i in $(seq 1 5); do - test_batched_request_firmware_into_buf $i both -done - -for i in $(seq 1 5); do - test_batched_request_firmware_direct $i both -done - -for i in $(seq 1 5); do - test_request_firmware_nowait_uevent $i both -done - -for i in $(seq 1 5); do - test_request_firmware_nowait_custom $i both -done +do_tests both # test with only xz file present mv "$FW" "${FW}-orig" echo echo "Testing with only xz file present..." -for i in $(seq 1 5); do - test_batched_request_firmware $i xzonly -done - -for i in $(seq 1 5); do - test_batched_request_firmware_into_buf $i xzonly -done - -for i in $(seq 1 5); do - test_batched_request_firmware_direct $i xzonly -done - -for i in $(seq 1 5); do - test_request_firmware_nowait_uevent $i xzonly -done - -for i in $(seq 1 5); do - test_request_firmware_nowait_custom $i xzonly -done +do_tests xzonly exit 0 -- 2.26.2