[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210806001704.667889-8-jarkko@kernel.org>
Date: Fri, 6 Aug 2021 03:17:03 +0300
From: Jarkko Sakkinen <jarkko@...nel.org>
To: Shuah Khan <shuah@...nel.org>
Cc: linux-kselftest@...r.kernel.org, linux-sgx@...r.kernel.org,
Reinette Chatre <reinette.chatre@...el.com>,
Borislav Petkov <bp@...en8.de>,
Jarkko Sakkinen <jarkko@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH v3 7/8] selftests/sgx: Move setup_test_encl() to each TEST_F()
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 <jarkko@...nel.org>
---
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;
--
2.32.0
Powered by blists - more mailing lists