selftests: sched: Add more core schedule prctl calls
PATCH 1/1 selftests: sched: Add more core schedule prctl calls
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.
--- tools/testing/selftests/sched/cs_prctl_test.c | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/testing/selftests/sched/cs_prctl_test.c +8 -0
@@ -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 ;
Signature · 6 lines
2.34.1 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Shuah Khan
maintainerHi Ivan,
Quoted 6 lines · Ivan Orlov
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 <[email protected]>
Thank you for the patch.
tools/testing/selftests/sched/cs_prctl_test.c int main(int argc, char *argv[]) · line 337
Quoted 13 lines
--- tools/testing/selftests/sched/cs_prctl_test.c | 8 ++++++++ 1 file changed, 8 insertions(+)tools/testing/selftests/sched/cs_prctl_test.c +1
-0@@ -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.
tools/testing/selftests/sched/cs_prctl_test.c int main(int argc, char *argv[]) · line 341
Quoted 4 lines
tools/testing/selftests/sched/cs_prctl_test.c +4
-0+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.
tools/testing/selftests/sched/cs_prctl_test.c int main(int argc, char *argv[]) · line 347
Quoted 6 lines
tools/testing/selftests/sched/cs_prctl_test.c +3
-0+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