All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
@ 2021-07-20 13:18 ` Cyril Hrubis
  2021-07-20 14:06   ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 01/16] lib/tst_sched: add ltp tst_sched_*() Alexey Kodanev
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 23+ messages in thread
From: Cyril Hrubis @ 2021-07-20 13:18 UTC (permalink / raw)
  To: ltp

Hi!
> The patch-set introduced new tst_sched_* wrappers to handle ENOSYS
> error that can be returned by libc (musl [1]). In that particular
> case the wrapper uses syscall directly to test the kernel anyway.

Can't we use the test_variants to test both the kernel and libc calls
instead?

> [1]: https://git.musl-libc.org/cgit/musl/commit/?id=1e21e78bf7a5
> 
> Alexey Kodanev (16):
>   lib/tst_sched: add ltp tst_sched_*()
>   syscalls/sched_getparam01: use tst_sched_*()
>   syscalls/sched_getparam03: use tst_sched_*()
>   syscalls/sched_setparam01: convert to new API
>   syscalls/sched_setparam02: convert to new API
>   syscalls/sched_setparam03: convert to new API
>   syscalls/sched_setparam04: convert to new API
>   syscalls/sched_setparam05: convert to new API
>   syscalls/sched_rr_get_interval01: use tst_sched_*()
>   syscalls/sched_rr_get_interval02: use tst_sched_*()
>   syscalls/sched_rr_get_interval03: use tst_sched_*()
>   syscalls/sched_setscheduler01: convert to new API
>   syscalls/sched_setscheduler02: convert to new API
>   syscalls/sched_setscheduler03: use tst_sched_*()
>   syscalls/sched_getscheduler01: convert to new API
>   syscalls/sched_getscheduler02: convert to new API
> 
>  include/tst_sched.h                           |  16 ++
>  lib/tst_sched.c                               |  36 +++
>  .../sched_getparam/sched_getparam01.c         |   6 +-
>  .../sched_getparam/sched_getparam03.c         |   4 +-
>  .../sched_getscheduler/sched_getscheduler01.c | 141 +++---------
>  .../sched_getscheduler/sched_getscheduler02.c | 104 ++-------
>  .../sched_rr_get_interval01.c                 |   4 +-
>  .../sched_rr_get_interval02.c                 |   4 +-
>  .../sched_rr_get_interval03.c                 |   4 +-
>  .../sched_setparam/sched_setparam01.c         | 135 ++---------
>  .../sched_setparam/sched_setparam02.c         | 195 +++-------------
>  .../sched_setparam/sched_setparam03.c         | 215 ++++--------------
>  .../sched_setparam/sched_setparam04.c         | 161 +++----------
>  .../sched_setparam/sched_setparam05.c         | 186 +++------------
>  .../sched_setscheduler/sched_setscheduler01.c | 171 ++++----------
>  .../sched_setscheduler/sched_setscheduler02.c | 154 +++----------
>  .../sched_setscheduler/sched_setscheduler03.c |  10 +-
>  17 files changed, 345 insertions(+), 1201 deletions(-)
>  create mode 100644 include/tst_sched.h
>  create mode 100644 lib/tst_sched.c
> 
> -- 
> 2.25.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno
@ 2021-07-20 13:33 Alexey Kodanev
  2021-07-20 13:18 ` Cyril Hrubis
                   ` (16 more replies)
  0 siblings, 17 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

The patch-set introduced new tst_sched_* wrappers to handle ENOSYS
error that can be returned by libc (musl [1]). In that particular
case the wrapper uses syscall directly to test the kernel anyway.

[1]: https://git.musl-libc.org/cgit/musl/commit/?id=1e21e78bf7a5

Alexey Kodanev (16):
  lib/tst_sched: add ltp tst_sched_*()
  syscalls/sched_getparam01: use tst_sched_*()
  syscalls/sched_getparam03: use tst_sched_*()
  syscalls/sched_setparam01: convert to new API
  syscalls/sched_setparam02: convert to new API
  syscalls/sched_setparam03: convert to new API
  syscalls/sched_setparam04: convert to new API
  syscalls/sched_setparam05: convert to new API
  syscalls/sched_rr_get_interval01: use tst_sched_*()
  syscalls/sched_rr_get_interval02: use tst_sched_*()
  syscalls/sched_rr_get_interval03: use tst_sched_*()
  syscalls/sched_setscheduler01: convert to new API
  syscalls/sched_setscheduler02: convert to new API
  syscalls/sched_setscheduler03: use tst_sched_*()
  syscalls/sched_getscheduler01: convert to new API
  syscalls/sched_getscheduler02: convert to new API

 include/tst_sched.h                           |  16 ++
 lib/tst_sched.c                               |  36 +++
 .../sched_getparam/sched_getparam01.c         |   6 +-
 .../sched_getparam/sched_getparam03.c         |   4 +-
 .../sched_getscheduler/sched_getscheduler01.c | 141 +++---------
 .../sched_getscheduler/sched_getscheduler02.c | 104 ++-------
 .../sched_rr_get_interval01.c                 |   4 +-
 .../sched_rr_get_interval02.c                 |   4 +-
 .../sched_rr_get_interval03.c                 |   4 +-
 .../sched_setparam/sched_setparam01.c         | 135 ++---------
 .../sched_setparam/sched_setparam02.c         | 195 +++-------------
 .../sched_setparam/sched_setparam03.c         | 215 ++++--------------
 .../sched_setparam/sched_setparam04.c         | 161 +++----------
 .../sched_setparam/sched_setparam05.c         | 186 +++------------
 .../sched_setscheduler/sched_setscheduler01.c | 171 ++++----------
 .../sched_setscheduler/sched_setscheduler02.c | 154 +++----------
 .../sched_setscheduler/sched_setscheduler03.c |  10 +-
 17 files changed, 345 insertions(+), 1201 deletions(-)
 create mode 100644 include/tst_sched.h
 create mode 100644 lib/tst_sched.c

-- 
2.25.1


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

* [LTP] [PATCH 01/16] lib/tst_sched: add ltp tst_sched_*()
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
  2021-07-20 13:18 ` Cyril Hrubis
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 02/16] syscalls/sched_getparam01: use tst_sched_*() Alexey Kodanev
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

The new tst_sched_*() invoke libc variant first, and if ENOSYS errno
has been returned, tries to invoke syscall directly.

musl implementation returns ENOSYS for some sched_*() functions due
to commit 1e21e78bf7a5 ("add support for thread scheduling (POSIX
TPS option)").

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 include/tst_sched.h | 16 ++++++++++++++++
 lib/tst_sched.c     | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 include/tst_sched.h
 create mode 100644 lib/tst_sched.c

diff --git a/include/tst_sched.h b/include/tst_sched.h
new file mode 100644
index 000000000..0e5d61344
--- /dev/null
+++ b/include/tst_sched.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
+ */
+
+#ifndef TST_SCHED_H_
+#define TST_SCHED_H_
+
+#include <sched.h>
+
+int tst_sched_setparam(pid_t pid, const struct sched_param *param);
+int tst_sched_getparam(pid_t pid, struct sched_param *param);
+int tst_sched_setscheduler(pid_t pid, int policy, const struct sched_param *param);
+int tst_sched_getscheduler(pid_t pid);
+
+#endif /* TST_SCHED_H_ */
diff --git a/lib/tst_sched.c b/lib/tst_sched.c
new file mode 100644
index 000000000..d53273d8e
--- /dev/null
+++ b/lib/tst_sched.c
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include "tst_sched.h"
+#include "lapi/syscalls.h"
+
+#define TST_SCHED_COMMON(SCALL, ...) do {			\
+	int ret = SCALL(__VA_ARGS__);				\
+	if (ret == -1 && errno == ENOSYS)			\
+		return syscall(__NR_##SCALL, __VA_ARGS__);	\
+	return ret;						\
+} while (0)
+
+int tst_sched_setparam(pid_t pid, const struct sched_param *param)
+{
+	TST_SCHED_COMMON(sched_setparam, pid, param);
+}
+
+int tst_sched_getparam(pid_t pid, struct sched_param *param)
+{
+	TST_SCHED_COMMON(sched_getparam, pid, param);
+}
+
+int tst_sched_setscheduler(pid_t pid, int policy, const struct sched_param *param)
+{
+	TST_SCHED_COMMON(sched_setscheduler, pid, policy, param);
+}
+
+int tst_sched_getscheduler(pid_t pid)
+{
+	TST_SCHED_COMMON(sched_getscheduler, pid);
+}
-- 
2.25.1


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

* [LTP] [PATCH 02/16] syscalls/sched_getparam01: use tst_sched_*()
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
  2021-07-20 13:18 ` Cyril Hrubis
  2021-07-20 13:33 ` [LTP] [PATCH 01/16] lib/tst_sched: add ltp tst_sched_*() Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 03/16] syscalls/sched_getparam03: " Alexey Kodanev
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 testcases/kernel/syscalls/sched_getparam/sched_getparam01.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_getparam/sched_getparam01.c b/testcases/kernel/syscalls/sched_getparam/sched_getparam01.c
index efb697707..c24d1c917 100644
--- a/testcases/kernel/syscalls/sched_getparam/sched_getparam01.c
+++ b/testcases/kernel/syscalls/sched_getparam/sched_getparam01.c
@@ -21,8 +21,8 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <sched.h>
 #include "tst_test.h"
+#include "tst_sched.h"
 
 static pid_t pids[2] = {0, 0};
 
@@ -35,8 +35,8 @@ static void verify_sched_getparam(unsigned int n)
 
 	child_pid = SAFE_FORK();
 	if (!child_pid) {
-		TST_EXP_PASS_SILENT(sched_getparam(pids[n], &param),
-				    "sched_getparam(%d)", pids[n]);
+		TST_EXP_PASS_SILENT(tst_sched_getparam(pids[n], &param),
+				   "sched_getparam(%d)", pids[n]);
 		if (!TST_PASS)
 			exit(0);
 
-- 
2.25.1


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

* [LTP] [PATCH 03/16] syscalls/sched_getparam03: use tst_sched_*()
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (2 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 02/16] syscalls/sched_getparam01: use tst_sched_*() Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 04/16] syscalls/sched_setparam01: convert to new API Alexey Kodanev
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 testcases/kernel/syscalls/sched_getparam/sched_getparam03.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_getparam/sched_getparam03.c b/testcases/kernel/syscalls/sched_getparam/sched_getparam03.c
index 19ecaf147..451bfdc50 100644
--- a/testcases/kernel/syscalls/sched_getparam/sched_getparam03.c
+++ b/testcases/kernel/syscalls/sched_getparam/sched_getparam03.c
@@ -17,8 +17,8 @@
  */
 
 #include <errno.h>
-#include <sched.h>
 #include "tst_test.h"
+#include "tst_sched.h"
 
 static struct sched_param param;
 static pid_t unused_pid;
@@ -43,7 +43,7 @@ static void verify_sched_getparam(unsigned int n)
 {
 	struct test_case_t *tc = &test_cases[n];
 
-	TST_EXP_FAIL(sched_getparam(*(tc->pid), tc->p), tc->exp_errno, "%s", tc->desc);
+	TST_EXP_FAIL(tst_sched_getparam(*(tc->pid), tc->p), tc->exp_errno, "%s", tc->desc);
 }
 
 static void setup(void)
-- 
2.25.1


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

* [LTP] [PATCH 04/16] syscalls/sched_setparam01: convert to new API
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (3 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 03/16] syscalls/sched_getparam03: " Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 05/16] syscalls/sched_setparam02: " Alexey Kodanev
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../sched_setparam/sched_setparam01.c         | 135 +++---------------
 1 file changed, 18 insertions(+), 117 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_setparam/sched_setparam01.c b/testcases/kernel/syscalls/sched_setparam/sched_setparam01.c
index a2272eb18..d677736a1 100644
--- a/testcases/kernel/syscalls/sched_setparam/sched_setparam01.c
+++ b/testcases/kernel/syscalls/sched_setparam/sched_setparam01.c
@@ -1,128 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
+ * AUTHOR: Saji Kumar.V.R <saji.kumar@wipro.com>
  */
-/**********************************************************
- *
- *    TEST IDENTIFIER	: sched_setparam01
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for sched_setparam(2)
- *
- *    TEST CASE TOTAL	: 1
- *
- *    AUTHOR		: Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- *    SIGNALS
- * 	Uses SIGUSR1 to pause before test if option set.
- * 	(See the parse_opts(3) man page).
- *
- *    DESCRIPTION
- *	This is a Phase I test for the sched_setparam(2) system call.
- *	It is intended to provide a limited exposure of the system call.
- *
- * 	Setup:
- * 	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- * 	Test:
- *	 Loop if the proper options are given.
- * 	  Execute system call
- *	  Check return code, if system call failed (return=-1)
- *		Log the errno and Issue a FAIL message.
- *	  Otherwise, Issue a PASS message.
- *
- * 	Cleanup:
- * 	  Print errno log and/or timing stats if options given
+
+/*\
+ * [Description]
  *
- * USAGE:  <for command-line>
- *  sched_setparam01 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
- *			where,  -c n : Run n copies concurrently.
- *				-e   : Turn on errno logging.
- *				-h   : Show help screen
- *				-f   : Turn off functional testing
- *				-i n : Execute test n times.
- *				-I x : Execute test for x seconds.
- *				-p   : Pause for SIGUSR1 before starting
- *				-P x : Pause for x seconds between iterations.
- *				-t   : Turn on syscall timing.
+ * Basic test for sched_setparam(2)
  *
- ****************************************************************/
-
-#include <errno.h>
-#include <sched.h>
-#include "test.h"
-
-static void setup();
-static void cleanup();
-
-char *TCID = "sched_setparam01";
-int TST_TOTAL = 1;
-
-static struct sched_param param;
-
-int main(int ac, char **av)
-{
-
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/*
-		 * Call sched_setparam(2) with pid=0 sothat it will
-		 * set the scheduling parameters for the calling process
-		 */
-		TEST(sched_setparam(0, &param));
-
-		if (TEST_RETURN == 0) {
-			tst_resm(TPASS, "sched_setparam() returned %ld",
-				 TEST_RETURN);
-		} else {
-			tst_resm(TFAIL | TTERRNO,
-				 "Test Failed, sched_setparam()" "returned %ld",
-				 TEST_RETURN);
-		}
-	}
+ * Call sched_setparam(2) with pid=0 so that it will
+ * set the scheduling parameters for the calling process
+ */
 
-	cleanup();
-	tst_exit();
-}
+#include "tst_test.h"
+#include "tst_sched.h"
 
-/* setup() - performs all ONE TIME setup for this test */
-void setup(void)
+static void run(void)
 {
+	struct sched_param p = { .sched_priority = 0 };
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	param.sched_priority = 0;
-
+	TST_EXP_PASS(tst_sched_setparam(0, &p));
 }
 
-/*
- *cleanup() -  performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- */
-void cleanup(void)
-{
-}
+static struct tst_test test = {
+	.test_all = run,
+};
-- 
2.25.1


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

* [LTP] [PATCH 05/16] syscalls/sched_setparam02: convert to new API
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (4 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 04/16] syscalls/sched_setparam01: convert to new API Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 06/16] syscalls/sched_setparam03: " Alexey Kodanev
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../sched_setparam/sched_setparam02.c         | 195 ++++--------------
 1 file changed, 35 insertions(+), 160 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_setparam/sched_setparam02.c b/testcases/kernel/syscalls/sched_setparam/sched_setparam02.c
index 132cc9d6c..de7ec208e 100644
--- a/testcases/kernel/syscalls/sched_setparam/sched_setparam02.c
+++ b/testcases/kernel/syscalls/sched_setparam/sched_setparam02.c
@@ -1,184 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * AUTHOR: Saji Kumar.V.R <saji.kumar@wipro.com>
  */
-/**********************************************************
- *
- *    TEST IDENTIFIER	: sched_setparam02
- *
- *    EXECUTED BY	: root / superuser
- *
- *    TEST TITLE	: Checks functionality for sched_setparam(2)
- *
- *    TEST CASE TOTAL	: 1
- *
- *    AUTHOR		: Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- *    SIGNALS
- * 	Uses SIGUSR1 to pause before test if option set.
- * 	(See the parse_opts(3) man page).
- *
- *    DESCRIPTION
- *	This test changes the scheduling priority for current process
- *	and verifies it by calling sched_getparam().
- *
- * 	Setup:
- * 	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *	  Change scheduling policy to SCHED_FIFO
- *
- * 	Test:
- *	 Loop if the proper options are given.
- * 	  Execute system call
- *	  If scheduling priority is set properly,
- *		TEST passed
- *	  else
- *		TEST failed
- *
- * 	Cleanup:
- * 	  Print errno log and/or timing stats if options given
+
+/*\
+ * [Description]
  *
- * USAGE:  <for command-line>
- *  sched_setparam02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
- *			where,  -c n : Run n copies concurrently.
- *				-e   : Turn on errno logging.
- *				-h   : Show help screen
- *				-f   : Turn off functional testing
- *				-i n : Execute test n times.
- *				-I x : Execute test for x seconds.
- *				-p   : Pause for SIGUSR1 before starting
- *				-P x : Pause for x seconds between iterations.
- *				-t   : Turn on syscall timing.
+ * Checks functionality for sched_setparam(2)
  *
- ****************************************************************/
+ * This test changes the scheduling priority for current process
+ * and verifies it by calling sched_getparam().
+ */
 
-#include <errno.h>
-#include <sched.h>
-#include "test.h"
+#include "tst_test.h"
+#include "tst_sched.h"
 
 #define FIFO_OR_RR_PRIO 5
 #define OTHER_PRIO 0
 
