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
[email protected]

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to