All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] sched_getattr/sched_getattr02: Add new testcase for sched_getattr
@ 2015-10-20 12:59 Cui Bixuan
  2015-10-26 15:47 ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Cui Bixuan @ 2015-10-20 12:59 UTC (permalink / raw)
  To: ltp

Add new testcase for sched_getattr

Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
---
 runtest/sched                                      |    1 +
 runtest/syscalls                                   |    1 +
 .../syscalls/sched_getattr/sched_getattr02.c       |  152 ++++++++++++++++++++
 3 files changed, 154 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/syscalls/sched_getattr/sched_getattr02.c

diff --git a/runtest/sched b/runtest/sched
index 10a1648..4b8a1df 100644
--- a/runtest/sched
+++ b/runtest/sched
@@ -10,6 +10,7 @@ hackbench01 hackbench 50 process 1000
 hackbench02 hackbench 20 thread 1000
 
 sched_getattr01 sched_getattr01
+sched_getattr02 sched_getattr02
 
 sched_cli_serv run_sched_cliserv.sh
 # Run this stress test for 2 minutes
diff --git a/runtest/syscalls b/runtest/syscalls
index 958f66e..724ab66 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -923,6 +923,7 @@ sched_setaffinity01 sched_setaffinity01
 sched_getaffinity01 sched_getaffinity01
 
 sched_getattr01 sched_getattr01
+sched_getattr02 sched_getattr02
 
 select01 select01
 select02 select02
diff --git a/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
new file mode 100644
index 0000000..a829e00
--- /dev/null
+++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
@@ -0,0 +1,152 @@
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <linux/unistd.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <sys/syscall.h>
+#include <pthread.h>
+#include <sched.h>
+#include <errno.h>
+
+#include "test.h"
+#include "linux_syscall_numbers.h"
+#include "lapi/sched.h"
+
+char *TCID = "sched_getattr01";
+int TST_TOTAL = 1;
+
+#define SCHED_DEADLINE	6
+#define RUNTIME_VAL 10000000
+#define PERIOD_VAL 30000000
+#define DEADLINE_VAL 30000000
+
+void *run_deadline(void *data LTP_ATTRIBUTE_UNUSED)
+{
+	struct sched_attr attr, attr_copy;
+	int ret;
+	unsigned int flags = 0;
+	unsigned int size;
+
+	attr.size = sizeof(attr);
+	attr.sched_flags = 0;
+	attr.sched_nice = 0;
+	attr.sched_priority = 0;
+
+	/* This creates a 10ms/30ms reservation */
+	attr.sched_policy = SCHED_DEADLINE;
+	attr.sched_runtime = RUNTIME_VAL;
+	attr.sched_period = PERIOD_VAL;
+	attr.sched_deadline = DEADLINE_VAL;
+
+	ret = sched_setattr(0, &attr, flags);
+	if (ret < 0)
+		tst_brkm(TFAIL | TERRNO, NULL, "sched_setattr() failed");
+
+	size = sizeof(attr_copy);
+
+	/*
+	 * TEST CASE 1
+	 * set invalid address (NULL) of attr
+	 */
+	TEST(sched_getattr(0, NULL, size, flags));
+
+	if (TEST_RETURN == -1) {
+		if (TEST_ERRNO == EINVAL) {
+			tst_resm(TPASS, "sched_getattr() - set invalid address of attr failed as expected with errno %d : %s",
+			TEST_ERRNO,
+			strerror(TEST_ERRNO));
+		} else {
+			tst_resm(TFAIL, "sched_getattr() - set invalid address of attr failed with errno %d : %s but expected %d (EINVAL)",
+			TEST_ERRNO,
+			strerror(TEST_ERRNO), EINVAL);
+		}
+	} else {
+		tst_resm(TFAIL, "sched_getattr() - set invalid address of attr succeeded unexpectedly.");
+	}
+
+	/*
+	 * TEST CASE 2
+	 * set error value (999999) of pid
+	 */
+	TEST(sched_getattr(999999, &attr_copy, size, flags));
+
+	if (TEST_RETURN == -1) {
+		if (TEST_ERRNO == ESRCH) {
+			tst_resm(TPASS, "sched_getattr() - set error value of pid failed as expected with errno %d : %s",
+			TEST_ERRNO,
+			strerror(TEST_ERRNO));
+		} else {
+			tst_resm(TFAIL, "sched_getattr() - set error value of pid failed with errno %d : %s but expected %d (ESRCH)",
+			TEST_ERRNO,
+			strerror(TEST_ERRNO), ESRCH);
+		}
+	} else {
+		tst_resm(TFAIL, "sched_getattr() - set error value of pid succeeded unexpectedly.");
+	}
+
+	/*
+	 * TEST CASE 3
+	 * set error value of size
+	 */
+	TEST(sched_getattr(0, &attr_copy, size - 1, flags));
+
+	if (TEST_RETURN == -1) {
+		if (TEST_ERRNO == EINVAL) {
+			tst_resm(TPASS, "sched_getattr() - set error value of size failed as expected with errno %d : %s",
+			TEST_ERRNO,
+			strerror(TEST_ERRNO));
+		} else {
+			tst_resm(TFAIL, "sched_getattr() - set error value of size failed with errno %d : %s but expected %d (EINVAL)",
+			TEST_ERRNO,
+			strerror(TEST_ERRNO), EINVAL);
+		}
+	} else {
+		tst_resm(TFAIL, "sched_getattr() - set error value of size succeeded unexpectedly.");
+	}
+
+	/*
+	 * TEST CASE 4
+	 * set error value (10000) of flags
+	 */
+	TEST(sched_getattr(0, &attr_copy, size, 10000));
+
+	if (TEST_RETURN == -1) {
+		if (TEST_ERRNO == EINVAL) {
+			tst_resm(TPASS, "sched_getattr() - set error value of flags failed as expected with errno %d : %s",
+			TEST_ERRNO,
+			strerror(TEST_ERRNO));
+		} else {
+			tst_resm(TFAIL, "sched_getattr() - set error value of flags failed with errno %d : %s but expected %d (EINVAL)",
+			TEST_ERRNO,
+			strerror(TEST_ERRNO), EINVAL);
+		}
+	} else {
+		tst_resm(TFAIL, "sched_getattr() - set error value of pid succeeded unexpectedly.");
+	}
+
+	return NULL;
+}
+
+int main(int argc, char **argv)
+{
+	pthread_t thread;
+	int lc;
+
+	tst_parse_opts(argc, argv, NULL, NULL);
+
+	tst_require_root();
+
+	if ((tst_kvercmp(3, 14, 0)) < 0)
+		tst_brkm(TCONF, NULL, "EDF needs kernel 3.14 or higher");
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		pthread_create(&thread, NULL, run_deadline, NULL);
+		pthread_join(thread, NULL);
+	}
+
+	tst_exit();
+}
-- 
1.6.0.2


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