-static void setup();
-static void cleanup();
-static int verify_priority(int);
-
-char *TCID = "sched_setparam02";
-
-static struct sched_param param;
-static struct sched_param param1 = { 1 };
-
 static struct test_cases_t {
 	char *desc;
 	int policy;
 	int priority;
-} testcases[] = {
+	int param;
+} tcases[] = {
 	{
-	"Test with policy SCHED_FIFO", SCHED_FIFO, FIFO_OR_RR_PRIO}, {
-	"Test with policy SCHED_RR", SCHED_RR, FIFO_OR_RR_PRIO}, {
-	"Test with SCHED_OTHER", SCHED_OTHER, OTHER_PRIO}
+	"Test with policy SCHED_FIFO", SCHED_FIFO, FIFO_OR_RR_PRIO, 1}, {
+	"Test with policy SCHED_RR", SCHED_RR, FIFO_OR_RR_PRIO, 1}, {
+	"Test with SCHED_OTHER", SCHED_OTHER, OTHER_PRIO, 0}
 };
 
-int TST_TOTAL = sizeof(testcases) / sizeof(testcases[0]);
-
-int main(int ac, char **av)
-{
-
-	int lc, i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; ++i) {
-
-			if (i == 2) {
-				param1.sched_priority = 0;
-			} else {
-				param1.sched_priority = 1;
-			}
-			if ((sched_setscheduler(0, testcases[i].policy,
-						&param1)) == -1) {
-				tst_brkm(TBROK, cleanup, "sched_setscheduler()"
-					 "  failed");
-			}
-			param.sched_priority = testcases[i].priority;
-			/*
-			 * Call sched_setparam(2) with pid=0 sothat it will
-			 * set the scheduling parameters for the calling process
-			 */
-			TEST(sched_setparam(0, &param));
-
-			if ((TEST_RETURN == 0) && (verify_priority(i))) {
-				tst_resm(TPASS, "%s Passed", testcases[i].desc);
-			} else {
-				tst_resm(TFAIL | TTERRNO,
-					 "%s Failed. sched_setparam()"
-					 " returned %ld", testcases[i].desc,
-					 TEST_RETURN);
-			}
-		}
-	}
-
-	/* cleanup and exit */
-	cleanup();
-
-	tst_exit();
-
-}
-
-/* setup() - performs all ONE TIME setup for this test */
-void setup(void)
+static void run(unsigned int n)
 {
-	tst_require_root();
+	struct test_cases_t *tc = &tcases[n];
+	struct sched_param p = { .sched_priority = tc->param };
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	TST_EXP_PASS_SILENT(tst_sched_setscheduler(0, tc->policy, &p));
 
-	TEST_PAUSE;
+	p.sched_priority = tc->priority;
+	TST_EXP_PASS_SILENT(tst_sched_setparam(0, &p));
 
-}
+	p.sched_priority = -1;
+	TST_EXP_PASS_SILENT(tst_sched_getparam(0, &p));
 
-/*
- *cleanup() -  performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- */
-void cleanup(void)
-{
+	if (p.sched_priority == tc->priority)
+		tst_res(TPASS, "got expected priority %d", p.sched_priority);
+	else
+		tst_res(TFAIL, "unexpected priority value %d, expected %d",
+			p.sched_priority, tc->priority);
 }
 
-/*
- * verify_priority() -  This function checks whether the priority is
- *			set correctly
- */
-int verify_priority(int i)
-{
-	struct sched_param p;
-
-	if ((sched_getparam(0, &p)) == 0) {
-		if (p.sched_priority == testcases[i].priority) {
-			return 1;
-		} else {
-			tst_resm(TWARN, "sched_getparam() returned priority"
-				 " value as %d", p.sched_priority);
-			return 0;
-		}
-	}
-
-	tst_resm(TWARN, "sched_getparam() failed");
-	return 0;
-}
+static struct tst_test test = {
+	.needs_root = 1,
+	.test = run,
+	.tcnt = ARRAY_SIZE(tcases),
+};
-- 
2.25.1


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

* [LTP] [PATCH 06/16] syscalls/sched_setparam03: convert to new API
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (5 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 05/16] syscalls/sched_setparam02: " Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 07/16] syscalls/sched_setparam04: " Alexey Kodanev
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../sched_setparam/sched_setparam03.c         | 215 ++++--------------
 1 file changed, 40 insertions(+), 175 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_setparam/sched_setparam03.c b/testcases/kernel/syscalls/sched_setparam/sched_setparam03.c
index 252364e2e..e9571a9b1 100644
--- a/testcases/kernel/syscalls/sched_setparam/sched_setparam03.c
+++ b/testcases/kernel/syscalls/sched_setparam/sched_setparam03.c
@@ -1,196 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
+ * AUTHOR: Saji Kumar.V.R <saji.kumar@wipro.com>
  */
-/**********************************************************
- *
- *    TEST IDENTIFIER	: sched_setparam03
- *
- *    EXECUTED BY	: root / superuser
- *
- *    TEST TITLE	: Checks functionality for sched_setparam(2) for pid!=0
- *
- *    TEST CASE TOTAL	: 1
- *
- *    AUTHOR		: Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- *    SIGNALS
- * 	Uses SIGUSR1 to pause before test if option set.
- * 	(See the parse_opts(3) man page).
- *
- *    DESCRIPTION
- *	This test forks a child & changes its parent's scheduling priority
- *
- * 	Setup:
- * 	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *	  Change scheduling policy to SCHED_FIFO
- *
- * 	Test:
- *	 Loop if the proper options are given.
- *	 Fork a child
- *
- *	 CHILD:
- *	  Changes scheduling priority for parent
- *
- *	 PARENT:
- *	  If scheduling priority is set properly,
- *		TEST passed
- *	  else
- *		TEST failed
- *
- * 	Cleanup:
- * 	  Print errno log and/or timing stats if options given
+
+/*\
+ * [Description]
  *
- * USAGE:  <for command-line>
- *  sched_setparam03 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
- *			where,  -c n : Run n copies concurrently.
- *				-e   : Turn on errno logging.
- *				-h   : Show help screen
- *				-f   : Turn off functional testing
- *				-i n : Execute test n times.
- *				-I x : Execute test for x seconds.
- *				-p   : Pause for SIGUSR1 before starting
- *				-P x : Pause for x seconds between iterations.
- *				-t   : Turn on syscall timing.
+ * Checks functionality for sched_setparam(2) for pid != 0
  *
- ****************************************************************/
-
-#include <err.h>
-#include <errno.h>
-#include <sched.h>
-#include <sys/wait.h>
-#include "test.h"
-
-#define NEW_PRIORITY 5
-
-static void setup();
-static void cleanup();
-static int verify_priority();
+ * This test forks a child and changes its parent's scheduling priority.
+ */
 
-char *TCID = "sched_setparam03";
-int TST_TOTAL = 1;
+#include <stdlib.h>
 
-static struct sched_param param = { NEW_PRIORITY };
+#include "tst_test.h"
+#include "tst_sched.h"
 
-int main(int ac, char **av)
+static void run(void)
 {
-
-	int lc;
-	int status;
+	struct sched_param p5 = { .sched_priority = 5 };
+	struct sched_param p;
 	pid_t child_pid;
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
+	child_pid = SAFE_FORK();
 
-		switch (child_pid = FORK_OR_VFORK()) {
-
-		case -1:
-			/* fork() failed */
-			tst_resm(TFAIL, "fork() failed");
-			continue;
-
-		case 0:
-			/* Child */
-
-			/*
-			 * Call sched_setparam(2) with pid = getppid() so that
-			 * it will set the scheduling parameters for parent
-			 * process
-			 */
-			TEST(sched_setparam(getppid(), &param));
-
-			if (TEST_RETURN == -1) {
-				err(0, "sched_setparam returned %ld",
-				    TEST_RETURN);
-			}
-			exit(1);
-
-		default:
-			/* Parent */
-			if ((waitpid(child_pid, &status, 0)) < 0) {
-				tst_resm(TFAIL, "wait() failed");
-				continue;
-			}
-
-			/*
-			 * Verify that parent's scheduling priority has
-			 * changed.
-			 */
-			if ((WIFEXITED(status)) && (WEXITSTATUS(status)) &&
-			    (verify_priority())) {
-				tst_resm(TPASS, "Test Passed");
-			} else {
-				tst_resm(TFAIL, "Test Failed");
-			}
-		}
+	if (!child_pid) {
+		/*
+		 * Call sched_setparam(2) with pid = getppid() so that
+		 * it will set the scheduling parameters for parent
+		 * process
+		 */
+		TST_EXP_PASS_SILENT(tst_sched_setparam(getppid(), &p5));
+		exit(0);
 	}
+	tst_reap_children();
+
+	TST_EXP_PASS_SILENT(tst_sched_getparam(0, &p));
 
-	cleanup();
-	tst_exit();
+	if (p.sched_priority == p5.sched_priority)
+		tst_res(TPASS, "got expected priority %d", p.sched_priority);
+	else
+		tst_res(TFAIL, "got priority %d, expected %d",
+			p.sched_priority, p5.sched_priority);
 }
 
-/* setup() - performs all ONE TIME setup for this test */
 void setup(void)
 {
-	struct sched_param p = { 1 };
-
-	tst_require_root();
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	/* Change scheduling policy to SCHED_FIFO */
-	if ((sched_setscheduler(0, SCHED_FIFO, &p)) == -1) {
-		tst_brkm(TBROK, cleanup, "sched_setscheduler() failed");
-	}
+	struct sched_param p = { .sched_priority = 1 };
 
+	TST_EXP_PASS_SILENT(tst_sched_setscheduler(0, SCHED_FIFO, &p));
 }
 
-/*
- *cleanup() -   performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- */
-void cleanup(void)
-{
-}
-
-/*
- * verify_priority() -  This function checks whether the priority is
- *			set correctly
- */
-int verify_priority(void)
-{
-	struct sched_param p;
-
-	if ((sched_getparam(0, &p)) == 0) {
-		if (p.sched_priority == NEW_PRIORITY) {
-			return 1;
-		} else {
-			tst_resm(TWARN, "sched_getparam() returned priority"
-				 " value as %d", p.sched_priority);
-			return 0;
-		}
-	}
-
-	tst_resm(TWARN, "sched_getparam() failed");
-	return 0;
-}
+static struct tst_test test = {
+	.forks_child = 1,
+	.needs_root = 1,
+	.setup = setup,
+	.test_all = run,
+};
-- 
2.25.1


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

* [LTP] [PATCH 07/16] syscalls/sched_setparam04: convert to new API
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (6 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 06/16] syscalls/sched_setparam03: " Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 08/16] syscalls/sched_setparam05: " Alexey Kodanev
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../sched_setparam/sched_setparam04.c         | 161 ++++--------------
 1 file changed, 30 insertions(+), 131 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_setparam/sched_setparam04.c b/testcases/kernel/syscalls/sched_setparam/sched_setparam04.c
index f6e017d3d..d80fd0d2a 100644
--- a/testcases/kernel/syscalls/sched_setparam/sched_setparam04.c
+++ b/testcases/kernel/syscalls/sched_setparam/sched_setparam04.c
@@ -1,34 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;  if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ * AUTHOR: Saji Kumar.V.R <saji.kumar@wipro.com>
  */
- /*******************************************************************
- *
- *    TEST IDENTIFIER   : sched_setparam04
- *
- *    EXECUTED BY       : anyone
- *
- *    TEST TITLE        : testing error conditions for sched_setparam(2)
- *
- *    TEST CASE TOTAL   : 4
- *
- *    AUTHOR            : Saji Kumar.V.R <saji.kumar@wipro.com>
+
+/*\
+ * [Description]
  *
- *    SIGNALS
- *      Uses SIGUSR1 to pause before test if option set.
- *      (See the parse_opts(3) man page).
+ * Testing error conditions for sched_setparam(2)
  *
  * DESCRIPTION
  * 	Verify that,
@@ -41,129 +21,48 @@
  *   4) sched_setparam(2) returns -1 sets errno to EINVAL if the
  *	value for p.sched_priority is other than 0 for scheduling
  *	policy, SCHED_OTHER
- *
- * ALGORITHM
- * Setup:
- *   Setup signal handling.
- *   Pause for SIGUSR1 if option specified.
- *
- *  Test:
- *   Loop if the proper options are given.
- *   Execute system call
- *   Check return code, if (system call failed (return=-1)) &
- *			   (errno set == expected errno)
- *              Issue sys call fails with expected return value and errno.
- *   Otherwise,
- *      Issue sys call returns unexpected value.
- *
- *  Cleanup:
- *        Print errno log and/or timing stats if options given
- *
- * USAGE:  <for command-line>
- *  sched_setparam04 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
- *		where,  -c n : Run n copies concurrently.
- *			-e   : Turn on errno logging.
- *			-h   : Show help screen
- *			-f   : Turn off functional testing
- *			-i n : Execute test n times.
- *			-I x : Execute test for x seconds.
- *			-p   : Pause for SIGUSR1 before starting
- *			-P x : Pause for x seconds between iterations.
- *			-t   : Turn on syscall timing.
- *
- *********************************************************************/
-
-#include <errno.h>
-#include <sched.h>
-#include <pwd.h>
-#include "test.h"
+ */
 
-static void cleanup(void);
-static void setup(void);
+#include <stdlib.h>
 
-static struct sched_param param = { 0 };
-static struct sched_param param1 = { 1 };
+#include "tst_test.h"
+#include "tst_sched.h"
 
-char *TCID = "sched_setparam04";
+static struct sched_param p = { .sched_priority = 0 };
+static struct sched_param p1 = { .sched_priority = 1 };
 
 static pid_t unused_pid;
 static pid_t inval_pid = -1;
 static pid_t zero_pid;
 
-static struct test_case_t {
+static struct test_cases_t {
 	char *desc;
 	pid_t *pid;
 	struct sched_param *p;
 	int exp_errno;
-	char err_desc[10];
-} test_cases[] = {
+} tcases[] = {
 	{
-	"test with non-existing pid", &unused_pid, &param, ESRCH, "ESRCH"}, {
-	"test invalid pid value", &inval_pid, &param, EINVAL, "EINVAL"}, {
-	"test with invalid address for p", &zero_pid, NULL, EINVAL, "EINVAL"}, {
-	"test with invalid p.sched_priority", &zero_pid, &param1, EINVAL,
-		    "EINVAL"}
+	"test with non-existing pid", &unused_pid, &p, ESRCH}, {
+	"test invalid pid value", &inval_pid, &p, EINVAL,}, {
+	"test with invalid address for p", &zero_pid, NULL, EINVAL}, {
+	"test with invalid p.sched_priority", &zero_pid, &p1, EINVAL}
 };
 
