Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp80817ybv; Wed, 19 Feb 2020 16:49:28 -0800 (PST) X-Google-Smtp-Source: APXvYqyhyrfKDXKWBu3EkSsG+h2fMG5ENECKkOvAvAJvr7+KhWx3723QizoRgGN9ubWikK97u+qg X-Received: by 2002:a05:6808:3b4:: with SMTP id n20mr283229oie.78.1582159768470; Wed, 19 Feb 2020 16:49:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582159768; cv=none; d=google.com; s=arc-20160816; b=ZrzBdNBV28Zn81+wWP7KVG2z5UIzQqg3jcbl5V5hq/HT7UklKyJXF6LQ0tSgVMWcaU V2KXzRwey+OsmDIby6O79riQjWERiiKbKC9PRRoqAH0knzq2eWYOl5Bp5fmEp1V8TPnQ XhMvMp37p+f/b7nOD95zkYB0DHSeh8krcCz7EHvFsfNTKmCYaHA1qRlnpCfRU1FuMoNV J7nXFfFPN8GjfIzwulNlyRd9JiYIqjqTPziDWqIaDUAowhvKd9l1jpVQqQVjp92kI3WG 93Az6sy+LXDXrrJXiJPucfpGTs+sX1LAaLRKQ5k7XbqqIFYiP/KFI/v1KedyqTKBO1OZ Lytw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=FyfNbWZdKxFWvrYaFX6247ohGc1n6i2IlhYtU0R4MSc=; b=BGL/9vzaTaF6cSJtlotg/kP4283U2HGhhYd+D+VPyeUJO46IUtglXDS5aFViksFwP+ 76lNw5nmJF/K3PLqDOadThPzsaoq2e9swBpqrK0j8fGT7eWATIGnyeWH/XR3Z/tv+8GQ Ivjh1lBRvy7YmGtdQ/ZHKLD7piq35PWD8lOrWEiMi7211qCHluTiQCNMXb4qHEqODhJG 9qI+IlDG9MUrtl1u+30HXgcYJqU9sjid27EM8CRflywBhBh8r33htashUaUSzAXOuzRb Az7nkAcIzWf0jXZX/WmMhw8Y6eMJqtg6yTV4nP69gg0ROTbJWvBWKwEGGzHKC5C/CXAc 6pdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=TKzkpIoy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q126si10528955oia.8.2020.02.19.16.49.16; Wed, 19 Feb 2020 16:49:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=TKzkpIoy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727747AbgBTAsx (ORCPT + 99 others); Wed, 19 Feb 2020 19:48:53 -0500 Received: from mail-pf1-f170.google.com ([209.85.210.170]:33252 "EHLO mail-pf1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727683AbgBTAsv (ORCPT ); Wed, 19 Feb 2020 19:48:51 -0500 Received: by mail-pf1-f170.google.com with SMTP id n7so1006942pfn.0 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=erAzppXG+RLj90ZdtKcNDYi9XAhjN8/3tJu6FfjsYg8G2AvQx7HqWQDg0Moxn1pJF0 9pkgfNI3Knu9AcyXZgPmvCkuZ3vJ4JzzH68PAsXC6EAMVRaht2MXyiLV1i2DpdZx/Hxn hTc4YHq/lWh7CLtJVsQa0I228FBfIz77zGbTtw8pquMtxF9tUVO6ukhixvD2SfM3wI1c V2zl9hsyxTSEhXqQxAxyMsG6b1sZOYkTR51V/r/my39lLi/I00ixg6Si13q4qM+1+q/E q/x/B7YcoWb88Z2u01+ZED2LjEXZ3lKGNacEx9+oWjWXr2oDT41WeAKcfSvE6LDKisqI qNcA== X-Gm-Message-State: APjAAAVmMe76FOsaCsCvFniebwp+6sjq5WZhLPu8uHxrHpVjK4xriaWL Q5sJReOhIKiRNjnYvTXdxIYaGg== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 -- 2.17.1