From: Wake Liu via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: Wake Liu <wakel@google.com>
Subject: [LTP] [PATCH] sched_{set, get}attr: Call the syscalls via tst_syscall()
Date: Sun, 4 Oct 2026 01:54:24 +0000 [thread overview]
Message-ID: <20261004015424.3821821-1-wakel@google.com> (raw)
From: Wake Liu <wakel@google.com>
The sched_setattr01, sched_setattr02, sched_getattr01 and
sched_getattr02 tests call sched_setattr() and sched_getattr().
Depending on the libc, these names resolve either to the lapi fallback
wrappers or to the libc functions.
On Bionic, sched_setattr() and sched_getattr() were added in API level
37. When LTP is built against such headers, the test binaries link
against the libc symbols. They then fail to start on devices with an
older libc:
CANNOT LINK EXECUTABLE "sched_setattr01": cannot locate symbol
"sched_setattr"
These are syscall tests, so call the syscalls directly through
tst_syscall(), as SAFE_SCHED_SETATTR() already does. This makes the
tests independent of libc support, and tst_syscall() reports TCONF if
the kernel lacks the syscalls. As a bonus, the negative tests no longer
pass NULL to the libc wrappers, whose attr parameter is declared
nonnull by glibc and Bionic.
Signed-off-by: Wake Liu <wakel@google.com>
---
testcases/kernel/syscalls/sched_getattr/sched_getattr01.c | 3 ++-
testcases/kernel/syscalls/sched_getattr/sched_getattr02.c | 7 ++++---
testcases/kernel/syscalls/sched_setattr/sched_setattr01.c | 5 +++--
testcases/kernel/syscalls/sched_setattr/sched_setattr02.c | 3 ++-
4 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c b/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c
index bd05164ca..2f3bd4a9c 100644
--- a/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c
+++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c
@@ -51,7 +51,8 @@ static void run(void)
memset((void *)read_attr, 0, sizeof(*read_attr));
- TST_EXP_PASS(sched_getattr(0, read_attr, sizeof(*read_attr), 0),
+ TST_EXP_PASS(tst_syscall(__NR_sched_getattr, 0, read_attr,
+ sizeof(*read_attr), 0),
"sched_getattr() with valid parameters");
if (!TST_PASS)
return;
diff --git a/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
index e2c0bf43b..a70b8ac5c 100644
--- a/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
+++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
@@ -40,9 +40,10 @@ static void verify_sched_getattr(unsigned int n)
{
struct test_case *tc = &tcase[n];
- TST_EXP_FAIL(sched_getattr(*(tc->pid), tc->attr, tc->size, tc->flags),
- tc->exp_errno, "sched_getattr(%d, ..., %d, %d)", *tc->pid,
- tc->size, tc->flags);
+ TST_EXP_FAIL(tst_syscall(__NR_sched_getattr, *tc->pid, tc->attr,
+ tc->size, tc->flags),
+ tc->exp_errno, "sched_getattr(%d, ..., %d, %d)",
+ *tc->pid, tc->size, tc->flags);
}
static void setup(void)
diff --git a/testcases/kernel/syscalls/sched_setattr/sched_setattr01.c b/testcases/kernel/syscalls/sched_setattr/sched_setattr01.c
index 93e532774..b1fe93735 100644
--- a/testcases/kernel/syscalls/sched_setattr/sched_setattr01.c
+++ b/testcases/kernel/syscalls/sched_setattr/sched_setattr01.c
@@ -51,12 +51,13 @@ static void run(void)
{
struct sched_attr read_attr = { .size = sizeof(read_attr) };
- TST_EXP_PASS(sched_setattr(0, &attr, 0),
+ TST_EXP_PASS(tst_syscall(__NR_sched_setattr, 0, &attr, 0),
"sched_setattr() with valid parameters");
if (!TST_PASS)
return;
- if (sched_getattr(0, &read_attr, sizeof(read_attr), 0) == -1) {
+ if (tst_syscall(__NR_sched_getattr, 0, &read_attr,
+ sizeof(read_attr), 0) == -1) {
tst_res(TFAIL | TERRNO, "sched_getattr() failed");
return;
}
diff --git a/testcases/kernel/syscalls/sched_setattr/sched_setattr02.c b/testcases/kernel/syscalls/sched_setattr/sched_setattr02.c
index 9f1ccfcd0..462f182a5 100644
--- a/testcases/kernel/syscalls/sched_setattr/sched_setattr02.c
+++ b/testcases/kernel/syscalls/sched_setattr/sched_setattr02.c
@@ -123,7 +123,8 @@ static void verify_sched_setattr(unsigned int n)
*/
attr_small.size = SCHED_ATTR_SIZE_VER0 - 1;
- TST_EXP_FAIL(sched_setattr(pid, target_attr, tc->flags),
+ TST_EXP_FAIL(tst_syscall(__NR_sched_setattr, pid, target_attr,
+ tc->flags),
tc->exp_errno, "%s", tc->desc);
}
--
2.56.0.rc1.315.gc6ed9934b7-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2026-10-04 1:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 1:54 Wake Liu via ltp [this message]
2026-10-04 4:30 ` [LTP] sched_{set, get}attr: Call the syscalls via tst_syscall() linuxtestproject.agent
2026-10-05 12:08 ` [LTP] [PATCH] " Andrea Cervesato via ltp
2026-10-12 12:24 ` Andrea Cervesato via ltp
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=20261004015424.3821821-1-wakel@google.com \
--to=ltp@lists.linux.it \
--cc=wakel@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.