-int TST_TOTAL = sizeof(test_cases) / sizeof(test_cases[0]);
-
-int main(int ac, char **av)
+static void setup(void)
 {
-	int lc, ind;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global setup */
-
-	/* The following loop checks looping state if -i option given */
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		for (ind = 0; ind < TST_TOTAL; ind++) {
-			/*
-			 * call the system call with the TEST() macro
-			 */
-			TEST(sched_setparam(*(test_cases[ind].pid),
-					    test_cases[ind].p));
-
-			if ((TEST_RETURN == -1) &&
-			    (TEST_ERRNO == test_cases[ind].exp_errno)) {
-				tst_resm(TPASS, "expected failure; Got %s",
-					 test_cases[ind].err_desc);
-			} else {
-				tst_resm(TFAIL, "Call failed to produce "
-					 "expected error;  Expected errno: %d "
-					 "Got : %d, %s",
-					 test_cases[ind].exp_errno,
-					 TEST_ERRNO, strerror(TEST_ERRNO));
-			}
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
+	unused_pid = tst_get_unused_pid();
 }
 
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
+static void run(unsigned int n)
 {
-	unused_pid = tst_get_unused_pid(cleanup);
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
+	struct test_cases_t *tc = &tcases[n];
 
+	TST_EXP_FAIL(tst_sched_setparam(*tc->pid, tc->p), tc->exp_errno,
+		     "%s", tc->desc);
 }
 
-/*
- * cleanup() -  performs all the ONE TIME cleanup for this test at completion
- *		or premature exit.
- */
-void cleanup(void)
-{
-
-}
+static struct tst_test test = {
+	.setup = setup,
+	.test = run,
+	.tcnt = ARRAY_SIZE(tcases),
+};
-- 
2.25.1


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

* [LTP] [PATCH 08/16] syscalls/sched_setparam05: convert to new API
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (7 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 07/16] syscalls/sched_setparam04: " Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 09/16] syscalls/sched_rr_get_interval01: use tst_sched_*() Alexey Kodanev
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../sched_setparam/sched_setparam05.c         | 186 +++---------------
 1 file changed, 26 insertions(+), 160 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_setparam/sched_setparam05.c b/testcases/kernel/syscalls/sched_setparam/sched_setparam05.c
index 53db641d7..36d7c4123 100644
--- a/testcases/kernel/syscalls/sched_setparam/sched_setparam05.c
+++ b/testcases/kernel/syscalls/sched_setparam/sched_setparam05.c
@@ -1,176 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
+ * AUTHOR: Saji Kumar.V.R <saji.kumar@wipro.com>
  */
-/**********************************************************
- *
- *    TEST IDENTIFIER	: sched_setparam05
- *
- *    EXECUTED BY	: root/superuser
- *
- *    TEST TITLE	: verify that sched_setparam() fails if the user does
- *			  not have proper privilages
- *
- *    TEST CASE TOTAL	: 1
- *
- *    AUTHOR		: Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- *    SIGNALS
- * 	Uses SIGUSR1 to pause before test if option set.
- * 	(See the parse_opts(3) man page).
- *
- *    DESCRIPTION
- *	Verify that sched_setparam() fails if the user does
- *	not have proper privilages
- *
- * 	Setup:
- * 	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- * 	Test:
- *	 Loop if the proper options are given.
- *	 Fork a child
- *
- *	 CHILD:
- *	  Changes euid to "nobody" user.
- *	  Try to Change scheduling priority for parent
- *	  If call failed with errno = EPERM,
- *		Test passed
- *	  else
- *		Test failed
- *
- *	 PARENT:
- *		wait for child to finish
- *
- * 	Cleanup:
- * 	  Print errno log and/or timing stats if options given
- *
- * USAGE:  <for command-line>
- *  sched_setparam05 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
- *			where,  -c n : Run n copies concurrently.
- *				-e   : Turn on errno logging.
- *				-h   : Show help screen
- *				-f   : Turn off functional testing
- *				-i n : Execute test n times.
- *				-I x : Execute test for x seconds.
- *				-p   : Pause for SIGUSR1 before starting
- *				-P x : Pause for x seconds between iterations.
- *				-t   : Turn on syscall timing.
+
+/*\
+ * [Description]
  *
- ****************************************************************/
+ * Verify that sched_setparam() fails if the user does not have proper
+ * privileges.
+ */
 
-#include <errno.h>
-#include <sched.h>
+#include <stdlib.h>
 #include <pwd.h>
-#include <sys/wait.h>
-#include "test.h"
-
-static void setup();
-static void cleanup();
-
-char *TCID = "sched_setparam05";
-int TST_TOTAL = 1;
-
-static struct sched_param param = { 0 };
 
-static char nobody_uid[] = "nobody";
-struct passwd *ltpuser;
+#include "tst_test.h"
+#include "tst_sched.h"
 
-int main(int ac, char **av)
+static void run(void)
 {
+	pid_t child_pid = SAFE_FORK();
 
-	int lc;
-	int status;
-	pid_t child_pid;
+	if (!child_pid) {
+		struct sched_param p = { .sched_priority = 0 };
+		struct passwd *pw = SAFE_GETPWNAM("nobody");
 
-	tst_parse_opts(ac, av, NULL, NULL);
+		SAFE_SETEUID(pw->pw_uid);
+		TST_EXP_FAIL(tst_sched_setparam(getppid(), &p), EPERM);
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		switch (child_pid = FORK_OR_VFORK()) {
-
-		case -1:
-			/* fork() failed */
-			tst_resm(TFAIL, "fork() failed");
-			continue;
-
-		case 0:
-			/* Child */
-
-			/* Switch to nobody user */
-			if ((ltpuser = getpwnam(nobody_uid)) == NULL) {
-				tst_brkm(TBROK, NULL, "'%s' user not present", nobody_uid);
-			}
-			if (seteuid(ltpuser->pw_uid) == -1) {
-				tst_resm(TWARN, "seteuid failed to to set the effective uid to %d",
-					 ltpuser->pw_uid);
-				exit(1);
-			}
-
-			/*
-			 * Call sched_setparam(2) with pid = getppid()
-			 */
-			TEST(sched_setparam(getppid(), &param));
-
-			if ((TEST_RETURN == -1) && (TEST_ERRNO == EPERM)) {
-				exit(0);
-			}
-
-			tst_resm(TWARN | TTERRNO,
-				 "Test failed, sched_setparam()"
-				 " returned : %ld", TEST_RETURN);
-			exit(1);
-
-		default:
-			/* Parent */
-			if ((waitpid(child_pid, &status, 0)) < 0) {
-				tst_resm(TFAIL, "wait() failed");
-				continue;
-			}
-			if ((WIFEXITED(status)) && (WEXITSTATUS(status) == 0)) {
-				tst_resm(TPASS, "Test passed, Got EPERM");
-			} else {
-				tst_resm(TFAIL, "Test Failed");
-			}
-		}
+		exit(0);
 	}
 
-	cleanup();
-	tst_exit();
+	tst_reap_children();
 }
 
-/* setup() - performs all ONE TIME setup for this test */
-void setup(void)
-{
-
-	tst_require_root();
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-}
-
-/*
- *cleanup() -  performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- */
-void cleanup(void)
-{
-}
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.test_all = run,
+};
-- 
2.25.1


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

* [LTP] [PATCH 09/16] syscalls/sched_rr_get_interval01: use tst_sched_*()
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (8 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 08/16] syscalls/sched_setparam05: " Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 10/16] syscalls/sched_rr_get_interval02: " Alexey Kodanev
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../syscalls/sched_rr_get_interval/sched_rr_get_interval01.c  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
index 5da5fe51d..cd6525414 100644
--- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
+++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
@@ -11,9 +11,9 @@
  * timeslice tuning knob in milliseconds").
  */
 
-#include <sched.h>
 #include "time64_variants.h"
 #include "tst_timer.h"
+#include "tst_sched.h"
 
 #define PROC_SCHED_RR_TIMESLICE_MS	"/proc/sys/kernel/sched_rr_timeslice_ms"
 static int proc_flag;
@@ -41,7 +41,7 @@ static void setup(void)
 
 	tp.type = tv->ts_type;
 
-	if ((sched_setscheduler(0, SCHED_RR, &p)) == -1)
+	if ((tst_sched_setscheduler(0, SCHED_RR, &p)) == -1)
 		tst_res(TFAIL | TERRNO, "sched_setscheduler() failed");
 
 	proc_flag = !access(PROC_SCHED_RR_TIMESLICE_MS, F_OK);
-- 
2.25.1


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

* [LTP] [PATCH 10/16] syscalls/sched_rr_get_interval02: use tst_sched_*()
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (9 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 09/16] syscalls/sched_rr_get_interval01: use tst_sched_*() Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 11/16] syscalls/sched_rr_get_interval03: " Alexey Kodanev
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../syscalls/sched_rr_get_interval/sched_rr_get_interval02.c  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c
index 9a0b8673d..f84a58216 100644
--- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c
+++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c
@@ -8,9 +8,9 @@
  * for tv_sec & tv_nsec.
  */
 
-#include <sched.h>
 #include "time64_variants.h"
 #include "tst_timer.h"
+#include "tst_sched.h"
 
 static struct tst_ts tp;
 
@@ -35,7 +35,7 @@ static void setup(void)
 
 	tp.type = tv->ts_type;
 
-	if ((sched_setscheduler(0, SCHED_FIFO, &p)) == -1)
+	if ((tst_sched_setscheduler(0, SCHED_FIFO, &p)) == -1)
 		tst_res(TFAIL | TERRNO, "sched_setscheduler() failed");
 }
 
-- 
2.25.1


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

* [LTP] [PATCH 11/16] syscalls/sched_rr_get_interval03: use tst_sched_*()
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (10 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 10/16] syscalls/sched_rr_get_interval02: " Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 12/16] syscalls/sched_setscheduler01: convert to new API Alexey Kodanev
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../syscalls/sched_rr_get_interval/sched_rr_get_interval03.c  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
index a61541b8a..0a486670b 100644
--- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
+++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
@@ -12,9 +12,9 @@
  *     address specified as &tp is invalid
  */
 
-#include <sched.h>
 #include "time64_variants.h"
 #include "tst_timer.h"
+#include "tst_sched.h"
 
 static pid_t unused_pid;
 static pid_t inval_pid = -1;
@@ -55,7 +55,7 @@ static void setup(void)
 	bad_addr = tst_get_bad_addr(NULL);
 	tp.type = tv->ts_type;
 
-	if ((sched_setscheduler(0, SCHED_RR, &p)) == -1)
+	if ((tst_sched_setscheduler(0, SCHED_RR, &p)) == -1)
 		tst_res(TFAIL | TERRNO, "sched_setscheduler() failed");
 
 	unused_pid = tst_get_unused_pid();
-- 
2.25.1


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

* [LTP] [PATCH 12/16] syscalls/sched_setscheduler01: convert to new API
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (11 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 11/16] syscalls/sched_rr_get_interval03: " Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 13/16] syscalls/sched_setscheduler02: " Alexey Kodanev
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../sched_setscheduler/sched_setscheduler01.c | 171 +++++-------------
 1 file changed, 42 insertions(+), 129 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler01.c b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler01.c
index 1cbce15d0..2feaa60d5 100644
--- a/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler01.c
+++ b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler01.c
@@ -1,160 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- *   the GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
+ * Copyright (c) International Business Machines  Corp., 2001
  */
 
