From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 5/7] syscalls/clone05: Convert to new API
Date: Wed, 25 Aug 2021 16:28:47 +0200 [thread overview]
Message-ID: <YSZTn5KKmOgFINNX@yuki> (raw)
In-Reply-To: <20210813072657.21976-1-zhanglianjie@uniontech.com>
Hi!
> static int child_exited = 0;
^
This should be volatile to avoid compiler miscompilation,
also there is no point in setting it to 0 either, it's
global variable and these are initialized to zero
regardless.
> +static void *child_stack;
>
> -int main(int ac, char **av)
> +static int child_fn(void *unused __attribute__((unused)))
> {
> + int i;
>
> - int lc, status;
> - void *child_stack;
> -
> - tst_parse_opts(ac, av, NULL, NULL);
> -
> - setup();
> -
> - child_stack = malloc(CHILD_STACK_SIZE);
> - if (child_stack == NULL)
> - tst_brkm(TBROK, cleanup, "Cannot allocate stack for child");
> -
> - for (lc = 0; TEST_LOOPING(lc); lc++) {
> - tst_count = 0;
> -
> - TEST(ltp_clone(CLONE_VM | CLONE_VFORK | SIGCHLD, child_fn, NULL,
> - CHILD_STACK_SIZE, child_stack));
> -
> - if ((TEST_RETURN != -1) && (child_exited))
> - tst_resm(TPASS, "Test Passed");
> - else
> - tst_resm(TFAIL, "Test Failed");
> + for (i = 0; i < 100; i++) {
> + sched_yield();
> + usleep(1000);
> + }
>
> - if ((wait(&status)) == -1)
> - tst_brkm(TBROK | TERRNO, cleanup,
> - "wait failed, status: %d", status);
> + child_exited = 1;
> + _exit(0);
> +}
>
> - child_exited = 0;
> - }
> +static void verify_clone(void)
> +{
> + TST_EXP_POSITIVE(ltp_clone(CLONE_VM | CLONE_VFORK | SIGCHLD, child_fn, NULL,
> + CHILD_STACK_SIZE, child_stack), "clone with vfork");
>
> - free(child_stack);
> + if (!TST_PASS)
> + return;
>
> - cleanup();
> - tst_exit();
> + TST_EXP_PASS(!child_exited);
This is misuse of the macro, since the macro checks for -1 on failure
and we will get 1 on failure here.
I guess that we should add TST_EXP_VAL() instead for cases like this and
we would do:
TST_EXP_VAL(child_exited, 1);
Will you send a patch or should I add it?
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2021-08-25 14:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-13 7:26 [LTP] [PATCH 5/7] syscalls/clone05: Convert to new API zhanglianjie
2021-08-25 14:28 ` Cyril Hrubis [this message]
2021-08-26 11:10 ` zhanglianjie
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=YSZTn5KKmOgFINNX@yuki \
--to=chrubis@suse.cz \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox