From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: rpalethorpe@suse.de
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] Rewrite process_vm01 test using new LTP API
Date: Fri, 26 Aug 2022 10:40:20 +0200 [thread overview]
Message-ID: <d64a2ccf-ee24-d4cf-17a7-bd32556a9570@suse.com> (raw)
In-Reply-To: <87bks71nwg.fsf@suse.de>
Hi!
On 8/26/22 09:04, Richard Palethorpe wrote:
> Hello,
>
> Andrea Cervesato via ltp <ltp@lists.linux.it> writes:
>
>> -static void cma_test_invalid_perm(void)
>> +static void test_invalid_perm(void)
>> {
>> char nobody_uid[] = "nobody";
>> struct passwd *ltpuser;
>> - int status;
>> struct process_vm_params *params;
>> pid_t child_pid;
>> pid_t parent_pid;
>> - int ret = 0;
>> + int status;
>> +
>> + tst_res(TINFO, "Testing invalid permissions on given PID");
>>
>> - tst_resm(TINFO, "test_invalid_perm");
>> parent_pid = getpid();
>> - child_pid = fork();
>> - switch (child_pid) {
>> - case -1:
>> - tst_brkm(TBROK | TERRNO, cleanup, "fork");
>> - break;
>> - case 0:
>> - ltpuser = getpwnam(nobody_uid);
>> - if (ltpuser == NULL)
>> - tst_brkm(TBROK | TERRNO, NULL, "getpwnam failed");
>> - SAFE_SETUID(NULL, ltpuser->pw_uid);
>> -
>> - params = cma_alloc_sane_params();
>> + child_pid = SAFE_FORK();
>> + if (!child_pid) {
>> + ltpuser = SAFE_GETPWNAM(nobody_uid);
>> + SAFE_SETUID(ltpuser->pw_uid);
>> +
>> + params = alloc_params();
>> params->pid = parent_pid;
>> - cma_test_params(params);
>> - ret |= cma_check_ret(-1, TEST_RETURN);
>> - ret |= cma_check_errno(EPERM);
>> - cma_free_params(params);
>> - exit(ret);
>> - default:
>> - SAFE_WAITPID(cleanup, child_pid, &status, 0);
>> - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
>> - tst_resm(TFAIL, "child returns %d", status);
>> + test_params(params);
>> + TST_EXP_EQ_LI(TST_RET, -1);
>> + check_errno(EPERM);
>> + free_params(params);
>> + return;
>> }
>> +
>> + SAFE_WAITPID(child_pid, &status, 0);
> We want to use tst_reap_children() here which will check the exit
> status.
>
> In fact, if SAFE_WAITPID is removed altogether then the exit status will
> be checked automatically at the end of the test when the lib calls
> reap_children.
>
> Otherwise LGTM!
>
Isn't tst_reap_childread() already called at the end of the test_all
function? (tst_test.c:1354)
Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-08-26 8:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 12:40 [LTP] [PATCH v1] Rewrite process_vm01 test using new LTP API Andrea Cervesato via ltp
2022-08-26 7:04 ` Richard Palethorpe
2022-08-26 8:40 ` Andrea Cervesato via ltp [this message]
2022-08-26 8:46 ` Andrea Cervesato via ltp
2022-08-26 8:50 ` Richard Palethorpe
2022-10-06 11:06 [LTP] [PATCH v1 0/3] Add process_madvise support Andrea Cervesato via ltp
2022-10-06 11:06 ` [LTP] [PATCH v1] Rewrite process_vm01 test using new LTP API Andrea Cervesato via ltp
2022-10-06 11:10 ` Andrea Cervesato via ltp
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=d64a2ccf-ee24-d4cf-17a7-bd32556a9570@suse.com \
--to=ltp@lists.linux.it \
--cc=andrea.cervesato@suse.com \
--cc=rpalethorpe@suse.de \
/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;
as well as URLs for NNTP newsgroup(s).