From patchwork Fri Aug 6 00:17:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 12422407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 375A7C43214 for ; Fri, 6 Aug 2021 00:17:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E41961166 for ; Fri, 6 Aug 2021 00:17:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238685AbhHFARv (ORCPT ); Thu, 5 Aug 2021 20:17:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:41996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241119AbhHFARo (ORCPT ); Thu, 5 Aug 2021 20:17:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 64C6461163; Fri, 6 Aug 2021 00:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628209048; bh=mtizAPA5mmHzhy5HVIFitBew0+Sy6VfrTxywUHjPXjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NbcmNxYKkvXRt8FurRHNWk3g4fjZ8t3fuJ712LnFhe/Nw6laENFUy46yy3Cj5c3du SRW2/3QXxFnLki83KrtMB8udr/6Bk5VMKQLQwSxHKqGpIM3HYfluCF6czNsOkUIf7i gLS4H3Y5Z9CTmU3bDhIbrOKLemZRCiPXH2Uxp7UVc0KA/55ckF7l8OTAHV4k3oieaa jJrWgLQKlpZxH9zH3rcjnLce0ZO2xQ0vdw3Qy/Qcrf+Fk8BcpF36uoqWv377pdMH/s lFWyqMhs11OfNquieV5IeW+7NMvX60wuiVmBYtq6TnzRCPqILMZ0JGo7ipobi5D9H+ E1m/AenKNaF7g== From: Jarkko Sakkinen To: Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-sgx@vger.kernel.org, Reinette Chatre , Borislav Petkov , Jarkko Sakkinen , Dave Hansen , linux-kernel@vger.kernel.org Subject: [PATCH v3 7/8] selftests/sgx: Move setup_test_encl() to each TEST_F() Date: Fri, 6 Aug 2021 03:17:03 +0300 Message-Id: <20210806001704.667889-8-jarkko@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210806001704.667889-1-jarkko@kernel.org> References: <20210806001704.667889-1-jarkko@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org Create the test enclave inside each TEST_F(), instead of FIXTURE_SETUP(), so that the heap size can be defined per test. Signed-off-by: Jarkko Sakkinen --- tools/testing/selftests/sgx/main.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c index 4fbe9856f775..f219768b4e9a 100644 --- a/tools/testing/selftests/sgx/main.c +++ b/tools/testing/selftests/sgx/main.c @@ -191,11 +191,6 @@ static bool setup_test_encl(unsigned long heap_size, struct encl *encl, FIXTURE_SETUP(enclave) { - if (!setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata)) - ASSERT_TRUE(false); - - memset(&self->run, 0, sizeof(self->run)); - self->run.tcs = self->encl.encl_base; } FIXTURE_TEARDOWN(enclave) @@ -227,6 +222,12 @@ TEST_F(enclave, unclobbered_vdso) { struct encl_op op; + if (!setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata)) + ASSERT_TRUE(false); + + memset(&self->run, 0, sizeof(self->run)); + self->run.tcs = self->encl.encl_base; + op.type = ENCL_OP_PUT; op.buffer = MAGIC; @@ -249,6 +250,12 @@ TEST_F(enclave, clobbered_vdso) { struct encl_op op; + if (!setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata)) + ASSERT_TRUE(false); + + memset(&self->run, 0, sizeof(self->run)); + self->run.tcs = self->encl.encl_base; + op.type = ENCL_OP_PUT; op.buffer = MAGIC; @@ -279,6 +286,12 @@ TEST_F(enclave, clobbered_vdso_and_user_function) { struct encl_op op; + if (!setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata)) + ASSERT_TRUE(false); + + memset(&self->run, 0, sizeof(self->run)); + self->run.tcs = self->encl.encl_base; + self->run.user_handler = (__u64)test_handler; self->run.user_data = 0xdeadbeef;