All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] sched_{set, get}attr: Call the syscalls via tst_syscall()
@ 2026-10-04  1:54 Wake Liu via ltp
  2026-10-04  4:30 ` [LTP] " linuxtestproject.agent
  2026-10-05 12:08 ` [LTP] [PATCH] " Andrea Cervesato via ltp
  0 siblings, 2 replies; 4+ messages in thread
From: Wake Liu via ltp @ 2026-10-04  1:54 UTC (permalink / raw)
  To: ltp; +Cc: Wake Liu

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] sched_{set, get}attr: Call the syscalls via tst_syscall()
  2026-10-04  1:54 [LTP] [PATCH] sched_{set, get}attr: Call the syscalls via tst_syscall() Wake Liu via ltp
@ 2026-10-04  4:30 ` linuxtestproject.agent
  2026-10-05 12:08 ` [LTP] [PATCH] " Andrea Cervesato via ltp
  1 sibling, 0 replies; 4+ messages in thread
From: linuxtestproject.agent @ 2026-10-04  4:30 UTC (permalink / raw)
  To: Wake Liu; +Cc: ltp

Hi Wake,

On October 4, 2026, Wake Liu wrote:
> sched_{set, get}attr: Call the syscalls via tst_syscall()

Verdict - Reviewed

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] sched_{set, get}attr: Call the syscalls via tst_syscall()
  2026-10-04  1:54 [LTP] [PATCH] sched_{set, get}attr: Call the syscalls via tst_syscall() Wake Liu via ltp
  2026-10-04  4:30 ` [LTP] " linuxtestproject.agent
@ 2026-10-05 12:08 ` Andrea Cervesato via ltp
  2026-10-12 12:24   ` Andrea Cervesato via ltp
  1 sibling, 1 reply; 4+ messages in thread
From: Andrea Cervesato via ltp @ 2026-10-05 12:08 UTC (permalink / raw)
  To: Wake Liu; +Cc: ltp

Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] sched_{set, get}attr: Call the syscalls via tst_syscall()
  2026-10-05 12:08 ` [LTP] [PATCH] " Andrea Cervesato via ltp
@ 2026-10-12 12:24   ` Andrea Cervesato via ltp
  0 siblings, 0 replies; 4+ messages in thread
From: Andrea Cervesato via ltp @ 2026-10-12 12:24 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: Wake Liu, ltp

Hi Wake,

> Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>

I think I reply to the wrong email. Forget about this RB.

The `sched_setattr` definition falls back to `syscall(__NR_sched_setattr, ..)`
if it's not present inside the system and if you see that error, it's probably
because you are linking to the wrong library locally.

Please confirm it so this patch will be rejected.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-12 12:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-04  1:54 [LTP] [PATCH] sched_{set, get}attr: Call the syscalls via tst_syscall() Wake Liu via ltp
2026-10-04  4:30 ` [LTP] " linuxtestproject.agent
2026-10-05 12:08 ` [LTP] [PATCH] " Andrea Cervesato via ltp
2026-10-12 12:24   ` Andrea Cervesato via ltp

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.