-/*
- * NAME
- *	sched_setscheduler01.c
- *
- * DESCRIPTION
- *	Testcase to test whether sched_setscheduler(2) sets the errnos
- *	correctly.
+/*\
+ * [Description]
  *
- * ALGORITHM
- *	1.	Call sched_setscheduler with an invalid pid, and expect
- *	ESRCH to be returned.
- *	2.	Call sched_setscheduler with an invalid scheduling policy,
- *	and expect EINVAL to be returned.
- *	3.	Call sched_setscheduler with an invalid "param" address,
- *	which lies outside the address space of the process, and expect
- *	EFAULT to be returned.
- *	4.	Call sched_setscheduler with an invalid priority value
- *	in "param" and expect EINVAL to be returned
+ * Testcase to test whether sched_setscheduler(2) sets the errnos
+ * correctly.
  *
- * USAGE:  <for command-line>
- *  sched_setscheduler01 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
+ * [Algorithm]
  *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *
- * RESTRICTIONS
- *	None
+ * 1. Call sched_setscheduler with an invalid pid, and expect
+ * ESRCH to be returned.
+ * 2. Call sched_setscheduler with an invalid scheduling policy,
+ * and expect EINVAL to be returned.
+ * 3. Call sched_setscheduler with an invalid "param" address,
+ * which lies outside the address space of the process, and expect
+ * EFAULT to be returned.
+ * 4.Call sched_setscheduler with an invalid priority value
+ * in "param" and expect EINVAL to be returned
  */
+
 #include <stdio.h>
 #include <errno.h>
-#include <sched.h>
 #include <pwd.h>
-#include "test.h"
 
-#define SCHED_INVALID	99
-
-char *TCID = "sched_setscheduler01";
+#include "tst_test.h"
+#include "tst_sched.h"
 
-struct sched_param param;
-struct sched_param param1 = { 1 };
-
-void setup(void);
-void cleanup(void);
+#define SCHED_INVALID	99
 
+static struct sched_param p;
+static struct sched_param p1 = { .sched_priority = 1 };
 static pid_t unused_pid;
 static pid_t init_pid = 1;
 static pid_t zero_pid;
 
-struct test_case_t {
+struct test_cases_t {
 	pid_t *pid;
 	int policy;
 	struct sched_param *p;
 	int error;
-} TC[] = {
+} tcases[] = {
 	/* The pid is invalid - ESRCH */
-	{
-	&unused_pid, SCHED_OTHER, &param, ESRCH},
-	    /* The policy is invalid - EINVAL */
-	{
-	&init_pid, SCHED_INVALID, &param, EINVAL},
-#ifndef UCLINUX
-	    /* Skip since uClinux does not implement memory protection */
-	    /* The param address is invalid - EFAULT */
-	{
-	&init_pid, SCHED_OTHER, (struct sched_param *)-1, EFAULT},
-#endif
-	    /* The priority value in param invalid - EINVAL */
-	{
-	&zero_pid, SCHED_OTHER, &param1, EINVAL}
+	{&unused_pid, SCHED_OTHER, &p, ESRCH},
+	/* The policy is invalid - EINVAL */
+	{&init_pid, SCHED_INVALID, &p, EINVAL},
+	/* The param address is invalid - EFAULT */
+	{&init_pid, SCHED_OTHER, (struct sched_param *)-1, EFAULT},
+	/* The priority value in param invalid - EINVAL */
+	{&zero_pid, SCHED_OTHER, &p1, EINVAL}
 };
 
-int TST_TOTAL = ARRAY_SIZE(TC);
-
-int main(int ac, char **av)
+static void setup(void)
 {
-	int lc;
-
-	int i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		setup();
-
-		/* loop through the test cases */
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			TEST(sched_setscheduler(*(TC[i].pid), TC[i].policy,
-						TC[i].p));
-
-			if (TEST_RETURN != -1) {
-				tst_resm(TFAIL, "call succeeded unexpectedly");
-				continue;
-			}
-
-			if (TEST_ERRNO == TC[i].error) {
-				tst_resm(TPASS, "expected failure - "
-					 "errno = %d : %s", TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-			} else {
-				tst_resm(TFAIL, "unexpected error - %d : %s - "
-					 "expected %d", TEST_ERRNO,
-					 strerror(TEST_ERRNO), TC[i].error);
-			}
-		}
-	}
-	cleanup();
-
-	tst_exit();
-
+	unused_pid = tst_get_unused_pid();
 }
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
+static void run(unsigned int n)
 {
-	unused_pid = tst_get_unused_pid(cleanup);
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	struct test_cases_t *tc = &tcases[n];
 
-	TEST_PAUSE;
+	TST_EXP_FAIL(tst_sched_setscheduler(*tc->pid, tc->policy, tc->p), tc->error);
 }
 
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *	       completion or premature exit.
- */
-void cleanup(void)
-{
-
-}
+static struct tst_test test = {
+	.setup = setup,
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+};
-- 
2.25.1


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

* [LTP] [PATCH 13/16] syscalls/sched_setscheduler02: convert to new API
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (12 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 12/16] syscalls/sched_setscheduler01: convert to new API Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 14/16] syscalls/sched_setscheduler03: use tst_sched_*() Alexey Kodanev
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../sched_setscheduler/sched_setscheduler02.c | 154 ++++--------------
 1 file changed, 33 insertions(+), 121 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler02.c b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler02.c
index 36952d9cb..68afb05c9 100644
--- a/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler02.c
+++ b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler02.c
@@ -1,148 +1,60 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- *   the GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
+ * Copyright (c) International Business Machines  Corp., 2001
  */
 
-/*
- * NAME
- *	sched_setscheduler01.c
+/*\
+ * [Description]
  *
- * DESCRIPTION
- *	Testcase to test whether sched_setscheduler(2) sets the errnos
- *	correctly.
+ * Testcase to test whether sched_setscheduler(2) sets the errnos
+ * correctly.
  *
- * ALGORITHM
- *	1.	Call sched_setscheduler as a non-root uid, and expect EPERM
- *	to be returned.
+ * [Algorithm]
  *
- * USAGE:  <for command-line>
- *  sched_setscheduler02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
+ * Call sched_setscheduler as a non-root uid, and expect EPERM
+ * to be returned.
  *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *
- * RESTRICTIONS
- *	Must run test as root.
  */
-#include <stdio.h>
+
+#include <stdlib.h>
 #include <errno.h>
-#include <sched.h>
 #include <pwd.h>
 #include <sys/types.h>
-#include <sys/wait.h>
 
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
+#include "tst_sched.h"
 
 #define SCHED_INVALID	99
 #define INVALID_PID	999999
 
-char *TCID = "sched_setscheduler02";
-int TST_TOTAL = 1;
-
-void setup(void);
-void cleanup(void);
-
 static uid_t nobody_uid;
 
-int main(int ac, char **av)
+static void setup(void)
 {
-	int lc;
-	pid_t pid;
-	struct sched_param param;
-	int status;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		if ((pid = FORK_OR_VFORK()) == -1) {
-			tst_brkm(TBROK, cleanup, "fork failed");
-		}
-
-		if (pid == 0) {	/* child */
-			param.sched_priority = 1;
-
-			SAFE_SETEUID(cleanup, nobody_uid);
-
-			TEST(sched_setscheduler(pid, SCHED_FIFO, &param));
-
-			if (TEST_ERRNO) {
-			}
-
-			if (TEST_RETURN != -1) {
-				tst_resm(TFAIL, "sched_setscheduler(2) passed "
-					 "with non root priveledges");
-			} else if (TEST_ERRNO != EPERM) {
-				tst_resm(TFAIL, "Expected EPERM, got %d",
-					 TEST_ERRNO);
-			} else {
-				tst_resm(TPASS, "got EPERM");
-			}
-		} else {	/* parent */
-			/* let the child carry on */
-			wait(&status);
-			if (WIFEXITED(status) != 0) {	/* Exit with errors */
-				exit(WEXITSTATUS(status));
-			} else {
-				exit(0);
-			}
-		}
-
-		SAFE_SETEUID(cleanup, 0);
-	}
-	cleanup();
-	tst_exit();
+	struct passwd *pw = SAFE_GETPWNAM("nobody");
 
+	nobody_uid = pw->pw_uid;
 }
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
+static void run(void)
 {
-	struct passwd *pw;
-
-	tst_require_root();
+	pid_t pid = SAFE_FORK();
 
-	pw = SAFE_GETPWNAM(NULL, "nobody");
-	nobody_uid = pw->pw_uid;
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
+	if (!pid) {
+		struct sched_param p = { .sched_priority = 1 };
 
-	TEST_PAUSE;
+		SAFE_SETEUID(nobody_uid);
+		TST_EXP_FAIL(tst_sched_setscheduler(0, SCHED_FIFO, &p), EPERM);
+		SAFE_SETEUID(0);
+		exit(0);
+	}
+	tst_reap_children();
 }
 
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *	       completion or premature exit.
- */
-void cleanup(void)
-{
-
-}
+static struct tst_test test = {
+	.forks_child = 1,
+	.needs_root = 1,
+	.setup = setup,
+	.test_all = run,
+};
-- 
2.25.1


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

