Linux Test Project
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v5 3/3] Add futex_waitv testing suite
Date: Thu, 10 Feb 2022 15:18:02 +0100	[thread overview]
Message-ID: <YgUemsGtWLfK7isG@rei> (raw)
In-Reply-To: <20220209091756.17245-2-andrea.cervesato@suse.de>

Hi!
I've fixed a few things in this patch and pushed the whole patchset,
thanks.

Full diff:

diff --git a/testcases/kernel/syscalls/futex/futex_waitv02.c b/testcases/kernel/syscalls/futex/futex_waitv02.c
index 2897f6c78..0a0e2b620 100644
--- a/testcases/kernel/syscalls/futex/futex_waitv02.c
+++ b/testcases/kernel/syscalls/futex/futex_waitv02.c
@@ -37,10 +37,10 @@ static void setup(void)
 	if (tst_parse_int(str_numfutex, &numfutex, 1, FUTEX_WAITV_MAX))
 		tst_brk(TBROK, "Invalid number of futexes '%s'", str_numfutex);
 
-	futexes = SAFE_MALLOC(sizeof(uint32_t) * numfutex);
+	futexes = tst_alloc(sizeof(uint32_t) * numfutex);
 	memset(futexes, FUTEX_INITIALIZER, sizeof(uint32_t) * numfutex);
 
-	waitv = SAFE_MALLOC(sizeof(struct futex_waitv) * numfutex);
+	waitv = tst_alloc(sizeof(struct futex_waitv) * numfutex);
 	memset(waitv, 0, sizeof(struct futex_waitv) * numfutex);
 
 	for (i = 0; i < numfutex; i++) {
@@ -60,8 +60,8 @@ static void *threaded(void *arg)
 	TEST(futex_wake(tv.fntype, (void *)(uintptr_t)waitv[numfutex - 1].uaddr,
 			1, FUTEX_PRIVATE_FLAG));
 	if (TST_RET < 0) {
-		tst_brk(TBROK, "futex_wake private returned: %ld %s", TST_RET,
-			tst_strerrno(TST_ERR));
+		tst_brk(TBROK | TTERRNO,
+			"futex_wake private returned: %ld", TST_RET);
 	}
 
 	return NULL;
@@ -70,7 +70,7 @@ static void *threaded(void *arg)
 static void run(void)
 {
 	struct timespec to;
-	int ret, tid;
+	int tid;
 	pthread_t t;
 
 	tid = tst_syscall(__NR_gettid);
@@ -81,13 +81,13 @@ static void run(void)
 	SAFE_CLOCK_GETTIME(CLOCK_MONOTONIC, &to);
 	to.tv_sec++;
 
-	ret = futex_waitv(waitv, numfutex, 0, &to, CLOCK_MONOTONIC);
-	if (ret < 0)
-		tst_brk(TBROK, "futex_waitv returned: %d %s", ret,
-			tst_strerrno(-ret));
-	else if (ret != numfutex - 1)
-		tst_res(TFAIL, "futex_waitv returned: %d, expecting %d", ret,
-			numfutex - 1);
+	TEST(futex_waitv(waitv, numfutex, 0, &to, CLOCK_MONOTONIC));
+	if (TST_RET < 0) {
+		tst_brk(TBROK | TTERRNO, "futex_waitv returned: %ld", TST_RET);
+	} else if (TST_RET != numfutex - 1) {
+		tst_res(TFAIL, "futex_waitv returned: %ld, expecting %d",
+			TST_RET,  numfutex - 1);
+	}
 
 	SAFE_PTHREAD_JOIN(t, NULL);
 	tst_res(TPASS, "futex_waitv returned correctly");
diff --git a/testcases/kernel/syscalls/futex/futex_waitv03.c b/testcases/kernel/syscalls/futex/futex_waitv03.c
index 773cc5af3..d8e39c76a 100644
--- a/testcases/kernel/syscalls/futex/futex_waitv03.c
+++ b/testcases/kernel/syscalls/futex/futex_waitv03.c
@@ -39,7 +39,7 @@ static void setup(void)
 	if (tst_parse_int(str_numfutex, &numfutex, 1, FUTEX_WAITV_MAX))
 		tst_brk(TBROK, "Invalid number of futexes '%s'", str_numfutex);
 
-	waitv = SAFE_MALLOC(sizeof(struct futex_waitv) * numfutex);
+	waitv = tst_alloc(sizeof(struct futex_waitv) * numfutex);
 	memset(waitv, 0, sizeof(struct futex_waitv) * numfutex);
 
 	for (i = 0; i < numfutex; i++) {
@@ -72,8 +72,8 @@ static void *threaded(void *arg)
 	TEST(futex_wake(tv.fntype, (void *)(uintptr_t)waitv[numfutex - 1].uaddr,
 			1, 0));
 	if (TST_RET < 0) {
-		tst_brk(TBROK, "futex_wake private returned: %ld %s", TST_RET,
-			tst_strerrno(TST_ERR));
+		tst_brk(TBROK | TTERRNO,
+			"futex_wake private returned: %ld", TST_RET);
 	}
 
 	return NULL;
@@ -94,12 +94,12 @@ static void run(void)
 	to.tv_sec++;
 
 	TEST(futex_waitv(waitv, numfutex, 0, &to, CLOCK_MONOTONIC));
-	if (TST_RET < 0)
-		tst_brk(TBROK, "futex_waitv returned: %ld %s", TST_RET,
-			tst_strerrno(TST_ERR));
-	else if (TST_RET != numfutex - 1)
+	if (TST_RET < 0) {
+		tst_brk(TBROK | TTERRNO, "futex_waitv returned: %ld", TST_RET);
+	} else if (TST_RET != numfutex - 1) {
 		tst_res(TFAIL, "futex_waitv returned: %ld, expecting %d",
 			TST_RET, numfutex - 1);
+	}
 
 	SAFE_PTHREAD_JOIN(t, NULL);
 	tst_res(TPASS, "futex_waitv returned correctly");

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

      reply	other threads:[~2022-02-10 14:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09  9:17 [LTP] [PATCH v5 1/3] Add TST_THREAD_STATE_WAIT macro Andrea Cervesato
2022-02-09  9:17 ` [LTP] [PATCH v5 3/3] Add futex_waitv testing suite Andrea Cervesato
2022-02-10 14:18   ` Cyril Hrubis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YgUemsGtWLfK7isG@rei \
    --to=chrubis@suse.cz \
    --cc=andrea.cervesato@suse.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox