Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2430576lqb; Mon, 27 May 2024 22:07:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVzkZ+GbZTJB4owKpPNqmZu8awg5+I5aOzZLSOWSzP1XCxvC/LTKEuTtrf006CkL+PFFDXecZS0BRc90uu92pgmpBe6c61VK0dsWOiyVw== X-Google-Smtp-Source: AGHT+IF4p8DVdPBOQyJcJf/irw+ICf7pE/O623ElTE5se6eRjcMHEsN0qUlx0JfZGVM5mgIKspyG X-Received: by 2002:a92:c566:0:b0:36d:bddc:2fb3 with SMTP id e9e14a558f8ab-3737b28a412mr131717275ab.7.1716872859824; Mon, 27 May 2024 22:07:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716872859; cv=pass; d=google.com; s=arc-20160816; b=06MJJpCW+pB9olGlIrBiMs+COMEuZOs6q97C5nfWbkPUrl724XtxMJdmn4NrntS1q5 eF3BJRG+gssfhX/GYIFSDD9+TpBFkTsc+h8vwj+vSQxP/oB9ZNIYqZAMfqQDsUcEOpUk pxmDBPMMHiSSht0wDLvpg8jI9G9gKlxmCmBXDPsmP3d8FocnXTQx//0WU3TrcIxXgviY iZT0dc0ILmD3+ojkWJ4MXu4aehaVccFZpaNnIq0WCy3B2svWse/4Ea+Xsv2Qb5xYwlDQ 8qUd/p/aKiH8HQQLp5kRVDcpebrIghXOxwM4K+zLDUgVJC9g1o7InkZZbFZugS3+Sz2Q SeMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=I3zENHlc5wEUkSXlaomjJgvBrL6+txM9jzU39ej24YU=; fh=G19b1/02jVuK/IQA74E6NAg4B1iVTkiT1n992vBavxQ=; b=qwnrPXGz6UmjN1J/HYl12SXwVUqQsPJ0kfgDhil3htrdRdONfGN9v3NNUynrrBqXEe raiJOmdL/uNHHEz8C3ypnupqMad9b/V2sluaZ5GMxlzvVYCMXfFtDeJNN8fYTnTReD3V OwQ3+2C5T6FqaLp/bp/Ukmib4TgSiztQJsikBGx3GYNO8+Iet1QGhmVbUVw/DJC+vXmN nfXpSSjOxIJQaeCORF7LV9O4ew0Xug5ikFdHKXH7JGee3Zqby9EX8hn0ItM7Uj4mzbCQ QvWYCa826HxbL7UofFKtQo6N5lJY/hXKPgmpAcLM457i3Myy4X6pOp+UAB3E//IMF3uq 0irQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MQqiwmwW; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-191752-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191752-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-68221c6ac2bsi7368631a12.115.2024.05.27.22.07.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 22:07:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191752-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MQqiwmwW; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-191752-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191752-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DF4D5284B69 for ; Tue, 28 May 2024 05:06:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37E5B3FB87; Tue, 28 May 2024 05:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="MQqiwmwW" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0F8945024; Tue, 28 May 2024 05:06:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716872764; cv=none; b=FtiyNC4yQAMCDnC91XtZlDwSW9FmOW972qNXKRP3Ghs93MiywqV1Fw8iFfCtE/MlTP/imj5svl7RGqJxOMA3xwhgC4y5ea3Q1/gDfk7Lon+OWRlqOPh7jbpYfBHJJ8tW1yiZUr30QnchOm1zcD3aMLusknM67yoXHd99tb/NaT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716872764; c=relaxed/simple; bh=QEn037aGR5cXUuVp/2L37AuO0NPPPU2+ZHA3zGxRGqo=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=bwaQjaG1BisG8T6NFA4Ao6UyRRTQDjoHsMzOggiDGKi4mSCYYFPXCV/RfMU/oSLHa7bmVcKjMuco7D59Lhtv1lHSHdA8u0BNQ/n+jHqju6MlwuyYBAYcH8orPabmH4X+g73E+pSDc4nzrZ7cP1Tzf9KqtUS6bSTPRjMKoz5Gu6g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=MQqiwmwW; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1716872761; bh=QEn037aGR5cXUuVp/2L37AuO0NPPPU2+ZHA3zGxRGqo=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=MQqiwmwWElSXojLLiK1uxGYthfGxhuNK2QNYe7mJOdxUuRP1Fhh6UYIv/8BjlVUL1 od9tPTGlQHlhaOf96UK2vGb/7sl0RLEnjIIykUKBvRp07iR5LqeWA3RnrR3E6+1EpS e0Ly9fuZ/+wGZhA84KLAxaNLFI0DiV7fCNJTbS+Ag28M34kKhwhcQ6WLO/CdZvM2J2 EHCnwU5tWm+X8izwkM/au9/P3tVBVHpKl1ik8U2My+mX2u44BTT3zcEK60d3X+f5Wx 96ZaHJY6yXfmX+g29xH9amndcs123dewRoHiFkQsRCGii8PDtO2rZtz1dSG9Uef4qE h/nUFUpwzs91g== Received: from [100.113.15.66] (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 385C13782137; Tue, 28 May 2024 05:05:57 +0000 (UTC) Message-ID: <4fb5ad2e-cc9f-4ad6-94a5-7de9f503ab94@collabora.com> Date: Tue, 28 May 2024 10:05:28 +0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , kernel@collabora.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] selftests: tpm2: conform test to TAP output To: Shuah Khan References: <20240426091435.2742024-1-usama.anjum@collabora.com> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: <20240426091435.2742024-1-usama.anjum@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Kind reminder On 4/26/24 2:14 PM, Muhammad Usama Anjum wrote: > The python unittest is being used for executing tests. TAP output > cannot be added in the unittest framework. The python unittest is being > run from a script. Add the output TAP logs to the script. Add "#" > prefix to the python unittest output which will mark all output as > informational TAP messages. Check exit status of the python unittest to > decide if test passed or failed. Not sure why but python unittest > outputs logs in stderr. So redirect the logs to stdout and then add > prefix. > > Specify the bash explicitly instead of sh to run these tests as all of > the kselftests are shifting towards using bash explicitly. Some > interpreters have different syntax and cause issues. > > Signed-off-by: Muhammad Usama Anjum > --- > tools/testing/selftests/tpm2/test_async.sh | 24 ++++++++++++++++------ > tools/testing/selftests/tpm2/test_smoke.sh | 19 ++++++++++++++--- > tools/testing/selftests/tpm2/test_space.sh | 19 ++++++++++++++--- > 3 files changed, 50 insertions(+), 12 deletions(-) > > diff --git a/tools/testing/selftests/tpm2/test_async.sh b/tools/testing/selftests/tpm2/test_async.sh > index 43bf5bd772fd4..0e6e5d9d649fb 100755 > --- a/tools/testing/selftests/tpm2/test_async.sh > +++ b/tools/testing/selftests/tpm2/test_async.sh > @@ -1,10 +1,22 @@ > -#!/bin/sh > +#!/bin/bash > # SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) > > -# Kselftest framework requirement - SKIP code is 4. > -ksft_skip=4 > +DIR="$(dirname $(readlink -f "$0"))" > +source "${DIR}"/../kselftest/ktap_helpers.sh > > -[ -e /dev/tpm0 ] || exit $ksft_skip > -[ -e /dev/tpmrm0 ] || exit $ksft_skip > +ktap_print_header > > -python3 -m unittest -v tpm2_tests.AsyncTest > +[ -e /dev/tpm0 ] || ktap_finished > +[ -e /dev/tpmrm0 ] || ktap_finished > + > +ktap_set_plan 1 > + > +python3 -m unittest -v tpm2_tests.AsyncTest 2>&1 | sed "s/^/# /" > + > +if [ ${PIPESTATUS[0]} -eq $ksft_pass ]; then > + ktap_test_pass "tpm2_tests.AsyncTest" > +else > + ktap_test_fail "tpm2_tests.AsyncTest" > +fi > + > +ktap_finished > diff --git a/tools/testing/selftests/tpm2/test_smoke.sh b/tools/testing/selftests/tpm2/test_smoke.sh > index 58af963e5b55a..2219a180de91d 100755 > --- a/tools/testing/selftests/tpm2/test_smoke.sh > +++ b/tools/testing/selftests/tpm2/test_smoke.sh > @@ -1,9 +1,22 @@ > -#!/bin/sh > +#!/bin/bash > # SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) > > # Kselftest framework requirement - SKIP code is 4. > -ksft_skip=4 > +DIR="$(dirname $(readlink -f "$0"))" > +source "${DIR}"/../kselftest/ktap_helpers.sh > + > +ktap_print_header > > [ -e /dev/tpm0 ] || exit $ksft_skip > > -python3 -m unittest -v tpm2_tests.SmokeTest > +ktap_set_plan 1 > + > +python3 -m unittest -v tpm2_tests.SmokeTest 2>&1 | sed "s/^/# /" > + > +if [ ${PIPESTATUS[0]} -eq $ksft_pass ]; then > + ktap_test_pass "tpm2_tests.AsyncTest" > +else > + ktap_test_fail "tpm2_tests.AsyncTest" > +fi > + > +ktap_finished > diff --git a/tools/testing/selftests/tpm2/test_space.sh b/tools/testing/selftests/tpm2/test_space.sh > index 04c47b13fe8ac..6a55d13d74983 100755 > --- a/tools/testing/selftests/tpm2/test_space.sh > +++ b/tools/testing/selftests/tpm2/test_space.sh > @@ -1,9 +1,22 @@ > -#!/bin/sh > +#!/bin/bash > # SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) > > # Kselftest framework requirement - SKIP code is 4. > -ksft_skip=4 > +DIR="$(dirname $(readlink -f "$0"))" > +source "${DIR}"/../kselftest/ktap_helpers.sh > + > +ktap_print_header > > [ -e /dev/tpmrm0 ] || exit $ksft_skip > > -python3 -m unittest -v tpm2_tests.SpaceTest > +ktap_set_plan 1 > + > +python3 -m unittest -v tpm2_tests.SpaceTest 2>&1 | sed "s/^/# /" > + > +if [ ${PIPESTATUS[0]} -eq $ksft_pass ]; then > + ktap_test_pass "tpm2_tests.AsyncTest" > +else > + ktap_test_fail "tpm2_tests.AsyncTest" > +fi > + > +ktap_finished -- BR, Muhammad Usama Anjum