* [LTP] [PATCH 14/16] syscalls/sched_setscheduler03: use tst_sched_*()
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (13 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 13/16] syscalls/sched_setscheduler02: " Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 15/16] syscalls/sched_getscheduler01: convert to new API Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 16/16] syscalls/sched_getscheduler02: " Alexey Kodanev
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../syscalls/sched_setscheduler/sched_setscheduler03.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c
index 9045d0366..af4b29300 100644
--- a/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c
+++ b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c
@@ -17,13 +17,13 @@
 #include <stdio.h>
 #include <errno.h>
 #include <pwd.h>
-#include <sched.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/wait.h>
 #include <stdlib.h>
 
 #include "tst_test.h"
+#include "tst_sched.h"
 
 #define RLIMIT_NICE_NORMAL 20
 
@@ -96,8 +96,8 @@ static void verify_fn(unsigned int i)
 		"Verifying case[%d]: policy = %d, priority = %d",
 		i + 1, cases[i].policy, cases[i].sched_param->sched_priority);
 
-	TEST(sched_setscheduler(*cases[i].pid, cases[i].policy,
-					cases[i].sched_param));
+	TEST(tst_sched_setscheduler(*cases[i].pid, cases[i].policy,
+				    cases[i].sched_param));
 	if (TST_RET)
 		tst_res(TFAIL | TTERRNO, "case[%d] expected: %d, got: ",
 			i + 1, cases[i].error);
@@ -129,11 +129,11 @@ static void setup(void)
 	l_rlimit_setup(RLIMIT_NICE, &limit);
 
 	tst_res(TINFO, "Setting init sched policy to SCHED_OTHER");
-	if (sched_setscheduler(0, SCHED_OTHER, &param[0]) != 0)
+	if (tst_sched_setscheduler(0, SCHED_OTHER, &param[0]) != 0)
 		tst_res(TFAIL | TERRNO,
 			 "ERROR sched_setscheduler: (0, SCHED_OTHER, param)");
 
-	if (sched_getscheduler(0) != SCHED_OTHER)
+	if (tst_sched_getscheduler(0) != SCHED_OTHER)
 		tst_res(TFAIL | TERRNO, "ERROR sched_setscheduler");
 
 	tst_res(TINFO, "Setting euid to nobody to drop privilege");
-- 
2.25.1


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

* [LTP] [PATCH 15/16] syscalls/sched_getscheduler01: convert to new API
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (14 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 14/16] syscalls/sched_setscheduler03: use tst_sched_*() Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  2021-07-20 13:33 ` [LTP] [PATCH 16/16] syscalls/sched_getscheduler02: " Alexey Kodanev
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../sched_getscheduler/sched_getscheduler01.c | 141 +++++-------------
 1 file changed, 37 insertions(+), 104 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler01.c b/testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler01.c
index f6bdf1a1b..e0da0510d 100644
--- a/testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler01.c
+++ b/testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler01.c
@@ -1,129 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- *   the GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
+ * Copyright (c) International Business Machines  Corp., 2001
  */
 
-/*
- * NAME
- *	sched_getscheduler01.C
+/*\
+ * [Description]
  *
- * DESCRIPTION
- *	Testcase to check sched_getscheduler() returns correct return value
+ * Testcase to check sched_getscheduler() returns correct return value.
  *
- * ALGORTIHM
- *	Call sched_setcheduler() to set the scheduling policy of the current
- *	process. Then call sched_getscheduler() to ensure that this is same
- *	as what set by the previous call to sched_setscheduler().
+ * [Algorithm]
  *
- *	Use SCHED_RR, SCHED_FIFO, SCHED_OTHER as the scheduling policies for
- *	sched_setscheduler().
+ * Call sched_setcheduler() to set the scheduling policy of the current
+ * process. Then call sched_getscheduler() to ensure that this is same
+ * as what set by the previous call to sched_setscheduler().
  *
- * USAGE:  <for command-line>
- *  sched_getscheduler01 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
+ * Use SCHED_RR, SCHED_FIFO, SCHED_OTHER as the scheduling policies for
+ * sched_setscheduler().
  *
- * RESTRICTION
- *	Must run test as root.
  */
 
 #include <errno.h>
-#include <sched.h>
 #include <stdio.h>
-#include "test.h"
-
-char *TCID = "sched_getscheduler01";
-int TST_TOTAL = 3;
 
-void setup(void);
-void cleanup(void);
+#include "tst_test.h"
+#include "tst_sched.h"
 
-struct test_case_t {
-	int prio;
+struct test_cases_t {
+	int priority;
 	int policy;
-} TC[] = {
-	/* set scheduling policy to SCHED_RR */
-	{
-	1, SCHED_RR},
-	    /* set scheduling policy to SCHED_OTHER */
-	{
-	0, SCHED_OTHER},
-	    /* set scheduling policy to SCHED_FIFO */
-	{
-	1, SCHED_FIFO}
+} tcases[] = {
+	{1, SCHED_RR},
+	{0, SCHED_OTHER},
+	{1, SCHED_FIFO}
 };
 
-int main(int ac, char **av)
+static void run(unsigned int n)
 {
-	int lc;
-	int i;
-	struct sched_param param;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
+	struct test_cases_t *tc = &tcases[n];
+	struct sched_param p = { .sched_priority = tc->priority };
 
-			param.sched_priority = TC[i].prio;
+	TST_EXP_PASS_SILENT(tst_sched_setscheduler(0, tc->policy, &p));
 
-			if (sched_setscheduler(0, TC[i].policy, &param) == -1)
-				tst_brkm(TBROK, cleanup,
-					 "sched_setscheduler failed");
+	TEST(tst_sched_getscheduler(0));
 
-			TEST(sched_getscheduler(0));
-
-			if (TEST_RETURN == -1) {
-				tst_resm(TFAIL, "call failed unexpectedly");
-				continue;
-			}
-
-			if (TEST_RETURN != TC[i].policy)
-				tst_resm(TFAIL,
-					 "policy value returned is not "
-					 "correct");
-			else
-				tst_resm(TPASS,
-					 "policy value returned is correct");
-		}
+	if (TST_RET == -1) {
+		tst_res(TFAIL, "sched_getscheduler() failed unexpectedly");
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (TST_RET == tc->policy)
+		tst_res(TPASS, "got expected policy %d", tc->policy);
+	else
+		tst_res(TFAIL, "got policy %ld, expected %d", TST_RET, tc->policy);
 }
 
-void setup(void)
-{
-
-	tst_require_root();
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-void cleanup(void)
-{
-}
+static struct tst_test test = {
+	.needs_root = 1,
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+};
-- 
2.25.1


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

* [LTP] [PATCH 16/16] syscalls/sched_getscheduler02: convert to new API
  2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
                   ` (15 preceding siblings ...)
  2021-07-20 13:33 ` [LTP] [PATCH 15/16] syscalls/sched_getscheduler01: convert to new API Alexey Kodanev
@ 2021-07-20 13:33 ` Alexey Kodanev
  16 siblings, 0 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 13:33 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 .../sched_getscheduler/sched_getscheduler02.c | 104 +++---------------
 1 file changed, 16 insertions(+), 88 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler02.c b/testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler02.c
index c43240108..73c5f58db 100644
--- a/testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler02.c
+++ b/testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler02.c
@@ -1,106 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- *   the GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Copyright (c) 2021, BELLSOFT. All rights reserved.
+ * Copyright (c) International Business Machines  Corp., 2001
  */
 
-/*
- * NAME
- *	sched_getscheduler02.C
- *
- * DESCRIPTION
- *	To check for the errno ESRCH
- *
- * ALGORITHM
- *	Pass an invalid pid to sched_getscheduler() and test for ESRCH.
+/*\
+ * [Description]
  *
- * USAGE:  <for command-line>
- *  sched_getscheduler02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
- *
- * RESTRICTION
- *	None
+ * Pass an invalid pid to sched_getscheduler() and test for ESRCH.
  */
 
 #include <stdio.h>
-#include <sched.h>
 #include <errno.h>
-#include "test.h"
 
-char *TCID = "sched_getscheduler02";
-int TST_TOTAL = 1;
+#include "tst_test.h"
+#include "tst_sched.h"
 
 static pid_t unused_pid;
 
-void setup(void);
-void cleanup(void);
-
-int main(int ac, char **av)
+static void setup(void)
 {
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		TEST(sched_getscheduler(unused_pid));
-
-		if (TEST_RETURN != -1) {
-			tst_resm(TFAIL, "sched_getscheduler(2) passed "
-				 "unexpectedly");
-			continue;
-		}
-
-		if (errno != ESRCH) {
-			tst_resm(TFAIL, "Expected ESRCH, got %d", errno);
-		} else {
-			tst_resm(TPASS, "call failed with ESRCH");
-		}
-	}
-	cleanup();
-	tst_exit();
-
+	unused_pid = tst_get_unused_pid();
 }
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
+static void run(void)
 {
-	unused_pid = tst_get_unused_pid(cleanup);
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
+	TST_EXP_FAIL(tst_sched_getscheduler(unused_pid), ESRCH);
 }
 
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *	       completion or premature exit.
- */
-void cleanup(void)
-{
-
-}
+static struct tst_test test = {
+	.setup = setup,
+	.test_all = run,
+};
-- 
2.25.1


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

