[email protected] writes:

> 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.
                        will remove it
>
>> +                    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.
Yeah you're right. I'd change it to TCONF as it doesn't work on systems
with low RAM. Please review V3.

Thanks.
>
>> +            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;
>> +}

-- 
Sent with my mu4e


------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to