All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Yang Xu <xuyang2018.jy@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 1/3] syscalls/setgroups01: Convert to new API
Date: Mon, 7 Aug 2023 14:30:34 +0200	[thread overview]
Message-ID: <ZNDj6o3UViMIbvkT@yuki> (raw)
In-Reply-To: <1690888046-18662-1-git-send-email-xuyang2018.jy@fujitsu.com>

Hi!
> -#include <errno.h>
> -#include <string.h>
> -#include <signal.h>
> -#include <sys/param.h>
> -#include <unistd.h>
> -#include <grp.h>
> -
> -#include "test.h"
> -
> -#include "compat_16.h"
> +/*\
> + * [Description]
> + *
> + * Check the basic functionality of the setgroups() system call.
> + */
>  
> -void setup();
> -void cleanup();
> +#include "tst_test.h"
> +#include "compat_tst_16.h"
>  
> -TCID_DEFINE(setgroups01);
> -int TST_TOTAL = 1;
> +static int len = NGROUPS, ngrps;
>  
> -int len = NGROUPS, ngrps = 0;
> -GID_T list[NGROUPS];
> +static GID_T list[NGROUPS];
>  
> -int main(int ac, char **av)
> +static void verify_setgroups(void)
>  {
> -	int lc;
> -
> -    /***************************************************************
> -     * parse standard options
> -     ***************************************************************/
> -	tst_parse_opts(ac, av, NULL, NULL);
> -
> -    /***************************************************************
> -     * perform global setup for test
> -     ***************************************************************/
> -	setup();
> -
> -    /***************************************************************
> -     * check looping state if -c option given
> -     ***************************************************************/
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
> -		tst_count = 0;
> -
> -		/*
> -		 * Call setgroups(2)
> -		 */
> -		TEST(SETGROUPS(cleanup, ngrps, list));
> -
> -		/* check return code */
> -		if (TEST_RETURN == -1) {
> -			tst_resm(TFAIL,
> -				 "setgroups(%d, list) Failed, errno=%d : %s",
> -				 len, TEST_ERRNO, strerror(TEST_ERRNO));
> -		} else {
> -			tst_resm(TPASS,
> -				 "setgroups(%d, list) returned %ld",
> -				 len, TEST_RETURN);
> -		}
> -
> -	}
> -
> -	cleanup();
> -	tst_exit();
> +	TST_EXP_POSITIVE(SETGROUPS(ngrps, list),
> +			 "setgroups(%d, list)", len);
>  }
>  
> -/***************************************************************
> - * setup() - performs all ONE TIME setup for this test.
> - ***************************************************************/
> -void setup(void)
> +static void setup(void)
>  {
> -
> -	tst_require_root();
> -
> -	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> -
> -	TEST_PAUSE;
> -
> -	ngrps = GETGROUPS(cleanup, len, list);
> -	if (ngrps == -1) {
> -		tst_brkm(TBROK, cleanup,
> -			 "getgroups(%d, list) Failure. errno=%d : %s",
> -			 len, errno, strerror(errno));
> +	if (GETGROUPS(len, list) < 0) {
> +		tst_brk(TBROK,
> +			"getgroups(%d, list) Failure. errno=%d : %s",
> +			len, errno, strerror(errno));
                             ^
			     use TERRNO instead of printing the values
			     by hand


>  	}

Also after this change the ngrps is no loger set and we pass 0 as the
number of groups to the setgroups call.


The rest of the changes looks good.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2023-08-07 12:29 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
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 ` Cyril Hrubis [this message]
2023-08-14 11:22   ` [LTP] [PATCH v2 1/3] syscalls/setgroups01: " 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=ZNDj6o3UViMIbvkT@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.