public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1 1/2] Refactor getegid01 using new LTP API
Date: Thu, 31 Aug 2023 15:32:09 +0200	[thread overview]
Message-ID: <ZPCWWXXHG-oEB5qO@yuki> (raw)
In-Reply-To: <20230831104242.27156-2-andrea.cervesato@suse.de>

Hi!
> +	gid_t gid;
> +	gid_t st_gid, st_egid;
>  
> -		if (TEST_RETURN == -1) {
> -			tst_resm(TFAIL | TTERRNO, "getegid failed");
> -			continue;	/* next loop for MTKERNEL */
> -		}
> +	SAFE_FILE_LINES_SCANF("/proc/self/status", "Gid: %d %d", &st_gid, &st_egid);

Hint: You can use assignment suppresion '*' in order to get rid of the
      dummy st_gid variable.

> -		tst_resm(TPASS, "getegid returned %ld", TEST_RETURN);
> -	}
> -
> -	cleanup();
> -	tst_exit();
> -}
> -
> -static void setup(void)
> -{
> -	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> -	TEST_PAUSE;
> +	GID16_CHECK((gid = GETEGID()), "getegid");

And this does not work at all.

The GID16_CHECK() is for the case where we have GID that is 32bit and we
want to check if the value fits into 16bit. In this case we get 16bit
value from the sycall, so the check will always be true.

Also the check only returns value, which we ingore here, so this isn't
doing anything at all.

What we need to do instead is to check the gid from /proc/ that is 32bit
if it fits into 16bit (in the case of the 16bit syscall) and skip the
comparsion below.

> +	TST_EXP_EQ_LI(gid, st_egid);

So the code here should really do:

	if (GID16_CHECK(st_egid))
		TST_EXP_EQ_LI(gid, st_egid);
	else
		tst_res(TPASS, "getgid() passed");

Which skips the check on 16bit syscall in the case that the GID
overflows 16bit, however we still have to report at least single TPASS
otherwise the test will be failed by the test library.

>  }
>  
> -static void cleanup(void)
> -{
> -}
> +static struct tst_test test = {
> +	.test_all = run,
> +};
> -- 
> 2.35.3
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2023-08-31 13:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31 10:42 [LTP] [PATCH v1 0/2] Refactor getegid testing suite Andrea Cervesato
2023-08-31 10:42 ` [LTP] [PATCH v1 1/2] Refactor getegid01 using new LTP API Andrea Cervesato
2023-08-31 13:32   ` Cyril Hrubis [this message]
2023-09-01 11:46     ` Andrea Cervesato via ltp
2023-09-01 12:21       ` Cyril Hrubis
2023-09-01 11:57     ` Andrea Cervesato via ltp
2023-09-01 12:22       ` Cyril Hrubis
2023-09-01 12:47         ` Andrea Cervesato via ltp
2023-08-31 10:42 ` [LTP] [PATCH v1 2/2] Refactor getegid02 " Andrea Cervesato
2023-09-08  9:37   ` Richard Palethorpe
2023-09-08 10:25     ` 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=ZPCWWXXHG-oEB5qO@yuki \
    --to=chrubis@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox