Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp144223lqf; Fri, 26 Apr 2024 02:14:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEGj19aKkYCJTTgENlwtzvcQre85cclflxUpALFn5H0xmnEEK6A6/G2kvCG+R+DsP787u2dokfldFMsqkHEfXHoSWaMMN89WizpMby+w== X-Google-Smtp-Source: AGHT+IFunBKJQGpr9plNBdalQUzeslGazLKjR7BjCIfKrQueONuOOKuUsNFTPW4f9OEoUUV5+Mwd X-Received: by 2002:a05:620a:22aa:b0:790:67c0:ad7a with SMTP id p10-20020a05620a22aa00b0079067c0ad7amr1815273qkh.58.1714122891599; Fri, 26 Apr 2024 02:14:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714122891; cv=pass; d=google.com; s=arc-20160816; b=aeQvPNnKNab8A7KOIiV3x1TfH8/p+QTiU3uAHLquH7uoj8s6cFo3sTkIlf9w8QFolu DRRRp5wIWN2jrNF20S/rlhT8zghRpVHFeiwCDXC29rWY6xneP7ZLZIz0F4YzWNdXK8JK SqLlg3tXOqkuWg+hxeABRZwTAua8DcVHd0EjRN6t5RVu5IehWaXVNpPI0QIOSxPfvjSB F6hs60S3xUtcwStADRqm33ZjhO/HpmCHnTVxbquzBQNnxD4kNxe/fGjV0VPVmwI2AuFN 6drdprt4iEsJlJN7IzHT3JoEy2ykhQYGpJZvhlaSTAXLVyy52fv7onyYVtXaXJMeV5cU sX5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=aLL2QKMJI1hndAzd+F/7xwwxly/5irDZFPUb0RBWkkY=; fh=3ITA+hG5KH7F/YE3za0C4YE3vOQC6OhXaAYfDI4ufbk=; b=mmTNNA4UY/wcWehElG2QB5F/lfd/4FLLxwrAY84DTsVpgabXTt5QsKlCBPXTQxKB14 xDuK1Mzu29W8H95voE0xuNLCETCgiuke4B+N2Bc8Xng384zFQFAQ1Lf/og7Z8MG0lHka aEkHahhrgVEIggHebhzzs5Ep0pPASosGHMdkx+obhlEfA7kAVeADlBB5c4/fyiO5gB/E cudVo4uEGeDj8U148xrSp8PgVwIUdya1+pkdko8M9aGBAoBxd3DMTM2JFe89utzk4Spy Hwdx+SakozWicz4toWnh8P+vy/kv1C/+fs8B/rmSnrKdyoy76lT+0sThMYsMxm8wQevt kTtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=snay4uiP; 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-159763-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159763-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v2-20020a05620a0f0200b0078ef154b69fsi22336593qkl.57.2024.04.26.02.14.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 02:14:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159763-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=snay4uiP; 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-159763-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159763-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5669B1C21BAA for ; Fri, 26 Apr 2024 09:14:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF5F313D8AF; Fri, 26 Apr 2024 09:14:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="snay4uiP" 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 68608282EA; Fri, 26 Apr 2024 09:14:19 +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=1714122861; cv=none; b=He4OLHxj7XkvnIejMzuabDKwjIgMpDgdm5aj/4f71VcOQSo/zmPKcoJ3H86c3eyc4+EWV7myjHUZaUAEebDwfPTMOIuBGfu9SShNsQODYPYREeJ29Ky0BiTz4VXjrfvXGi3PGC4WPl46XCiRFG0iVzM3/Dnqnv0E4rOGRSeVwic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714122861; c=relaxed/simple; bh=XRMyjyuFRMYv4naA7smww2pv7Fyy87chOndvIRM21zo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=VsqTIRwwMnvmyS1KEetxn8jOU1fgusojDCcgSYDDg4UwCcrnpFPP2WqmRUtdiDb6dIviaPCCm52BlHwDuVoGxGKfQWMAzXcfizjFsDX15Jjap0rFrHjrPkCprPGKFYby2LUp1Bf7c8Zy0t/DfZ8TTd9uyW6SzWNJW7oQIkPSIf0= 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=snay4uiP; 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=1714122857; bh=XRMyjyuFRMYv4naA7smww2pv7Fyy87chOndvIRM21zo=; h=From:To:Cc:Subject:Date:From; b=snay4uiPzdNKoUj8uDMupInxEoFmLrh7EgQ1xM1KF+ZwDk++yID21DyPwhm6WawCF Hukc5U8qJHT57NoFnEIWTX38a/KWVnSXuh2Xr/2+Fry9NPfxsyMH3szlCGo72Nx3U9 t8vskqpAM0809QTFEExY8ZU/hgX2clP8KVn6xMNC3kwOgiIScGde4gbqgGD5Pel80g SICtTjnjBCv6UXWjLM0/JvrcyUCQPkLHlQfVDecXBsQ8KaKsBS/VL7z3vjylnomqYe 511Aijo4a1XAhTGlEjqhsv/5UOXIjtdHyKCDCtXb4yadEmkiZA9ws2PbGaOfxLT9wE smOewfX04lHAQ== Received: from localhost.localdomain (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 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 DCAD737809D1; Fri, 26 Apr 2024 09:14:14 +0000 (UTC) From: Muhammad Usama Anjum To: Shuah Khan , Muhammad Usama Anjum Cc: kernel@collabora.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests: tpm2: conform test to TAP output Date: Fri, 26 Apr 2024 14:14:31 +0500 Message-Id: <20240426091435.2742024-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 -- 2.39.2