From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v4] Rewrite userns06.c using new LTP API
Date: Mon, 4 Apr 2022 12:33:33 +0200 [thread overview]
Message-ID: <YkrJfb0vZq6WSZmX@pevik> (raw)
In-Reply-To: <20220401050804.1286-1-andrea.cervesato@suse.de>
Hi Andrea,
BTW it'd help reviewers a bit if you include a changelog.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
TL;DR: TST_TEST_TCONF() in userns06_capcheck.c
> diff --git a/testcases/kernel/containers/userns/userns06_capcheck.c b/testcases/kernel/containers/userns/userns06_capcheck.c
...
> -/*
> - * Verify that:
> +/*\
> + * [Description]
> + *
> * When a process with non-zero user IDs performs an execve(), the
> * process's capability sets are cleared. When a process with zero
> * user IDs performs an execve(), the process's capability sets
> * are set.
> */
nit: I wonder if we want to have docparse documentation in both userns06.c and
userns06_capcheck.c, they now look as 2 separate tests. Maybe describe
everything in userns06.c.
> +#define TST_NO_DEFAULT_MAIN
> +#include "tst_test.h"
> +#include "config.h"
> +
> +#ifdef HAVE_LIBCAP
...
> + if (argc < 2)
> + tst_brk(TBROK, "userns06_capcheck <privileged|unprivileged>");
> +
> + tst_reinit();
I'm not sure if tst_reinit() shouldn't be called even before tst_brk(TBROK, ...).
> +
> + SAFE_FILE_SCANF("/proc/sys/kernel/cap_last_cap", "%d", &last_cap);
> +
> if (strcmp("privileged", argv[1]))
> expected_flag = 0;
nit: It might help debugging to print argv[1] in TINF0.
> caps = cap_get_proc();
> - SAFE_FILE_SCANF(NULL, "/proc/sys/kernel/cap_last_cap", "%d", &last_cap);
> +
> for (i = 0; i <= last_cap; i++) {
> cap_get_flag(caps, i, CAP_EFFECTIVE, &flag_val);
> if (flag_val != expected_flag)
> break;
> +
> cap_get_flag(caps, i, CAP_PERMITTED, &flag_val);
> if (flag_val != expected_flag)
> break;
> }
> - if (flag_val != expected_flag) {
> - printf("unexpected effective/permitted caps at %d\n", i);
> - exit(1);
> - }
> + if (flag_val != expected_flag)
> + tst_res(TFAIL, "unexpected effective/permitted caps at %d", i);
The flags are CAP_EFFECTIVE and CAP_PERMITTED only here, right?
(i.e. no CAP_INHERITABLE). Not sure how helpful would be to print here which
flag was the failing one.
> + else
> + tst_res(TPASS, "expected caps at %d", i);
> +}
> #else
> - printf("System is missing libcap.\n");
> -#endif
> - tst_exit();
> +int main(void)
> +{
> + tst_brk(TBROK, "System is missing libcap");
> }
Why don't you also use TST_TEST_TCONF() here?
> +#endif
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-04-04 10:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 5:08 [LTP] [PATCH v4] Rewrite userns06.c using new LTP API Andrea Cervesato
2022-04-04 10:33 ` Petr Vorel [this message]
2022-04-04 10:52 ` Andrea Cervesato via ltp
2022-04-04 12:55 ` Petr Vorel
2022-04-19 7:22 ` Petr Vorel
2022-04-19 7:36 ` Andrea Cervesato via ltp
2022-04-19 12:16 ` Cyril Hrubis
-- strict thread matches above, loose matches on Subject: below --
2022-04-26 8:47 Andrea Cervesato
2022-04-26 13:57 ` 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=YkrJfb0vZq6WSZmX@pevik \
--to=pvorel@suse.cz \
--cc=andrea.cervesato@suse.de \
--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.