From: Wake Liu <wakel@google.com>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org
Cc: "Peter Zijlstra" <peterz@infradead.org>,
"Darren Hart" <dvhart@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"André Almeida" <andrealmeid@igalia.com>,
"Carlos Llamas" <cmllamas@google.com>,
linux-kernel@vger.kernel.org, wakel@google.com
Subject: [PATCH v2 2/2] selftests/futex: Correct validation logic in waitv
Date: Tue, 26 May 2026 01:06:35 +0000 [thread overview]
Message-ID: <20260526010635.23980-3-wakel@google.com> (raw)
In-Reply-To: <20260526010635.23980-1-wakel@google.com>
In futex_waitv negative tests (invalid_flag, unaligned_address, etc.),
test results were previously evaluated as:
if (res == EINVAL)
Since sys_futex_waitv returns -1 on error and sets errno, direct positive
comparisons against res are always false, causing tests to silently pass
regardless of real errors.
Correct these validations to assert EXPECT_EQ(res, -1) and compare errno
directly against expected constants.
Signed-off-by: Wake Liu <wakel@google.com>
---
.../selftests/futex/functional/futex_waitv.c | 45 +++++++++----------
1 file changed, 20 insertions(+), 25 deletions(-)
diff --git a/tools/testing/selftests/futex/functional/futex_waitv.c b/tools/testing/selftests/futex/functional/futex_waitv.c
index 3053f69cf0c3..6a6fc49708a2 100644
--- a/tools/testing/selftests/futex/functional/futex_waitv.c
+++ b/tools/testing/selftests/futex/functional/futex_waitv.c
@@ -132,11 +132,10 @@ TEST(invalid_flag)
to.tv_sec++;
res = futex_waitv(waitv, NR_FUTEXES, 0, &to, CLOCK_MONOTONIC);
- if (res == EINVAL) {
- EXPECT_TRUE(0) TH_LOG("futex_waitv private returned: %d %s",
- res ? errno : res,
- res ? strerror(errno) : "");
- }
+ EXPECT_EQ(res, -1) TH_LOG("futex_waitv returned unexpected result: %d", res);
+ if (res == -1)
+ EXPECT_EQ(errno, EINVAL)
+ TH_LOG("futex_waitv returned unexpected errno: %d", errno);
}
TEST(unaligned_address)
@@ -156,11 +155,10 @@ TEST(unaligned_address)
to.tv_sec++;
res = futex_waitv(waitv, NR_FUTEXES, 0, &to, CLOCK_MONOTONIC);
- if (res == EINVAL) {
- EXPECT_TRUE(0) TH_LOG("futex_wake private returned: %d %s",
- res ? errno : res,
- res ? strerror(errno) : "");
- }
+ EXPECT_EQ(res, -1) TH_LOG("futex_waitv returned unexpected result: %d", res);
+ if (res == -1)
+ EXPECT_EQ(errno, EINVAL)
+ TH_LOG("futex_waitv returned unexpected errno: %d", errno);
}
TEST(null_address)
@@ -179,11 +177,10 @@ TEST(null_address)
to.tv_sec++;
res = futex_waitv(waitv, NR_FUTEXES, 0, &to, CLOCK_MONOTONIC);
- if (res == EINVAL) {
- EXPECT_TRUE(0) TH_LOG("futex_waitv private returned: %d %s",
- res ? errno : res,
- res ? strerror(errno) : "");
- }
+ EXPECT_EQ(res, -1) TH_LOG("futex_waitv returned unexpected result: %d", res);
+ if (res == -1)
+ EXPECT_EQ(errno, EINVAL)
+ TH_LOG("futex_waitv returned unexpected errno: %d", errno);
/* Testing a NULL address for *waiters */
ASSERT_EQ(clock_gettime(CLOCK_MONOTONIC, &to), 0) TH_LOG("gettime64 failed");
@@ -191,11 +188,10 @@ TEST(null_address)
to.tv_sec++;
res = futex_waitv(NULL, NR_FUTEXES, 0, &to, CLOCK_MONOTONIC);
- if (res == EINVAL) {
- EXPECT_TRUE(0) TH_LOG("futex_waitv private returned: %d %s",
- res ? errno : res,
- res ? strerror(errno) : "");
- }
+ EXPECT_EQ(res, -1) TH_LOG("futex_waitv returned unexpected result: %d", res);
+ if (res == -1)
+ EXPECT_EQ(errno, EINVAL)
+ TH_LOG("futex_waitv returned unexpected errno: %d", errno);
}
TEST(invalid_clockid)
@@ -212,11 +208,10 @@ TEST(invalid_clockid)
to.tv_sec++;
res = futex_waitv(NULL, NR_FUTEXES, 0, &to, CLOCK_TAI);
- if (res == EINVAL) {
- EXPECT_TRUE(0) TH_LOG("futex_waitv private returned: %d %s",
- res ? errno : res,
- res ? strerror(errno) : "");
- }
+ EXPECT_EQ(res, -1) TH_LOG("futex_waitv returned unexpected result: %d", res);
+ if (res == -1)
+ EXPECT_EQ(errno, EINVAL)
+ TH_LOG("futex_waitv returned unexpected errno: %d", errno);
}
TEST_HARNESS_MAIN
--
2.54.0.746.g67dd491aae-goog
prev parent reply other threads:[~2026-05-26 1:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 7:57 [PATCH 0/2] selftests/futex: Migrate functional tests to harness and fix validations Wake Liu
2026-05-25 7:57 ` [PATCH 1/2] selftests/futex: Migrate functional tests to harness Wake Liu
2026-05-25 18:37 ` André Almeida
2026-05-25 7:57 ` [PATCH 2/2] selftests/futex: Correct validation logic in waitv Wake Liu
2026-05-26 1:06 ` [PATCH v2 0/2] selftests/futex: Migrate functional tests to harness and fix validations Wake Liu
2026-05-26 1:06 ` [PATCH v2 1/2] selftests/futex: Migrate functional tests to harness Wake Liu
2026-05-26 1:06 ` Wake Liu [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=20260526010635.23980-3-wakel@google.com \
--to=wakel@google.com \
--cc=andrealmeid@igalia.com \
--cc=cmllamas@google.com \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=shuah@kernel.org \
--cc=tglx@kernel.org \
/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