From: zhaogongyi via ltp <ltp@lists.linux.it>
To: "rpalethorpe@suse.de" <rpalethorpe@suse.de>
Cc: "ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] Re [PATCH] syscalls/sched_setscheduler04: new test for sched_setscheduler()
Date: Mon, 14 Nov 2022 11:13:28 +0000 [thread overview]
Message-ID: <efc489b0b94a488c9c3c1dbc438da279@huawei.com> (raw)
Hi!
> > >> > +static void test_sched_setscheduler02(void) {
> >> > + pthread_t tid;
> >> > +
> >> > + SAFE_PTHREAD_CREATE(&tid, NULL, thread_func, NULL);
> >> > + SAFE_PTHREAD_JOIN(tid, NULL);
> >> > +}
> >> > +
> >> > +
> >> > +static void run(void)
> >> > +{
> >> > + sched_prio = sched_get_priority_min(SCHED_POLICY);
> >>
> >> This can go in the setup function.
> >
> > If move it to setup function, we run the test with option "-I 200", it
> > will fail.
>
> Why?
sched_prio is a global variable, and it increase in any running loop, thus it will be out of range and report:
sched_setscheduler04.c:52: TPASS: param.sched_priority == sched_prio (99)
sched_setscheduler04.c:53: TPASS: new_policy == EXP_POLICY (1)
sched_setscheduler04.c:34: TINFO: Setting of tid: 70774
sched_setscheduler04.c:40: TBROK: sched_setscheduler(70774, 1, ...) failed: EINVAL (22)
Summary:
passed 196
failed 0
broken 1
skipped 0
warnings 0
> >
> >>
> >> > +
> >> > + test_sched_setscheduler01();
> >> > + test_sched_setscheduler02();
> >>
> >> This should be replaced with .tcnt = 2 and .test. or else just merge
> >> them into run.
> >
> > Agree, I will fix it int the next version.
> >
> >>
> >> > +}
> >> > +
> >> > +static struct tst_test test = {
> >> > + .test_all = run,
> >>
> >> We probably need to ensure CAP_SYS_NICE. Full details are in 'man 7
> >> sched'
> >>
> >> i.e. .caps = (struct tst_cap[]) {
> >> TST_CAP(TST_CAP_REQ, CAP_SYS_NICE),
> >> null
> >> }
> >>
> >
> > In this testcase, we just increase the priority, should we add the checking
> of capability?
>
> For the test to run we need CAP_SYS_NICE. If you want to test that the
> priority can only be set when CAP_SYS_NICE is available, then that is a
> seperate test in my opinion.
Anybody can call nice() to increase the priority, i have test it with normal user and passed.
And if decrease the priority, the test will report EPERM when running with normal user.
Regards,
Gongyi
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2022-11-14 11:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-14 11:13 zhaogongyi via ltp [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-11-16 2:23 [LTP] Re [PATCH] syscalls/sched_setscheduler04: new test for sched_setscheduler() zhaogongyi via ltp
2022-11-14 6:27 zhaogongyi via ltp
2022-11-14 10:34 ` Richard Palethorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=efc489b0b94a488c9c3c1dbc438da279@huawei.com \
--to=ltp@lists.linux.it \
--cc=rpalethorpe@suse.de \
--cc=zhaogongyi@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox