From: chrubis@suse.cz
To: Madper Xie <cxie@redhat.com>
Cc: LTP <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH v2] syscalls/fork: add new case fork14
Date: Tue, 28 Jan 2014 14:11:29 +0100 [thread overview]
Message-ID: <20140128131129.GA7102@rei> (raw)
In-Reply-To: <87vbx532pm.fsf@redhat.com>
Hi!
> +int main(int ac, char **av)
> +{
> + int lc, ret;
> + char *msg;
> +
> + msg = parse_opts(ac, av, NULL, NULL);
> + if (msg != NULL)
> + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
> +/*
> + * Tested on ppc64/x86_64/i386/s390x. And only 64bit has this issue.
> + * Since a 32bit program can't mmap so many memory.
> + */
> +#if __WORDSIZE == 32
> + tst_brkm(TCONF, NULL, "This test is only for 64bit.");
> +#endif
> + setup();
> + for (lc = 0; TEST_LOOPING(lc); lc++) {
> + tst_count = 0;
> +
> + ret = fork_test();
> + if (ret == 0)
> + tst_resm(TPASS, "fork failed as expected.");
> + }
> + cleanup();
> + tst_exit();
> +}
> +
> +static void setup(void)
> +{
> + tst_sig(FORK, DEF_HANDLER, cleanup);
> + TEST_PAUSE;
> +}
> +
> +static void cleanup(void)
> +{
> + TEST_CLEANUP;
> +}
> +
> +static int fork_test(void)
> +{
> + int i, ret = 0;
> + void *addr;
> +
> + for (i = 0; i < EXTENT; i++) {
> + addr = mmap(NULL, (size_t) 1 * GB, PROT_READ | PROT_WRITE,
^
Why do you multiply the size by 1
casted to (size_t) that does not make
much sense.
> + MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
> + if (addr == MAP_FAILED)
> + tst_brkm(TBROK|TERRNO, cleanup, "mmap");
I wonder if this should be really TBROK. This
could easily fail with ENOMEM if you turn off
memory overcommit and you machine does not have
enough RAM.
> + switch (fork()) {
> + case -1:
> + break;
> + case 0:
> + exit(0);
> + default:
> + if (waitpid(-1, NULL, 0) == -1)
> + tst_brkm(TBROK|TERRNO,
> + cleanup, "waitpid");
> +
> + if (i >= LARGE) {
> + tst_brkm(TFAIL, NULL,
> + "Fork succeeds incorrectly");
> + ret++;
> + }
> + }
> + }
> + return ret;
> +}
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable
security intelligence. It gives you real-time visual feedback on key
security issues and trends. Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
prev parent reply other threads:[~2014-01-28 13:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-27 14:43 [LTP] [PATCH v2] syscalls/fork: add new case fork14 Madper Xie
2014-01-28 13:11 ` chrubis [this message]
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=20140128131129.GA7102@rei \
--to=chrubis@suse.cz \
--cc=cxie@redhat.com \
--cc=ltp-list@lists.sourceforge.net \
/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.