From patchwork Thu Feb 20 00:48:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Branden X-Patchwork-Id: 11392841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 172F9930 for ; Thu, 20 Feb 2020 00:49:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB5A924676 for ; Thu, 20 Feb 2020 00:49:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="TKzkpIoy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727723AbgBTAsx (ORCPT ); Wed, 19 Feb 2020 19:48:53 -0500 Received: from mail-pf1-f173.google.com ([209.85.210.173]:37248 "EHLO mail-pf1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727681AbgBTAsv (ORCPT ); Wed, 19 Feb 2020 19:48:51 -0500 Received: by mail-pf1-f173.google.com with SMTP id p14so995891pfn.4 for ; Wed, 19 Feb 2020 16:48:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FyfNbWZdKxFWvrYaFX6247ohGc1n6i2IlhYtU0R4MSc=; b=TKzkpIoyO6Ud+jx6k7yjvn9BnhBvU7p4rb3Z6rWbmD41Jkbg7oX2L4OHt6xC0WwyyV YizdQYav+qJuztIxOwg/XRFjv90VcOsGMLPoNNqxTOCR9r1wJMhLWJUjtM9oUjlPbnTy 7gIaxiBeBviHKuamYTR+XuTcJV8rE5A+BC3Kw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FyfNbWZdKxFWvrYaFX6247ohGc1n6i2IlhYtU0R4MSc=; b=X0CmpWC50sFoBjvQLYGGTzhXPV2YExHWnUguKLkM+WFxdPl22zIbRh0miWHAgh4Pq3 SPXhseMfSfZHFKRH8FPjmF11RqpA8WamlMKuiKyx96jSUZ5V18TP3K39q/ECgppBz0xt HjNppnQIFS8lr4GtT1scfEtWf3iUT3lUcCODiVgVK0OMCQvZH0X1ZTCd5TgQObglL7av nw4TJMbRDw/H0waQc+EhHfwD8eQe0hMTiv/AMkhqsnBNg65EHyjWNolWaT9tYFxJM7HR 1h0LV+VfrbbcAWNk/Y0U26ybPhid0moDCYIsxSWPzMHM7PqlCH+Sb64PT6NHm+U7W5rv JCFQ== X-Gm-Message-State: APjAAAXxJmvzNcPxXaB9S/f0FecohHL4pELEteoEkYIsplURtfYct27q /WOURspyQJeD5s/rJbkICQrtfw== X-Google-Smtp-Source: APXvYqwyAa/sHxlQcNiDnIb8oQK3EcBTrdcT47I160SBbxG2YWGq4/oM2Nk0hkIXgfBkbUN29+WrQw== X-Received: by 2002:a63:6383:: with SMTP id x125mr27759449pgb.409.1582159730320; Wed, 19 Feb 2020 16:48:50 -0800 (PST) Received: from lbrmn-lnxub113.broadcom.net ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id 64sm816323pfd.48.2020.02.19.16.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 16:48:49 -0800 (PST) From: Scott Branden To: Luis Chamberlain , Greg Kroah-Hartman , David Brown , Alexander Viro , Shuah Khan , bjorn.andersson@linaro.org, Shuah Khan , Arnd Bergmann Cc: "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, BCM Kernel Feedback , Olof Johansson , Andrew Morton , Dan Carpenter , Colin Ian King , Kees Cook , Takashi Iwai , linux-kselftest@vger.kernel.org, Andy Gross , Scott Branden Subject: [PATCH v2 4/7] firmware: test partial file reads of request_firmware_into_buf Date: Wed, 19 Feb 2020 16:48:22 -0800 Message-Id: <20200220004825.23372-5-scott.branden@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200220004825.23372-1-scott.branden@broadcom.com> References: <20200220004825.23372-1-scott.branden@broadcom.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add firmware tests for partial file reads of request_firmware_into_buf. Signed-off-by: Scott Branden --- .../selftests/firmware/fw_filesystem.sh | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh index 56894477c8bd..e973c658fe1a 100755 --- a/tools/testing/selftests/firmware/fw_filesystem.sh +++ b/tools/testing/selftests/firmware/fw_filesystem.sh @@ -126,6 +126,26 @@ config_unset_into_buf() echo 0 > $DIR/config_into_buf } +config_set_buf_size() +{ + echo $1 > $DIR/config_buf_size +} + +config_set_file_offset() +{ + echo $1 > $DIR/config_file_offset +} + +config_set_partial() +{ + echo 1 > $DIR/config_partial +} + +config_unset_partial() +{ + echo 0 > $DIR/config_partial +} + config_set_sync_direct() { echo 1 > $DIR/config_sync_direct @@ -184,6 +204,35 @@ read_firmwares() done } +read_firmwares_partial() +{ + if [ "$(cat $DIR/config_into_buf)" == "1" ]; then + fwfile="${FW_INTO_BUF}" + else + fwfile="${FW}" + fi + + if [ "$1" = "xzonly" ]; then + fwfile="${fwfile}-orig" + fi + + # Strip fwfile down to match partial offset and length + partial_data="$(cat $fwfile)" + partial_data="${partial_data:$2:$3}" + + for i in $(seq 0 3); do + config_set_read_fw_idx $i + + read_firmware="$(cat $DIR/read_firmware)" + + # Verify the contents are what we expect. + if [ $read_firmware != $partial_data ]; then + echo "request #$i: partial firmware was not loaded" >&2 + exit 1 + fi + done +} + read_firmwares_expect_nofile() { for i in $(seq 0 3); do @@ -296,6 +345,21 @@ test_batched_request_firmware_into_buf() echo "OK" } +test_batched_request_firmware_into_buf_partial() +{ + echo -n "Batched request_firmware_into_buf_partial() $2 off=$3 size=$4 try #$1: " + config_reset + config_set_name $TEST_FIRMWARE_INTO_BUF_FILENAME + config_set_into_buf + config_set_partial + config_set_buf_size $4 + config_set_file_offset $3 + config_trigger_sync + read_firmwares_partial $2 $3 $4 + release_all_firmware + echo "OK" +} + test_batched_request_firmware_direct() { echo -n "Batched request_firmware_direct() $2 try #$1: " @@ -348,6 +412,22 @@ 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_into_buf_partial $i normal 0 10 +done + +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_partial $i normal 0 5 +done + +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_partial $i normal 1 6 +done + +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_partial $i normal 2 10 +done + for i in $(seq 1 5); do test_batched_request_firmware_direct $i normal done