* [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno
  2021-07-20 14:06   ` Alexey Kodanev
@ 2021-07-20 14:06     ` Cyril Hrubis
  2021-07-20 14:23     ` Cyril Hrubis
  1 sibling, 0 replies; 23+ messages in thread
From: Cyril Hrubis @ 2021-07-20 14:06 UTC (permalink / raw)
  To: ltp

Hi!
> >> The patch-set introduced new tst_sched_* wrappers to handle ENOSYS
> >> error that can be returned by libc (musl [1]). In that particular
> >> case the wrapper uses syscall directly to test the kernel anyway.
> > 
> > Can't we use the test_variants to test both the kernel and libc calls
> > instead?
> 
> With glibc it seems it would be just a redundant work to call both
> variants, wouldn't it?

I do not think so, since the libc wrappers may be more complex than just
a syscall(__NR_foo, ...). At least recently the libc variants are
switching between foo and foo_time64 syscall variants and convert the
timespecs accordingly.

> BTW, sched_rr_get_interval* tests already using tst_variants, adding
> more variants will double them too, right?

That's true and this makes things slightly more complicated. But as
these test just calls a few syscalls and check return values I doubt
that doubling the test matrix would be measureable in the test runtime.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno
  2021-07-20 13:18 ` Cyril Hrubis
@ 2021-07-20 14:06   ` Alexey Kodanev
  2021-07-20 14:06     ` Cyril Hrubis
  2021-07-20 14:23     ` Cyril Hrubis
  0 siblings, 2 replies; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 14:06 UTC (permalink / raw)
  To: ltp

Hi Cyril,
On 20.07.2021 16:18, Cyril Hrubis wrote:
> Hi!
>> The patch-set introduced new tst_sched_* wrappers to handle ENOSYS
>> error that can be returned by libc (musl [1]). In that particular
>> case the wrapper uses syscall directly to test the kernel anyway.
> 
> Can't we use the test_variants to test both the kernel and libc calls
> instead?

With glibc it seems it would be just a redundant work to call both
variants, wouldn't it?

BTW, sched_rr_get_interval* tests already using tst_variants, adding
more variants will double them too, right?

> 
>> [1]: https://git.musl-libc.org/cgit/musl/commit/?id=1e21e78bf7a5
>>
>> Alexey Kodanev (16):
>>   lib/tst_sched: add ltp tst_sched_*()
>>   syscalls/sched_getparam01: use tst_sched_*()
>>   syscalls/sched_getparam03: use tst_sched_*()
>>   syscalls/sched_setparam01: convert to new API
>>   syscalls/sched_setparam02: convert to new API
>>   syscalls/sched_setparam03: convert to new API
>>   syscalls/sched_setparam04: convert to new API
>>   syscalls/sched_setparam05: convert to new API
>>   syscalls/sched_rr_get_interval01: use tst_sched_*()
>>   syscalls/sched_rr_get_interval02: use tst_sched_*()
>>   syscalls/sched_rr_get_interval03: use tst_sched_*()
>>   syscalls/sched_setscheduler01: convert to new API
>>   syscalls/sched_setscheduler02: convert to new API
>>   syscalls/sched_setscheduler03: use tst_sched_*()
>>   syscalls/sched_getscheduler01: convert to new API
>>   syscalls/sched_getscheduler02: convert to new API
>>
>>  include/tst_sched.h                           |  16 ++
>>  lib/tst_sched.c                               |  36 +++
>>  .../sched_getparam/sched_getparam01.c         |   6 +-
>>  .../sched_getparam/sched_getparam03.c         |   4 +-
>>  .../sched_getscheduler/sched_getscheduler01.c | 141 +++---------
>>  .../sched_getscheduler/sched_getscheduler02.c | 104 ++-------
>>  .../sched_rr_get_interval01.c                 |   4 +-
>>  .../sched_rr_get_interval02.c                 |   4 +-
>>  .../sched_rr_get_interval03.c                 |   4 +-
>>  .../sched_setparam/sched_setparam01.c         | 135 ++---------
>>  .../sched_setparam/sched_setparam02.c         | 195 +++-------------
>>  .../sched_setparam/sched_setparam03.c         | 215 ++++--------------
>>  .../sched_setparam/sched_setparam04.c         | 161 +++----------
>>  .../sched_setparam/sched_setparam05.c         | 186 +++------------
>>  .../sched_setscheduler/sched_setscheduler01.c | 171 ++++----------
>>  .../sched_setscheduler/sched_setscheduler02.c | 154 +++----------
>>  .../sched_setscheduler/sched_setscheduler03.c |  10 +-
>>  17 files changed, 345 insertions(+), 1201 deletions(-)
>>  create mode 100644 include/tst_sched.h
>>  create mode 100644 lib/tst_sched.c
>>
>> -- 
>> 2.25.1
>>
>>
>> -- 
>> Mailing list info: https://lists.linux.it/listinfo/ltp
> 


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

* [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno
  2021-07-20 14:06   ` Alexey Kodanev
  2021-07-20 14:06     ` Cyril Hrubis
@ 2021-07-20 14:23     ` Cyril Hrubis
  2021-07-20 15:26       ` Alexey Kodanev
  1 sibling, 1 reply; 23+ messages in thread
From: Cyril Hrubis @ 2021-07-20 14:23 UTC (permalink / raw)
  To: ltp

Hi!
> BTW, sched_rr_get_interval* tests already using tst_variants, adding
> more variants will double them too, right?

Actually not, since we do run the test for both the libc
sched_rr_get_interval and for all possible syscalls variants we don't
have to touch these tests at all.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno
  2021-07-20 14:23     ` Cyril Hrubis
@ 2021-07-20 15:26       ` Alexey Kodanev
  2021-07-20 17:23         ` Cyril Hrubis
  0 siblings, 1 reply; 23+ messages in thread
From: Alexey Kodanev @ 2021-07-20 15:26 UTC (permalink / raw)
  To: ltp

On 20.07.2021 17:23, Cyril Hrubis wrote:
> Hi!
>> BTW, sched_rr_get_interval* tests already using tst_variants, adding
>> more variants will double them too, right?
> 
> Actually not, since we do run the test for both the libc
> sched_rr_get_interval and for all possible syscalls variants we don't
> have to touch these tests at all.

sched_rr_get_interval works with musl, the one which returns ENOSYS
is sched_setscheduler() there, in setup().

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

* [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno
  2021-07-20 15:26       ` Alexey Kodanev
@ 2021-07-20 17:23         ` Cyril Hrubis
  0 siblings, 0 replies; 23+ messages in thread
From: Cyril Hrubis @ 2021-07-20 17:23 UTC (permalink / raw)
  To: ltp

Hi!
> >> BTW, sched_rr_get_interval* tests already using tst_variants, adding
> >> more variants will double them too, right?
> > 
> > Actually not, since we do run the test for both the libc
> > sched_rr_get_interval and for all possible syscalls variants we don't
> > have to touch these tests at all.
> 
> sched_rr_get_interval works with musl, the one which returns ENOSYS
> is sched_setscheduler() there, in setup().

Since this is setup we may as well switch to syscall() in the test
setup and be done with it, we are not testing sched_setscheduler() in
these tests.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2021-07-20 17:23 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20 13:33 [LTP] [PATCH 00/16] syscalls/sched_*: convert to new API and handle ENOSYS errno Alexey Kodanev
2021-07-20 13:18 ` Cyril Hrubis
2021-07-20 14:06   ` Alexey Kodanev
2021-07-20 14:06     ` Cyril Hrubis
2021-07-20 14:23     ` Cyril Hrubis
2021-07-20 15:26       ` Alexey Kodanev
2021-07-20 17:23         ` Cyril Hrubis
2021-07-20 13:33 ` [LTP] [PATCH 01/16] lib/tst_sched: add ltp tst_sched_*() Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 02/16] syscalls/sched_getparam01: use tst_sched_*() Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 03/16] syscalls/sched_getparam03: " Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 04/16] syscalls/sched_setparam01: convert to new API Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 05/16] syscalls/sched_setparam02: " Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 06/16] syscalls/sched_setparam03: " Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 07/16] syscalls/sched_setparam04: " Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 08/16] syscalls/sched_setparam05: " Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 09/16] syscalls/sched_rr_get_interval01: use tst_sched_*() Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 10/16] syscalls/sched_rr_get_interval02: " Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 11/16] syscalls/sched_rr_get_interval03: " Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 12/16] syscalls/sched_setscheduler01: convert to new API Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 13/16] syscalls/sched_setscheduler02: " Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 14/16] syscalls/sched_setscheduler03: use tst_sched_*() Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 15/16] syscalls/sched_getscheduler01: convert to new API Alexey Kodanev
2021-07-20 13:33 ` [LTP] [PATCH 16/16] syscalls/sched_getscheduler02: " Alexey Kodanev

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.