<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Alexey,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Aug 7, 2021 at 12:48 AM Alexey Kodanev <<a href="mailto:aleksei.kodanev@bell-sw.com">aleksei.kodanev@bell-sw.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The new wrappers allow to test libc and syscall variants. This is needed<br>
because libc implementation can differ from calling syscall directly.<br>
For example, musl libc implementation returns ENOSYS for some sched_*()<br>
functions due to commit 1e21e78bf7a5 ("add support for thread scheduling<br>
(POSIX TPS option)").<br>
<br>
Signed-off-by: Alexey Kodanev <<a href="mailto:aleksei.kodanev@bell-sw.com" target="_blank">aleksei.kodanev@bell-sw.com</a>><br>
---<br>
include/tst_sched.h | 70 +++++++++++++++++++++++++++++++++++++++++++++<br>
1 file changed, 70 insertions(+)<br>
create mode 100644 include/tst_sched.h<br>
<br>
diff --git a/include/tst_sched.h b/include/tst_sched.h<br>
new file mode 100644<br>
index 000000000..a5dc767b3<br>
--- /dev/null<br>
+++ b/include/tst_sched.h<br>
@@ -0,0 +1,70 @@<br>
+/* SPDX-License-Identifier: GPL-2.0-or-later */<br>
+/*<br>
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.<br>
+ */<br>
+<br>
+#ifndef TST_SCHED_H_<br>
+#define TST_SCHED_H_<br>
+<br>
+#include <sched.h><br>
+<br>
+#include "lapi/syscalls.h"<br>
+<br>
+struct sched_variants {<br>
+ char *desc;<br>
+<br>
+ int (*sched_setparam)(pid_t pid, const struct sched_param *param);<br>
+ int (*sched_getparam)(pid_t pid, struct sched_param *param);<br>
+ int (*sched_setscheduler)(pid_t pid, int policy, const struct sched_param *param);<br>
+ int (*sched_getscheduler)(pid_t pid);<br>
+};<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">The whole patchset looks tidy and correctly, but I'm thinking maybe</div><div class="gmail_default" style="font-size:small">we can define the varints[] unified here instead of stating them in each</div><div class="gmail_default" style="font-size:small">test case again and again?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I.e. </div><div class="gmail_default" style="font-size:small"><br></div>--- a/include/tst_sched.h<br>+++ b/include/tst_sched.h<br>@@ -10,15 +10,6 @@<br> <br> #include "lapi/syscalls.h"<br> <br>-struct sched_variants {<br>- char *desc;<br>-<br>- int (*sched_setparam)(pid_t pid, const struct sched_param *param);<br>- int (*sched_getparam)(pid_t pid, struct sched_param *param);<br>- int (*sched_setscheduler)(pid_t pid, int policy, const struct sched_param *param);<br>- int (*sched_getscheduler)(pid_t pid);<br>-};<br>-<br> #define _TST_LIBC_SCHED_SCALL(SCALL, ...)({ \<br> int tst_ret = SCALL(__VA_ARGS__); \<br> if (tst_ret == -1 && errno == ENOSYS) { \<br>@@ -67,4 +58,24 @@ static inline int libc_sched_getscheduler(pid_t pid)<br> return _TST_LIBC_SCHED_SCALL(sched_getscheduler, pid);<br> }<br> <br>+struct sched_variants {<br>+ char *desc;<br>+<br>+ int (*sched_setparam)(pid_t pid, const struct sched_param *param);<br>+ int (*sched_getparam)(pid_t pid, struct sched_param *param);<br>+ int (*sched_setscheduler)(pid_t pid, int policy, const struct sched_param *param);<br>+ int (*sched_getscheduler)(pid_t pid);<br>+} variants[] = {<br>+ { .sched_setparam = libc_sched_setparam,<br>+ .sched_getparam = libc_sched_getparam,<br>+ .sched_setscheduler = libc_sched_setscheduler,<br>+ .desc = "libc"<br>+ },<br>+ { .sched_setparam = sys_sched_setparam,<br>+ .sched_getparam = sys_sched_getparam,<br>+ .sched_setscheduler = sys_sched_setscheduler,<br>+ .desc = "syscall"<br>+ },<br>+};<br>+<br> #endif /* TST_SCHED_H_ */<br><div class="gmail_default" style="font-size:small"></div></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>