[LTP] [PATCH] futex_waitv01: Correct assign and add cleanup

Zhao Gongyi zhaogongyi@huawei.com
Wed Apr 13 13:24:05 CEST 2022


1.Correct assign of waitv->uaddr
2.Rename function name of test_invalid_nr_futex
3.Add cleanup

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
 testcases/kernel/syscalls/futex/futex_waitv01.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/futex/futex_waitv01.c b/testcases/kernel/syscalls/futex/futex_waitv01.c
index 8b7bd50d3..ddc4be01c 100644
--- a/testcases/kernel/syscalls/futex/futex_waitv01.c
+++ b/testcases/kernel/syscalls/futex/futex_waitv01.c
@@ -10,6 +10,7 @@
  */

 #include <time.h>
+#include <stdlib.h>
 #include "tst_test.h"
 #include "lapi/futex.h"
 #include "futex2test.h"
@@ -32,7 +33,7 @@ static void init_timeout(struct timespec *to)

 static void init_waitv(void)
 {
-	waitv->uaddr = (uintptr_t)&futex;
+	waitv->uaddr = (uintptr_t)futex;
 	waitv->flags = FUTEX_32 | FUTEX_PRIVATE_FLAG;
 	waitv->val = 0;
 }
@@ -98,7 +99,7 @@ static void test_invalid_clockid(void)
 		     "futex_waitv invalid clockid");
 }

-static void test_invalid_nr_futex(void)
+static void test_invalid_nr_futexes(void)
 {
 	struct timespec to;

@@ -112,6 +113,12 @@ static void test_invalid_nr_futex(void)
 		     "futex_waitv invalid nr_futexes");
 }

+static void cleanup(void)
+{
+	if (futex != NULL)
+		free(futex);
+}
+
 static void run(void)
 {
 	test_invalid_flags();
@@ -119,12 +126,13 @@ static void run(void)
 	test_null_address();
 	test_null_waiters();
 	test_invalid_clockid();
-	test_invalid_nr_futex();
+	test_invalid_nr_futexes();
 }

 static struct tst_test test = {
 	.test_all = run,
 	.setup = setup,
+	.cleanup = cleanup,
 	.min_kver = "5.16",
 	.bufs =
 		(struct tst_buffers[]){
--
2.17.1



More information about the ltp mailing list