diff mbox series

selftests: sched: Add more core schedule prctl calls

Message ID 20230322203724.4757-1-ivan.orlov0322@gmail.com (mailing list archive)
State New
Headers show
Series selftests: sched: Add more core schedule prctl calls | expand

Commit Message

Ivan Orlov March 22, 2023, 8:37 p.m. UTC
The core sched kselftest makes prctl calls only with correct
parameters. This patch will extend this test with more core
schedule prctl calls with wrong parameters to increase code
coverage.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
---
 tools/testing/selftests/sched/cs_prctl_test.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Shuah Khan March 27, 2023, 7:55 p.m. UTC | #1
Hi Ivan,

On 3/22/23 14:37, Ivan Orlov wrote:
> The core sched kselftest makes prctl calls only with correct
> parameters. This patch will extend this test with more core
> schedule prctl calls with wrong parameters to increase code
> coverage.
> 
> Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>

Thank you for the patch.

> ---
>   tools/testing/selftests/sched/cs_prctl_test.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c
> index 25e0d95d3713..df8e4629b3b5 100644
> --- a/tools/testing/selftests/sched/cs_prctl_test.c
> +++ b/tools/testing/selftests/sched/cs_prctl_test.c
> @@ -334,6 +334,14 @@ int main(int argc, char *argv[])
>   	validate(get_cs_cookie(pid) != 0);
>   	validate(get_cs_cookie(pid) == get_cs_cookie(procs[pidx].thr_tids[0]));
>   
> +	printf("\n## Try to pass wrong subcommand PR_SCHED_CORE_MAX = %d to prctl (shouldn't succeed)\n", PR_SCHED_CORE_MAX);

This message is unnecessary. validate() prints an error message.

> +	validate(_prctl(PR_SCHED_CORE, PR_SCHED_CORE_MAX, 0, PIDTYPE_PGID, 0) < 0
> +		&& errno == EINVAL);
> +
> +	printf("\n## Try to pass not-null uaddr with forbidden command (shouldn't succeed)\n");

Same here.

> +	validate(_prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_TO, 0, PIDTYPE_PGID, 1) < 0
> +		&& errno == EINVAL);
> +
>   	if (errors) {
>   		printf("TESTS FAILED. errors: %d\n", errors);
>   		res = 10;

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c
index 25e0d95d3713..df8e4629b3b5 100644
--- a/tools/testing/selftests/sched/cs_prctl_test.c
+++ b/tools/testing/selftests/sched/cs_prctl_test.c
@@ -334,6 +334,14 @@  int main(int argc, char *argv[])
 	validate(get_cs_cookie(pid) != 0);
 	validate(get_cs_cookie(pid) == get_cs_cookie(procs[pidx].thr_tids[0]));
 
+	printf("\n## Try to pass wrong subcommand PR_SCHED_CORE_MAX = %d to prctl (shouldn't succeed)\n", PR_SCHED_CORE_MAX);
+	validate(_prctl(PR_SCHED_CORE, PR_SCHED_CORE_MAX, 0, PIDTYPE_PGID, 0) < 0
+		&& errno == EINVAL);
+
+	printf("\n## Try to pass not-null uaddr with forbidden command (shouldn't succeed)\n");
+	validate(_prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_TO, 0, PIDTYPE_PGID, 1) < 0
+		&& errno == EINVAL);
+
 	if (errors) {
 		printf("TESTS FAILED. errors: %d\n", errors);
 		res = 10;