* [LTP] [PATCH] sched_getattr/sched_getattr02: Add new testcase for sched_getattr
  2015-10-20 12:59 [LTP] [PATCH] sched_getattr/sched_getattr02: Add new testcase for sched_getattr Cui Bixuan
@ 2015-10-26 15:47 ` Cyril Hrubis
  2015-10-28  1:40   ` [LTP] [PATCH v2] " Cui Bixuan
  0 siblings, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2015-10-26 15:47 UTC (permalink / raw)
  To: ltp

Hi!
> --- /dev/null
> +++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
> @@ -0,0 +1,152 @@

Please add a GPL header here.

> +#define _GNU_SOURCE
> +#include <unistd.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <time.h>
> +#include <linux/unistd.h>
> +#include <linux/kernel.h>
> +#include <linux/types.h>
> +#include <sys/syscall.h>
> +#include <pthread.h>
> +#include <sched.h>
> +#include <errno.h>
> +
> +#include "test.h"
> +#include "linux_syscall_numbers.h"
> +#include "lapi/sched.h"
> +
> +char *TCID = "sched_getattr01";
> +int TST_TOTAL = 1;
> +
> +#define SCHED_DEADLINE	6
> +#define RUNTIME_VAL 10000000
> +#define PERIOD_VAL 30000000
> +#define DEADLINE_VAL 30000000
> +
> +void *run_deadline(void *data LTP_ATTRIBUTE_UNUSED)
> +{
> +	struct sched_attr attr, attr_copy;
> +	int ret;
> +	unsigned int flags = 0;
> +	unsigned int size;
> +
> +	attr.size = sizeof(attr);
> +	attr.sched_flags = 0;
> +	attr.sched_nice = 0;
> +	attr.sched_priority = 0;
> +
> +	/* This creates a 10ms/30ms reservation */
> +	attr.sched_policy = SCHED_DEADLINE;
> +	attr.sched_runtime = RUNTIME_VAL;
> +	attr.sched_period = PERIOD_VAL;
> +	attr.sched_deadline = DEADLINE_VAL;
> +
> +	ret = sched_setattr(0, &attr, flags);
> +	if (ret < 0)
> +		tst_brkm(TFAIL | TERRNO, NULL, "sched_setattr() failed");
> +
> +	size = sizeof(attr_copy);

So this test test invalid parameters passed to sched_getattr(), then it
would be far better to define array of structures that describe what
parameters should be passed to the call and what is the expected
outcome. See for instance:

testcases/kernel/syscalls/kcmp/kcmp02.c

> +	/*
> +	 * TEST CASE 1
> +	 * set invalid address (NULL) of attr
> +	 */
> +	TEST(sched_getattr(0, NULL, size, flags));
> +
> +	if (TEST_RETURN == -1) {
> +		if (TEST_ERRNO == EINVAL) {
> +			tst_resm(TPASS, "sched_getattr() - set invalid address of attr failed as expected with errno %d : %s",
> +			TEST_ERRNO,
> +			strerror(TEST_ERRNO));
> +		} else {
> +			tst_resm(TFAIL, "sched_getattr() - set invalid address of attr failed with errno %d : %s but expected %d (EINVAL)",

These messages are far too long. Be more punctual and to the point. Also
you should really use TTERRNO flag that will print TEST_ERRNO in
standard format rather than doing it manually. I would do something as:

tst_resm(TFAIL | TTERRNO, "sched_getattr() attr = NULL, expected EINVAL");

Which would yield:

foo         1  TFAIL  :  sched_getattr02.c:21: sched_getattr() attr = NULL, expected EINVAL: errno=EFAULT(14): Bad address

Which contains all information that is needed.

> +			TEST_ERRNO,
> +			strerror(TEST_ERRNO), EINVAL);
> +		}
> +	} else {
> +		tst_resm(TFAIL, "sched_getattr() - set invalid address of attr succeeded unexpectedly.");
> +	}
> +
> +	/*
> +	 * TEST CASE 2
> +	 * set error value (999999) of pid
> +	 */
> +	TEST(sched_getattr(999999, &attr_copy, size, flags));

We have tst_get_unused_pid() that returns pid that is guaranteed not to
be used. Please us it instead.

> +	if (TEST_RETURN == -1) {
> +		if (TEST_ERRNO == ESRCH) {
> +			tst_resm(TPASS, "sched_getattr() - set error value of pid failed as expected with errno %d : %s",
> +			TEST_ERRNO,
> +			strerror(TEST_ERRNO));
> +		} else {
> +			tst_resm(TFAIL, "sched_getattr() - set error value of pid failed with errno %d : %s but expected %d (ESRCH)",
> +			TEST_ERRNO,
> +			strerror(TEST_ERRNO), ESRCH);
> +		}
> +	} else {
> +		tst_resm(TFAIL, "sched_getattr() - set error value of pid succeeded unexpectedly.");
> +	}
> +
> +	/*
> +	 * TEST CASE 3
> +	 * set error value of size
> +	 */
> +	TEST(sched_getattr(0, &attr_copy, size - 1, flags));
> +
> +	if (TEST_RETURN == -1) {
> +		if (TEST_ERRNO == EINVAL) {
> +			tst_resm(TPASS, "sched_getattr() - set error value of size failed as expected with errno %d : %s",
> +			TEST_ERRNO,
> +			strerror(TEST_ERRNO));
> +		} else {
> +			tst_resm(TFAIL, "sched_getattr() - set error value of size failed with errno %d : %s but expected %d (EINVAL)",
> +			TEST_ERRNO,
> +			strerror(TEST_ERRNO), EINVAL);
> +		}
> +	} else {
> +		tst_resm(TFAIL, "sched_getattr() - set error value of size succeeded unexpectedly.");
> +	}
> +
> +	/*
> +	 * TEST CASE 4
> +	 * set error value (10000) of flags
> +	 */
> +	TEST(sched_getattr(0, &attr_copy, size, 10000));
> +
> +	if (TEST_RETURN == -1) {
> +		if (TEST_ERRNO == EINVAL) {
> +			tst_resm(TPASS, "sched_getattr() - set error value of flags failed as expected with errno %d : %s",
> +			TEST_ERRNO,
> +			strerror(TEST_ERRNO));
> +		} else {
> +			tst_resm(TFAIL, "sched_getattr() - set error value of flags failed with errno %d : %s but expected %d (EINVAL)",
> +			TEST_ERRNO,
> +			strerror(TEST_ERRNO), EINVAL);
> +		}
> +	} else {
> +		tst_resm(TFAIL, "sched_getattr() - set error value of pid succeeded unexpectedly.");
> +	}
> +
> +	return NULL;
> +}
> +
> +int main(int argc, char **argv)
> +{
> +	pthread_t thread;
> +	int lc;
> +
> +	tst_parse_opts(argc, argv, NULL, NULL);
> +
> +	tst_require_root();
> +
> +	if ((tst_kvercmp(3, 14, 0)) < 0)
> +		tst_brkm(TCONF, NULL, "EDF needs kernel 3.14 or higher");
> +
> +	for (lc = 0; TEST_LOOPING(lc); lc++) {
> +		pthread_create(&thread, NULL, run_deadline, NULL);
> +		pthread_join(thread, NULL);
> +	}
> +
> +	tst_exit();
> +}

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v2] sched_getattr/sched_getattr02: Add new testcase for sched_getattr
  2015-10-26 15:47 ` Cyril Hrubis
@ 2015-10-28  1:40   ` Cui Bixuan
  2015-10-29 16:09     ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Cui Bixuan @ 2015-10-28  1:40 UTC (permalink / raw)
  To: ltp

