[CRIU] [PATCH] zdtm/stopped: fix stopped test
Andrew Vagin
avagin at parallels.com
Wed Oct 8 04:28:56 PDT 2014
Acked-by: Andrew Vagin <avagin at parallels.com>
On Wed, Oct 08, 2014 at 10:13:13AM +0400, Konstantin Neumoin wrote:
> On Tue, 2014-10-07 at 16:51 +0400, Andrew Vagin wrote:
> > On Tue, Oct 07, 2014 at 03:28:30PM +0400, Konstantin Neumoin wrote:
> > > The main problem with the
> > > test that it's never 'fail'.
> > > Test can only 'pass' or hangs.
> > >
> > > Signed-off-by: Konstantin Neumoin <kneumoin at parallels.com>
> > > ---
> > > test/zdtm/live/static/stopped.c | 29 ++++++++++++++++++-----------
> > > 1 file changed, 18 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/test/zdtm/live/static/stopped.c b/test/zdtm/live/static/stopped.c
> > > index 6194d6b..b74b7ff 100644
> > > --- a/test/zdtm/live/static/stopped.c
> > > +++ b/test/zdtm/live/static/stopped.c
> > > @@ -33,35 +33,42 @@ int main(int argc, char **argv)
> > > return 1;
> > > }
> > >
> > > - ret = read(p[0], &c, 1);
> > > - if (ret != 0) {
> > > - err("Unable to read: %d", ret);
> > > - return 1;
> > > - }
> > > -
> > > return 0;
> > > }
> > > close(p[0]);
> > >
> > > kill(pid, SIGSTOP);
> > > +
> > > write(p[1], "0", 1);
> > > + close(p[1]);
> > >
> > > test_daemon();
> > > test_waitsig();
> > >
> > > + // Return immediately if child run or stopped(by SIGSTOP)
> > > + if (waitpid(pid, &status, WUNTRACED | WCONTINUED) == -1) {
> >
> > it doesn't return if a child is running.
> >
> > import os, time, sys, signal
> >
> > pid = os.fork()
> > if pid == 0:
> > time.sleep(5)
> > sys.exit(0)
> > pid, status = os.waitpid(pid, os.WCONTINUED | os.WUNTRACED)
> > os.kill(pid, signal.SIGKILL);
> > print pid, status
> >
>
> It's actually does.
> As you can see in your example it's not a big deal to wait
> a children which have to finish in near time(after sleep timeout or
> after read from pipe).
> In old test implementation test 'hangs' if SIGCONT was sent to not
> stopped children(it's what we try to check), so test never finish.
>
> In my implementation tests can finish if children - running or stopped
> after resume, also we check process state directly as STOPPED(in
> difference STOP CONTINUED).
>
> >
> > > + err("Unable to wait child");
> > > + goto out;
> > > + }
> > > +
> > > + if (WIFSTOPPED(status))
> > > + test_msg("The procces stopped\n");
> > > + else{
> > > + fail("The process doesn't stopped");
> > > + goto out;
> > > + }
> > > +
> > > kill(pid, SIGCONT);
> > > - if (waitpid(pid, &status, WCONTINUED) == -1) {
> > > +
> > > + if (waitpid(pid, &status, 0) == -1) {
> > > err("Unable to wait child");
> > > goto out;
> > > }
> > >
> > > - if (WIFCONTINUED(status))
> > > + if (WIFEXITED(status))
> > > pass();
> > > else
> > > fail("The process doesn't continue");
> > > out:
> > > - close(p[1]);
> > > - waitpid(pid, &status, 0);
> > > -
> > > return 0;
> > > }
> > > --
> > > 1.7.11.7
> > >
>
>
More information about the CRIU
mailing list