From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 3/3 v2] getrusage: Cleanup and bugfix for getrusage03
Date: Fri, 18 Jun 2021 14:20:22 +0200 [thread overview]
Message-ID: <YMyPhiiKwuwEdj7N@yuki> (raw)
In-Reply-To: <20210617105556.130869-4-xieziyao@huawei.com>
Hi!
> static void sig_ign(void)
> {
> - tst_resm(TINFO, "Testcase #06: SIG_IGN");
> -
> - SAFE_GETRUSAGE(cleanup, RUSAGE_CHILDREN, &ru);
> - tst_resm(TINFO, "initial.children = %ld", ru.ru_maxrss);
> - signal(SIGCHLD, SIG_IGN);
> + SAFE_SIGNAL(SIGCHLD, SIG_IGN);
> + SAFE_GETRUSAGE(RUSAGE_CHILDREN, &ru);
> maxrss_init = ru.ru_maxrss;
>
> - switch (pid = fork()) {
> - case -1:
> - tst_brkm(TBROK, cleanup, "fork #6");
> - case 0:
> - retval = system("getrusage03_child -n 500");
> - if ((WIFEXITED(retval) && WEXITSTATUS(retval) != 0))
> - tst_brkm(TBROK | TERRNO, cleanup, "system");
> - exit(0);
> - default:
> - break;
> - }
> + pid_t pid = SAFE_FORK();
> +
> + if (!pid)
> + SAFE_EXECLP("getrusage03_child", "getrusage03_child",
> + "consume", "500", NULL);
>
> - sleep(1); /* children become zombie */
> - SAFE_GETRUSAGE(cleanup, RUSAGE_CHILDREN, &ru);
> - tst_resm(TINFO, "after_zombie.children = %ld", ru.ru_maxrss);
> + TST_PROCESS_EXIT_WAIT(pid, 0);
> + SAFE_GETRUSAGE(RUSAGE_CHILDREN, &ru);
> if (is_in_delta(ru.ru_maxrss - maxrss_init))
> - tst_resm(TPASS, "initial.children ~= after_zombie.children");
> + tst_res(TPASS, "initial.children ~= after_zombie.children");
> else
> - tst_resm(TFAIL, "initial.children !~= after_zombie.children");
> - signal(SIGCHLD, SIG_DFL);
> -}
> + tst_res(TFAIL, "after_zombie.children = %li, expected %li",
> + ru.ru_maxrss, maxrss_init);
I guess that these messages could be better, techincally it's not a
zombie but rather ignored child, so I would change this to:
"initial.children ~= ignored_child.children"
Other than this the rest is good.
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Also if you agree I can fix the two minor issues in the patchset before
merge, no need to send v3.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2021-06-18 12:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-17 10:55 [LTP] [PATCH 0/3 v2] Cleanup and bugfix for getrusage03 Xie Ziyao
2021-06-17 10:55 ` [LTP] [PATCH 1/3 v2] lib: tst_process_state: Use SPDX and format alignment Xie Ziyao
2021-06-18 11:46 ` Cyril Hrubis
2021-06-17 10:55 ` [LTP] [PATCH 2/3 v2] lib: tst_process_state: Add tst_process_exit_wait() Xie Ziyao
2021-06-18 11:53 ` Cyril Hrubis
2021-06-17 10:55 ` [LTP] [PATCH 3/3 v2] getrusage: Cleanup and bugfix for getrusage03 Xie Ziyao
2021-06-18 12:20 ` Cyril Hrubis [this message]
2021-06-18 13:16 ` xieziyao
2021-06-18 18:04 ` 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=YMyPhiiKwuwEdj7N@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 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.