Add new testcase for sched_getattr

Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
---
V2:
    * Add GPL header;
    * Define array of structures 'test_cases';
    * Use tst_get_unused_pid() to get unused pid;
    * Change some long message;
    * Add setup(),cleanup() and sched_getattr_verify();
    * Change TCID to 'sched_getattr02'

 runtest/sched                                      |    1 +
 runtest/syscalls                                   |    1 +
 .../syscalls/sched_getattr/sched_getattr02.c       |  152 ++++++++++++++++++++
 3 files changed, 154 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/syscalls/sched_getattr/sched_getattr02.c

diff --git a/runtest/sched b/runtest/sched
index 10a1648..4b8a1df 100644
--- a/runtest/sched
+++ b/runtest/sched
@@ -10,6 +10,7 @@ hackbench01 hackbench 50 process 1000
 hackbench02 hackbench 20 thread 1000

 sched_getattr01 sched_getattr01
+sched_getattr02 sched_getattr02

 sched_cli_serv run_sched_cliserv.sh
 # Run this stress test for 2 minutes
diff --git a/runtest/syscalls b/runtest/syscalls
index 958f66e..724ab66 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -923,6 +923,7 @@ sched_setaffinity01 sched_setaffinity01
 sched_getaffinity01 sched_getaffinity01

 sched_getattr01 sched_getattr01
+sched_getattr02 sched_getattr02

 select01 select01
 select02 select02
diff --git a/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
new file mode 100644
index 0000000..edb8980
--- /dev/null
+++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd., 2015
+ * 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.
+ */
+
+#define _GNU_SOURCE
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <linux/unistd.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <sys/syscall.h>
+#include <pthread.h>
+#include <sched.h>
+#include <errno.h>
+
+#include "test.h"
+#include "linux_syscall_numbers.h"
+#include "lapi/sched.h"
+
+char *TCID = "sched_getattr02";
+
+#define SCHED_DEADLINE  6
+#define RUNTIME_VAL 10000000
+#define PERIOD_VAL 30000000
+#define DEADLINE_VAL 30000000
+
+static pid_t pid;
+static pid_t unused_pid;
+struct sched_attr attr_copy;
+static unsigned int size;
+static unsigned int inval_size;
+static unsigned int flags;
+static unsigned int inval_flags = 10000;
+
+static struct test_case {
+	pid_t *pid;
+	struct sched_attr *a;
+	unsigned int *size;
+	unsigned int *flags;
+	int exp_errno;
+} test_cases[] = {
+	{&unused_pid, &attr_copy, &size, &flags, ESRCH},
+	{&pid, NULL, &size, &flags, EINVAL},
+	{&pid, &attr_copy, &inval_size, &flags, EINVAL},
+	{&pid, &attr_copy, &size, &inval_flags, EINVAL}
+};
+
+static void cleanup(void);
+static void setup(void);
+static void sched_getattr_verify(const struct test_case *test);
+
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+
+void *run_deadline(void *data LTP_ATTRIBUTE_UNUSED)
+{
+	struct sched_attr attr;
+	int ret;
+	unsigned int flags = 0;
+	int ind;
+
+	attr.size = sizeof(attr);
+	attr.sched_flags = 0;
+	attr.sched_nice = 0;
+	attr.sched_priority = 0;
+
+	/* This creates a 10ms/30ms reservation */
+	attr.sched_policy = SCHED_DEADLINE;
+	attr.sched_runtime = RUNTIME_VAL;
+	attr.sched_period = PERIOD_VAL;
+	attr.sched_deadline = DEADLINE_VAL;
+
+	ret = sched_setattr(0, &attr, flags);
+	if (ret < 0)
+		tst_brkm(TFAIL | TERRNO, NULL, "sched_setattr() failed");
+
+	for (ind = 0; ind < TST_TOTAL; ind++)
+		sched_getattr_verify(&test_cases[ind]);
+
+	return NULL;
+}
+
+static void sched_getattr_verify(const struct test_case *test)
+{
+	TEST(sched_getattr(*(test->pid), test->a, *(test->size),
+			*(test->flags)));
+
+	if (TEST_RETURN != -1) {
+		tst_resm(TFAIL, "sched_getattr() succeeded unexpectedly.");
+		return;
+	}
+
+	if (TEST_ERRNO == test->exp_errno) {
+		tst_resm(TPASS | TTERRNO,
+			"sched_getattr() returned the expected value");
+		return;
+	}
+
+	tst_resm(TFAIL | TTERRNO, "sched_getattr() got unexpected return "
+		"value: expected: %d - %s",
+		test->exp_errno, tst_strerrno(test->exp_errno));
+}
+
+int main(int argc, char **argv)
+{
+	pthread_t thread;
+	int lc;
+
+	tst_parse_opts(argc, argv, NULL, NULL);
+
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		pthread_create(&thread, NULL, run_deadline, NULL);
+		pthread_join(thread, NULL);
+	}
+
+	cleanup();
+	tst_exit();
+}
+
+void setup(void)
+{
+	pid = 0;
+	unused_pid = tst_get_unused_pid(cleanup);
+	size = sizeof(attr_copy);
+	inval_size = size - 1;
+	flags = 0;
+
+	tst_require_root();
+
+	if ((tst_kvercmp(3, 14, 0)) < 0)
+		tst_brkm(TCONF, NULL, "EDF needs kernel 3.14 or higher");
+
+	TEST_PAUSE;
+}
+
+void cleanup(void)
+{
+}
-- 
1.6.0.2 .


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

* [LTP] [PATCH v2] sched_getattr/sched_getattr02: Add new testcase for sched_getattr
  2015-10-28  1:40   ` [LTP] [PATCH v2] " Cui Bixuan
@ 2015-10-29 16:09     ` Cyril Hrubis
  2015-10-31  6:46       ` [LTP] [PATCH v3] " Cui Bixuan
  0 siblings, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2015-10-29 16:09 UTC (permalink / raw)
  To: ltp

Hi!
> +#include "test.h"
> +#include "linux_syscall_numbers.h"
> +#include "lapi/sched.h"
> +
> +char *TCID = "sched_getattr02";
> +
> +#define SCHED_DEADLINE  6
> +#define RUNTIME_VAL 10000000
> +#define PERIOD_VAL 30000000
> +#define DEADLINE_VAL 30000000
> +
> +static pid_t pid;
> +static pid_t unused_pid;
> +struct sched_attr attr_copy;
> +static unsigned int size;
> +static unsigned int inval_size;
> +static unsigned int flags;
> +static unsigned int inval_flags = 10000;
> +
> +static struct test_case {
> +	pid_t *pid;
> +	struct sched_attr *a;
> +	unsigned int *size;
> +	unsigned int *flags;
> +	int exp_errno;
> +} test_cases[] = {
> +	{&unused_pid, &attr_copy, &size, &flags, ESRCH},
> +	{&pid, NULL, &size, &flags, EINVAL},
> +	{&pid, &attr_copy, &inval_size, &flags, EINVAL},
> +	{&pid, &attr_copy, &size, &inval_flags, EINVAL}
> +};
> +
> +static void cleanup(void);
> +static void setup(void);
> +static void sched_getattr_verify(const struct test_case *test);
> +
> +int TST_TOTAL = ARRAY_SIZE(test_cases);
> +
> +void *run_deadline(void *data LTP_ATTRIBUTE_UNUSED)
> +{
> +	struct sched_attr attr;
> +	int ret;
> +	unsigned int flags = 0;
> +	int ind;
> +
> +	attr.size = sizeof(attr);
> +	attr.sched_flags = 0;
> +	attr.sched_nice = 0;
> +	attr.sched_priority = 0;
> +
> +	/* This creates a 10ms/30ms reservation */
> +	attr.sched_policy = SCHED_DEADLINE;
> +	attr.sched_runtime = RUNTIME_VAL;
> +	attr.sched_period = PERIOD_VAL;
> +	attr.sched_deadline = DEADLINE_VAL;
> +
> +	ret = sched_setattr(0, &attr, flags);
> +	if (ret < 0)
> +		tst_brkm(TFAIL | TERRNO, NULL, "sched_setattr() failed");

Hmm, do we actually have to call sched_setattr() before we try to do
sched_getattr()?

> +	for (ind = 0; ind < TST_TOTAL; ind++)
> +		sched_getattr_verify(&test_cases[ind]);

Using anything else than i as loop variable is strange.

> +	return NULL;
> +}
> +
> +static void sched_getattr_verify(const struct test_case *test)
> +{
> +	TEST(sched_getattr(*(test->pid), test->a, *(test->size),
> +			*(test->flags)));
> +
> +	if (TEST_RETURN != -1) {
> +		tst_resm(TFAIL, "sched_getattr() succeeded unexpectedly.");
> +		return;
> +	}
> +
> +	if (TEST_ERRNO == test->exp_errno) {
> +		tst_resm(TPASS | TTERRNO,
> +			"sched_getattr() returned the expected value");
                                            ^
					    "failed expectedly" would be
					    a bit better.
> +		return;
> +	}
> +
> +	tst_resm(TFAIL | TTERRNO, "sched_getattr() got unexpected return "
                                                     ^
						  "failed unexpectedly"
> +		"value: expected: %d - %s",
> +		test->exp_errno, tst_strerrno(test->exp_errno));
> +}
> +
> +int main(int argc, char **argv)
> +{
> +	pthread_t thread;
> +	int lc;
> +
> +	tst_parse_opts(argc, argv, NULL, NULL);
> +
> +	setup();
> +
> +	for (lc = 0; TEST_LOOPING(lc); lc++) {
> +		pthread_create(&thread, NULL, run_deadline, NULL);
> +		pthread_join(thread, NULL);
> +	}
> +
> +	cleanup();
> +	tst_exit();
> +}
> +
> +void setup(void)
> +{
> +	pid = 0;

Pid is global variable and therefore initialized to 0 allready.

> +	unused_pid = tst_get_unused_pid(cleanup);
> +	size = sizeof(attr_copy);
> +	inval_size = size - 1;

Both sizeof(attr_copy) and sizeof(attr_copy) - 1 are compile time
constants, you can use them directly in the structure initalizer instead
of using it indirectly here.

Also the flags can be initialized directly, no need to use pointers as
they are constant at the compile time as well.

> +	flags = 0;
> +
> +	tst_require_root();
> +
> +	if ((tst_kvercmp(3, 14, 0)) < 0)
> +		tst_brkm(TCONF, NULL, "EDF needs kernel 3.14 or higher");
> +
> +	TEST_PAUSE;
> +}
> +
> +void cleanup(void)
> +{
> +}

Do not add useless empty cleanup() function.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v3] sched_getattr/sched_getattr02: Add new testcase for sched_getattr
  2015-10-29 16:09     ` Cyril Hrubis
@ 2015-10-31  6:46       ` Cui Bixuan
  2015-11-02 17:28         ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Cui Bixuan @ 2015-10-31  6:46 UTC (permalink / raw)
  To: ltp

Add new testcase for sched_getattr

Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
---
V3:
    * Delete sched_setattr() and related parameters;
    * Change ind to i as loop variable;
    * Change "returned the expected value" to "failed expectedly";
    * Delete unnecessary initialization in setup();
    * Delete cleanup function;

V2:
    * Add GPL header;
    * Define array of structures 'test_cases';
    * Use tst_get_unused_pid() to get unused pid;
    * Change some long message;
    * Add setup(),cleanup() and sched_getattr_verify();
    * Change TCID to 'sched_getattr02'

 runtest/sched                                      |    1 +
 runtest/syscalls                                   |    1 +
 .../syscalls/sched_getattr/sched_getattr02.c       |  118 ++++++++++++++++++++
 3 files changed, 120 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/syscalls/sched_getattr/sched_getattr02.c

diff --git a/runtest/sched b/runtest/sched
index 10a1648..4b8a1df 100644
--- a/runtest/sched
+++ b/runtest/sched
@@ -10,6 +10,7 @@ hackbench01 hackbench 50 process 1000
 hackbench02 hackbench 20 thread 1000

 sched_getattr01 sched_getattr01
+sched_getattr02 sched_getattr02

 sched_cli_serv run_sched_cliserv.sh
 # Run this stress test for 2 minutes
diff --git a/runtest/syscalls b/runtest/syscalls
index 958f66e..724ab66 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -923,6 +923,7 @@ sched_setaffinity01 sched_setaffinity01
 sched_getaffinity01 sched_getaffinity01

 sched_getattr01 sched_getattr01
+sched_getattr02 sched_getattr02

 select01 select01
 select02 select02
diff --git a/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
new file mode 100644
index 0000000..f2d7764
--- /dev/null
+++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd., 2015
+ * 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.
+ */
+
+#define _GNU_SOURCE
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <linux/unistd.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <sys/syscall.h>
+#include <pthread.h>
+#include <sched.h>
+#include <errno.h>
+
+#include "test.h"
+#include "linux_syscall_numbers.h"
+#include "lapi/sched.h"
+
+char *TCID = "sched_getattr02";
+
+static pid_t pid;
+static pid_t unused_pid;
+struct sched_attr attr_copy;
+static unsigned int flags;
+static unsigned int inval_flags = 10000;
+
+static struct test_case {
+	pid_t *pid;
+	struct sched_attr *a;
+	unsigned int size;
+	unsigned int *flags;
+	int exp_errno;
+} test_cases[] = {
+	{&unused_pid, &attr_copy, sizeof(struct sched_attr), &flags, ESRCH},
+	{&pid, NULL, sizeof(struct sched_attr), &flags, EINVAL},
+	{&pid, &attr_copy, sizeof(struct sched_attr) - 1, &flags, EINVAL},
+	{&pid, &attr_copy, sizeof(struct sched_attr), &inval_flags, EINVAL}
+};
+
+static void setup(void);
+static void sched_getattr_verify(const struct test_case *test);
+
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+
+void *run_deadline(void *data LTP_ATTRIBUTE_UNUSED)
+{
+	int i;
+
+	for (i = 0; i < TST_TOTAL; i++)
+		sched_getattr_verify(&test_cases[i]);
+
+	return NULL;
+}
+
+static void sched_getattr_verify(const struct test_case *test)
+{
+	TEST(sched_getattr(*(test->pid), test->a, test->size,
+			*(test->flags)));
+
+	if (TEST_RETURN != -1) {
+		tst_resm(TFAIL, "sched_getattr() succeeded unexpectedly.");
+		return;
+	}
+
+	if (TEST_ERRNO == test->exp_errno) {
+		tst_resm(TPASS | TTERRNO,
+			"sched_getattr() failed expectedly");
+		return;
+	}
+
+	tst_resm(TFAIL | TTERRNO, "sched_getattr() failed unexpectedly "
+		": expected: %d - %s",
+		test->exp_errno, tst_strerrno(test->exp_errno));
+}
+
+int main(int argc, char **argv)
+{
+	pthread_t thread;
+	int lc;
+
+	tst_parse_opts(argc, argv, NULL, NULL);
+
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		pthread_create(&thread, NULL, run_deadline, NULL);
+		pthread_join(thread, NULL);
+	}
+
+	tst_exit();
+}
+
+void setup(void)
+{
+	unused_pid = tst_get_unused_pid(setup);
+
+	tst_require_root();
+
+	if ((tst_kvercmp(3, 14, 0)) < 0)
+		tst_brkm(TCONF, NULL, "EDF needs kernel 3.14 or higher");
+
+	TEST_PAUSE;
+}
+
-- 
1.6.0.2 .


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

* [LTP] [PATCH v3] sched_getattr/sched_getattr02: Add new testcase for sched_getattr
  2015-10-31  6:46       ` [LTP] [PATCH v3] " Cui Bixuan
@ 2015-11-02 17:28         ` Cyril Hrubis
  2015-11-03  9:22           ` [LTP] [PATCH v4] " Cui Bixuan
  2015-11-03 11:29           ` [LTP] [PATCH v5] " Cui Bixuan
  0 siblings, 2 replies; 9+ messages in thread
From: Cyril Hrubis @ 2015-11-02 17:28 UTC (permalink / raw)
  To: ltp

Hi!
> +static pid_t pid;
> +static pid_t unused_pid;
> +struct sched_attr attr_copy;
> +static unsigned int flags;
> +static unsigned int inval_flags = 10000;
> +
> +static struct test_case {
> +	pid_t *pid;
> +	struct sched_attr *a;
> +	unsigned int size;
> +	unsigned int *flags;
> +	int exp_errno;
> +} test_cases[] = {
> +	{&unused_pid, &attr_copy, sizeof(struct sched_attr), &flags, ESRCH},
> +	{&pid, NULL, sizeof(struct sched_attr), &flags, EINVAL},
> +	{&pid, &attr_copy, sizeof(struct sched_attr) - 1, &flags, EINVAL},
> +	{&pid, &attr_copy, sizeof(struct sched_attr), &inval_flags, EINVAL}

The flags are also compile time constant, so we can just initialize it
here with 0 and 10000 for invalid flags the same way as the size.

> +};
> +
> +static void setup(void);
> +static void sched_getattr_verify(const struct test_case *test);
> +
> +int TST_TOTAL = ARRAY_SIZE(test_cases);
> +
> +void *run_deadline(void *data LTP_ATTRIBUTE_UNUSED)
> +{
> +	int i;
> +
> +	for (i = 0; i < TST_TOTAL; i++)
> +		sched_getattr_verify(&test_cases[i]);
> +
> +	return NULL;
> +}
> +
> +static void sched_getattr_verify(const struct test_case *test)
> +{
> +	TEST(sched_getattr(*(test->pid), test->a, test->size,
> +			*(test->flags)));
> +
> +	if (TEST_RETURN != -1) {
> +		tst_resm(TFAIL, "sched_getattr() succeeded unexpectedly.");
> +		return;
> +	}
> +
> +	if (TEST_ERRNO == test->exp_errno) {
> +		tst_resm(TPASS | TTERRNO,
> +			"sched_getattr() failed expectedly");
> +		return;
> +	}
> +
> +	tst_resm(TFAIL | TTERRNO, "sched_getattr() failed unexpectedly "
> +		": expected: %d - %s",
> +		test->exp_errno, tst_strerrno(test->exp_errno));
> +}
> +
> +int main(int argc, char **argv)
> +{
> +	pthread_t thread;
> +	int lc;
> +
> +	tst_parse_opts(argc, argv, NULL, NULL);
> +
> +	setup();
> +
> +	for (lc = 0; TEST_LOOPING(lc); lc++) {
> +		pthread_create(&thread, NULL, run_deadline, NULL);
> +		pthread_join(thread, NULL);

And since we do not call the sched_setattr() anymore, there is no reason
to run the test in separate thread, or is it?

I would just do the for loop over the testcase here inside the
TEST_LOOPING() loop.

> +	}
> +
> +	tst_exit();
> +}

The rest looks good.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v4] sched_getattr/sched_getattr02: Add new testcase for sched_getattr
  2015-11-02 17:28         ` Cyril Hrubis
@ 2015-11-03  9:22           ` Cui Bixuan
  2015-11-03 11:29           ` [LTP] [PATCH v5] " Cui Bixuan
  1 sibling, 0 replies; 9+ messages in thread
From: Cui Bixuan @ 2015-11-03  9:22 UTC (permalink / raw)
  To: ltp

Add new testcase for sched_getattr

Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
---
V4:
    * Initialize flags in array of structures 'test_cases';
    * Delete run_deadline() and TEST_LOOPING() loop;
    * Add loop in main to call sched_getattr_verify();

V3:
    * Delete sched_setattr() and related parameters;
    * Change ind to i as loop variable;
    * Change "returned the expected value" to "failed expectedly";
    * Delete unnecessary initialization in setup();
    * Delete cleanup function;

V2:
    * Add GPL header;
    * Define array of structures 'test_cases';
    * Use tst_get_unused_pid() to get unused pid;
    * Change some long message;
    * Add setup(),cleanup() and sched_getattr_verify();
    * Change TCID to 'sched_getattr02'

 runtest/sched                                      |    1 +
 runtest/syscalls                                   |    1 +
 .../syscalls/sched_getattr/sched_getattr02.c       |  103 ++++++++++++++++++++
 3 files changed, 105 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/syscalls/sched_getattr/sched_getattr02.c

diff --git a/runtest/sched b/runtest/sched
index 10a1648..4b8a1df 100644
--- a/runtest/sched
+++ b/runtest/sched
@@ -10,6 +10,7 @@ hackbench01 hackbench 50 process 1000
 hackbench02 hackbench 20 thread 1000

 sched_getattr01 sched_getattr01
+sched_getattr02 sched_getattr02

 sched_cli_serv run_sched_cliserv.sh
 # Run this stress test for 2 minutes
diff --git a/runtest/syscalls b/runtest/syscalls
index 958f66e..724ab66 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -923,6 +923,7 @@ sched_setaffinity01 sched_setaffinity01
 sched_getaffinity01 sched_getaffinity01

 sched_getattr01 sched_getattr01
+sched_getattr02 sched_getattr02

 select01 select01
 select02 select02
diff --git a/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
new file mode 100644
index 0000000..198892b
--- /dev/null
+++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd., 2015
+ * 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.
+ */
+
+#define _GNU_SOURCE
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <linux/unistd.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <sys/syscall.h>
+#include <pthread.h>
+#include <sched.h>
+#include <errno.h>
+
+#include "test.h"
+#include "linux_syscall_numbers.h"
+#include "lapi/sched.h"
+
+char *TCID = "sched_getattr02";
+
+static pid_t pid;
+static pid_t unused_pid;
+struct sched_attr attr_copy;
+
+static struct test_case {
+	pid_t *pid;
+	struct sched_attr *a;
+	unsigned int size;
+	unsigned int flags;
+	int exp_errno;
+} test_cases[] = {
+	{&unused_pid, &attr_copy, sizeof(struct sched_attr), 0, ESRCH},
+	{&pid, NULL, sizeof(struct sched_attr), 0, EINVAL},
+	{&pid, &attr_copy, sizeof(struct sched_attr) - 1, 0, EINVAL},
+	{&pid, &attr_copy, sizeof(struct sched_attr), 1000, EINVAL}
+};
+
+static void setup(void);
+static void sched_getattr_verify(const struct test_case *test);
+
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+
+static void sched_getattr_verify(const struct test_case *test)
+{
+	TEST(sched_getattr(*(test->pid), test->a, test->size,
+			test->flags));
+
+	if (TEST_RETURN != -1) {
+		tst_resm(TFAIL, "sched_getattr() succeeded unexpectedly.");
+		return;
+	}
+
+	if (TEST_ERRNO == test->exp_errno) {
+		tst_resm(TPASS | TTERRNO,
+			"sched_getattr() failed expectedly");
+		return;
+	}
+
+	tst_resm(TFAIL | TTERRNO, "sched_getattr() failed unexpectedly "
+		": expected: %d - %s",
+		test->exp_errno, tst_strerrno(test->exp_errno));
+}
+
+int main(int argc, char **argv)
+{
+	int i;
+
+	tst_parse_opts(argc, argv, NULL, NULL);
+
+	setup();
+
+	for (i = 0; i < TST_TOTAL; i++)
+		sched_getattr_verify(&test_cases[i]);
+
+	tst_exit();
+}
+
+void setup(void)
+{
+	unused_pid = tst_get_unused_pid(setup);
+
+	tst_require_root();
+
+	if ((tst_kvercmp(3, 14, 0)) < 0)
+		tst_brkm(TCONF, NULL, "EDF needs kernel 3.14 or higher");
+
+	TEST_PAUSE;
+}
+
-- 
1.6.0.2

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

* [LTP] [PATCH v5] sched_getattr/sched_getattr02: Add new testcase for sched_getattr
  2015-11-02 17:28         ` Cyril Hrubis
  2015-11-03  9:22           ` [LTP] [PATCH v4] " Cui Bixuan
@ 2015-11-03 11:29           ` Cui Bixuan
  2015-11-03 13:21             ` Cyril Hrubis
  1 sibling, 1 reply; 9+ messages in thread
From: Cui Bixuan @ 2015-11-03 11:29 UTC (permalink / raw)
  To: ltp

Add new testcase for sched_getattr

Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
---
V5:
    * Add sched_getattr02 to testcases/kernel/syscalls/.gitignore;

V4:
    * Initialize flags in array of structures 'test_cases';
    * Delete run_deadline() and TEST_LOOPING() loop;
    * Add loop in main to call sched_getattr_verify();

V3:
    * Delete sched_setattr() and related parameters;
    * Change ind to i as loop variable;
    * Change "returned the expected value" to "failed expectedly";
    * Delete unnecessary initialization in setup();
    * Delete cleanup function;

V2:
    * Add GPL header;
    * Define array of structures 'test_cases';
    * Use tst_get_unused_pid() to get unused pid;
    * Change some long message;
    * Add setup(),cleanup() and sched_getattr_verify();
    * Change TCID to 'sched_getattr02'

 runtest/sched                                      |    1 +
 runtest/syscalls                                   |    1 +
 testcases/kernel/syscalls/.gitignore               |    1 +
 .../syscalls/sched_getattr/sched_getattr02.c       |  103 ++++++++++++++++++++
 4 files changed, 106 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/syscalls/sched_getattr/sched_getattr02.c

diff --git a/runtest/sched b/runtest/sched
index 10a1648..4b8a1df 100644
--- a/runtest/sched
+++ b/runtest/sched
@@ -10,6 +10,7 @@ hackbench01 hackbench 50 process 1000
 hackbench02 hackbench 20 thread 1000

 sched_getattr01 sched_getattr01
+sched_getattr02 sched_getattr02

 sched_cli_serv run_sched_cliserv.sh
 # Run this stress test for 2 minutes
diff --git a/runtest/syscalls b/runtest/syscalls
index 958f66e..724ab66 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -923,6 +923,7 @@ sched_setaffinity01 sched_setaffinity01
 sched_getaffinity01 sched_getaffinity01

 sched_getattr01 sched_getattr01
+sched_getattr02 sched_getattr02

 select01 select01
 select02 select02
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index 6e4894a..aba112b 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -742,6 +742,7 @@
 /sched_get_priority_min/sched_get_priority_min02
 /sched_getaffinity/sched_getaffinity01
 /sched_getattr/sched_getattr01
+/sched_getattr/sched_getattr02
 /sched_getparam/sched_getparam01
 /sched_getparam/sched_getparam02
 /sched_getparam/sched_getparam03
diff --git a/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
new file mode 100644
index 0000000..198892b
--- /dev/null
+++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd., 2015
+ * 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.
+ */
+
+#define _GNU_SOURCE
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <linux/unistd.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <sys/syscall.h>
+#include <pthread.h>
+#include <sched.h>
+#include <errno.h>
+
+#include "test.h"
+#include "linux_syscall_numbers.h"
+#include "lapi/sched.h"
+
+char *TCID = "sched_getattr02";
+
+static pid_t pid;
+static pid_t unused_pid;
+struct sched_attr attr_copy;
+
+static struct test_case {
+	pid_t *pid;
+	struct sched_attr *a;
+	unsigned int size;
+	unsigned int flags;
+	int exp_errno;
+} test_cases[] = {
+	{&unused_pid, &attr_copy, sizeof(struct sched_attr), 0, ESRCH},
+	{&pid, NULL, sizeof(struct sched_attr), 0, EINVAL},
+	{&pid, &attr_copy, sizeof(struct sched_attr) - 1, 0, EINVAL},
+	{&pid, &attr_copy, sizeof(struct sched_attr), 1000, EINVAL}
+};
+
+static void setup(void);
+static void sched_getattr_verify(const struct test_case *test);
+
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+
+static void sched_getattr_verify(const struct test_case *test)
+{
+	TEST(sched_getattr(*(test->pid), test->a, test->size,
+			test->flags));
+
+	if (TEST_RETURN != -1) {
+		tst_resm(TFAIL, "sched_getattr() succeeded unexpectedly.");
+		return;
+	}
+
+	if (TEST_ERRNO == test->exp_errno) {
+		tst_resm(TPASS | TTERRNO,
+			"sched_getattr() failed expectedly");
+		return;
+	}
+
+	tst_resm(TFAIL | TTERRNO, "sched_getattr() failed unexpectedly "
+		": expected: %d - %s",
+		test->exp_errno, tst_strerrno(test->exp_errno));
+}
+
+int main(int argc, char **argv)
+{
+	int i;
+
+	tst_parse_opts(argc, argv, NULL, NULL);
+
+	setup();
+
+	for (i = 0; i < TST_TOTAL; i++)
+		sched_getattr_verify(&test_cases[i]);
+
+	tst_exit();
+}
+
+void setup(void)
+{
+	unused_pid = tst_get_unused_pid(setup);
+
+	tst_require_root();
+
+	if ((tst_kvercmp(3, 14, 0)) < 0)
+		tst_brkm(TCONF, NULL, "EDF needs kernel 3.14 or higher");
+
+	TEST_PAUSE;
+}
+
-- 
1.6.0.2 .



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

* [LTP] [PATCH v5] sched_getattr/sched_getattr02: Add new testcase for sched_getattr
  2015-11-03 11:29           ` [LTP] [PATCH v5] " Cui Bixuan
@ 2015-11-03 13:21             ` Cyril Hrubis
  0 siblings, 0 replies; 9+ messages in thread
From: Cyril Hrubis @ 2015-11-03 13:21 UTC (permalink / raw)
  To: ltp

Hi!
> +	for (i = 0; i < TST_TOTAL; i++)
> +		sched_getattr_verify(&test_cases[i]);

I've readded the TEST_LOOPING() here, since I asked you to do this loop
inside of the TEST_LOOPING() loop, not to remove it. Once it's removed
the default test parameters does not work.

> +	tst_exit();
> +}
> +
> +void setup(void)
> +{
> +	unused_pid = tst_get_unused_pid(setup);
> +
> +	tst_require_root();

And I've removed the tst_require_root() since it's not needed as we do
not call setattr anymore.

And pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2015-11-03 13:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-20 12:59 [LTP] [PATCH] sched_getattr/sched_getattr02: Add new testcase for sched_getattr Cui Bixuan
2015-10-26 15:47 ` Cyril Hrubis
2015-10-28  1:40   ` [LTP] [PATCH v2] " Cui Bixuan
2015-10-29 16:09     ` Cyril Hrubis
2015-10-31  6:46       ` [LTP] [PATCH v3] " Cui Bixuan
2015-11-02 17:28         ` Cyril Hrubis
2015-11-03  9:22           ` [LTP] [PATCH v4] " Cui Bixuan
2015-11-03 11:29           ` [LTP] [PATCH v5] " Cui Bixuan
2015-11-03 13:21             ` Cyril Hrubis

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.