From: Cyril Hrubis <chrubis@suse.cz>
To: Yang Xu <xuyang2018.jy@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 2/3] syscalls/setgroups02: Convert to new API
Date: Mon, 7 Aug 2023 15:13:28 +0200 [thread overview]
Message-ID: <ZNDt-PogUzCebHSl@yuki> (raw)
In-Reply-To: <1690888046-18662-2-git-send-email-xuyang2018.jy@fujitsu.com>
Hi!
> +static GID_T groups_get[NGROUPS];
> +static GID_T groups_set[NGROUPS];
Since you are using the guarded buffers these two has to be just
pointers, i.e.
static GID_T *groups_get;
> -/*
> - * setup() - performs all ONE TIME setup for this test.
> - *
> - * Make sure the test process uid is root.
> - * Get the supplimentrary group id of test user from /etc/passwd file.
> - */
> -void setup(void)
> +static void verify_setgroups(void)
> {
> + int gidsetsize = 1;
There is no point in passing the value via variable, we can as well pass
1 directly to the getgroups/setgroups calls.
> - tst_require_root();
> -
> - tst_sig(NOFORK, DEF_HANDLER, cleanup);
> + groups_set[0] = 42;
We have to clear the groups_get[0] here as well, in the case that we are
looping with the -i parameter, i.e.
groups_get[0] = 0;
> - TEST_PAUSE;
> + TST_EXP_PASS(SETGROUPS(gidsetsize, groups_set));
>
> - /* Get the group id info. of TESTUSER from /etc/passwd */
> - if ((user_info = getpwnam(TESTUSER)) == NULL) {
> - tst_brkm(TFAIL, cleanup, "getpwnam(2) of %s Failed", TESTUSER);
> - }
> + TST_EXP_VAL(GETGROUPS(gidsetsize, groups_get), 1);
>
> - if (!GID_SIZE_CHECK(user_info->pw_gid)) {
> - tst_brkm(TBROK,
> - cleanup,
> - "gid returned from getpwnam is too large for testing setgroups16");
> - }
> -
> - groups_list[0] = user_info->pw_gid;
> + TST_EXP_EQ_LI(groups_get[0], groups_set[0]);
> }
>
> -/*
> - * cleanup() - performs all ONE TIME cleanup for this test at
> - * completion or premature exit.
> - */
> -void cleanup(void)
> -{
> -
> -}
> +static struct tst_test test = {
> + .test_all = verify_setgroups,
> + .bufs = (struct tst_buffers []) {
> + {&groups_get, .size = sizeof(groups_get)},
> + {&groups_set, .size = sizeof(groups_set)},
^
Since we are using arrays of
size 1 with elements of a size
GID_T this should be just
sizeof(GID_T)
If it was array of size 2 it would have been 2 * sizeof(GID_T) etc.
The rest of the changes looks good.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-08-07 13:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 11:07 [LTP] [PATCH v2 1/3] syscalls/setgroups01: Convert to new API Yang Xu
2023-08-01 11:07 ` [LTP] [PATCH v2 2/3] syscalls/setgroups02: " Yang Xu
2023-08-07 13:13 ` Cyril Hrubis [this message]
2023-08-14 11:18 ` Yang Xu (Fujitsu)
2023-08-01 11:07 ` [LTP] [PATCH v2 3/3] syscalls/setgroups03: " Yang Xu
2023-08-07 15:28 ` Cyril Hrubis
2023-08-14 11:21 ` Yang Xu (Fujitsu)
2023-08-07 12:30 ` [LTP] [PATCH v2 1/3] syscalls/setgroups01: " Cyril Hrubis
2023-08-14 11:22 ` Yang Xu (Fujitsu)
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=ZNDt-PogUzCebHSl@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=xuyang2018.jy@fujitsu.com \
/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.