All of lore.kernel.org
 help / color / mirror / Atom feed
From: ruansy.fnst@fujitsu.com <ruansy.fnst@fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] 回复:  [PATCH 1/2] syscalls/getpid01: Convert to new API
Date: Thu, 25 Feb 2021 02:11:12 +0000	[thread overview]
Message-ID: <OSBPR01MB2920DF74B48CA7A680A03257F49E9@OSBPR01MB2920.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <YDYqZMYBVfh8oiYH@yuki.lan>

> Hi!
> > +static void verify_getpid(void)
> >  {
> > +     TEST(getpid());
> > 
> > -     tst_sig(NOFORK, DEF_HANDLER, cleanup);
> > -
> > -     TEST_PAUSE;
> > +     if (TST_RET == -1)
> > +             tst_res(TFAIL | TTERRNO, "getpid()");
> > +     else
> > +             tst_res(TPASS, "getpid() returns %ld", TST_RET);
>
> The POSIX actually mandates that getpid() cannot fail and is always
> successful. Given that this test seems to be useless and could be
> removed or replaced with something more sane.
>
> I guess that what we can do is to check if the return value from
> getpid() is greater than 1, since pid 1 is special no other process than
> init can have pid == 1. And the value has to be smaller or equal to
> /proc/sys/kernel/pid_max as well.
>
> So what would I do here would be:
>
> * read /proc/sys/kernel/pid_max value
> * loop 100 times or so
>   - fork a child
>   - check that the pid in child is > 1 and <= pid_max

Do you mean loop 100 times to fork 100 children processes?  I tried in this
way and found that the pid number just increased sequentially from +0 to +100
(Because no other processes were created during the test).  So, I am not sure
if 100 times is enough to test the range?


--
Thanks,
Ruan Shiyang.

>
> --
> Cyril Hrubis
> chrubis@suse.cz

  reply	other threads:[~2021-02-25  2:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24  3:12 [LTP] [PATCH 1/2] syscalls/getpid01: Convert to new API Shiyang Ruan
2021-02-24  3:12 ` [LTP] [PATCH 2/2] syscalls/getpid02: " Shiyang Ruan
2021-02-24 10:33   ` Cyril Hrubis
2021-02-24 10:28 ` [LTP] [PATCH 1/2] syscalls/getpid01: " Cyril Hrubis
2021-02-25  2:11   ` ruansy.fnst [this message]
2021-02-25 10:30     ` [LTP] ????: " Cyril Hrubis

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=OSBPR01MB2920DF74B48CA7A680A03257F49E9@OSBPR01MB2920.jpnprd01.prod.outlook.com \
    --to=ruansy.fnst@fujitsu.com \
    --cc=ltp@lists.linux.it \
    /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 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.