All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 03/10] getrusage02: Convert getrusage02 to new API
Date: Fri, 11 Jun 2021 15:49:38 +0200	[thread overview]
Message-ID: <YMNp8tAdF1usM1LM@yuki> (raw)
In-Reply-To: <20210609173601.29352-3-vinay.m.engg@gmail.com>

Hi!
>  #ifndef RUSAGE_BOTH		/* Removed from user space on RHEL4 */
>  #define RUSAGE_BOTH (-2)	/* still works on SuSE      */
>  #endif /* so this is a work around */

This is used as invalid value here, so this whole part looks wrong.

Can we just place -2 in the testcases structure instead?

> -static void setup();
> -static void cleanup();
> -
> -char *TCID = "getrusage02";
> -
>  static struct rusage usage;
>  
>  struct test_cases_t {
> @@ -90,56 +33,25 @@ struct test_cases_t {
>  } test_cases[] = {
>  	{
>  	RUSAGE_BOTH, &usage, EINVAL},
> -#ifndef UCLINUX
>  	{
>  	RUSAGE_SELF, (struct rusage *)-1, EFAULT}
> -#endif
>  };
>  
> -int TST_TOTAL = ARRAY_SIZE(test_cases);
> -
> -int main(int ac, char **av)
> +static void verify_getrusage(unsigned int i)
>  {
> -
> -	int lc, i;
> -
> -	tst_parse_opts(ac, av, NULL, NULL);
> -
> -	setup();
> -
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
> -		tst_count = 0;
> -
> -		for (i = 0; i < TST_TOTAL; i++) {
> -			TEST(getrusage(test_cases[i].who, test_cases[i].usage));
> -
> -			if (TEST_RETURN == -1 &&
> -			    TEST_ERRNO == test_cases[i].exp_errno)
> -				tst_resm(TPASS | TTERRNO,
> -					 "getrusage failed as expected");
> -			else
> -				tst_resm(TFAIL | TTERRNO,
> -					 "getrusage failed unexpectedly");
> -		}
> -	}
> -
> -	cleanup();
> -
> -	tst_exit();
> -
> +		TEST(getrusage(test_cases[i].who, test_cases[i].usage));
> +
> +		if (TST_RET == -1 &&
> +		    TST_ERR == test_cases[i].exp_errno)
> +			tst_res(TPASS | TTERRNO,
> +				"getrusage failed as expected");
> +		else
> +			tst_res(TFAIL | TTERRNO,
> +				"getrusage failed unexpectedly");

Here as well, can we please switch to TST_EXP_FAIL()?

>  }
>  
> -void setup(void)
> -{
> -
> -	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> -
> -	TEST_PAUSE;
> -
> -}
> -
> -void cleanup(void)
> -{
> -
> -}
> +static struct tst_test test = {
> +	.test = verify_getrusage,
> +	.tcnt = ARRAY_SIZE(test_cases),
> +	.needs_root = 1,

Do we really need root for this test?

The original test works fine when executed as a user.

> +};
> -- 
> 2.17.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2021-06-11 13:49 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07 10:45 [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 2/7] getrusage02: " Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 3/7] msgctl04: " Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 4/7] semctl03: " Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 5/7] shmctl02: " Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 6/7] sched_rr_get_interval03: " Vinay Kumar
2021-06-07 10:45 ` [LTP] [PATCH 7/7] setitimer02: " Vinay Kumar
2021-06-08 20:43 ` [LTP] [PATCH 1/7] getitimer02: " Petr Vorel
2021-06-09 17:35   ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Vinay Kumar
2021-06-09 17:35     ` [LTP] [PATCH v2 02/10] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
2021-06-11 13:43       ` Cyril Hrubis
2021-06-13 16:54         ` [LTP] [PATCH v3] " Vinay Kumar
2021-06-14 14:22           ` Cyril Hrubis
2021-06-09 17:35     ` [LTP] [PATCH v2 03/10] getrusage02: Convert getrusage02 to new API Vinay Kumar
2021-06-11 13:49       ` Cyril Hrubis [this message]
2021-06-13 17:12         ` [LTP] [PATCH v3] " Vinay Kumar
2021-06-09 17:35     ` [LTP] [PATCH v2 04/10] getrusage02: Skipped EFAULT tests for libc variant Vinay Kumar
2021-06-11 13:50       ` Cyril Hrubis
2021-06-13 17:16         ` [LTP] [PATCH v3] " Vinay Kumar
2021-06-14 14:37           ` Cyril Hrubis
2021-06-14 15:14             ` Vinay Kumar
2021-06-14 14:52               ` Cyril Hrubis
2021-06-09 17:35     ` [LTP] [PATCH v2 05/10] setitimer02: Convert setitimer02 to new API Vinay Kumar
2021-06-11 13:57       ` Cyril Hrubis
2021-06-13 17:30         ` [LTP] [PATCH v3] " Vinay Kumar
2021-06-14 14:44           ` Cyril Hrubis
2021-06-09 17:35     ` [LTP] [PATCH v2 06/10] setitimer02: Skipped EFAULT tests for libc variant Vinay Kumar
2021-06-11 14:00       ` Cyril Hrubis
2021-06-13 17:35         ` [LTP] [PATCH v3] " Vinay Kumar
2021-06-14 14:47           ` Cyril Hrubis
2021-06-09 17:35     ` [LTP] [PATCH v2 07/10] msgctl04: " Vinay Kumar
2021-06-11 14:13       ` Cyril Hrubis
2021-06-09 17:35     ` [LTP] [PATCH v2 08/10] semctl03 :Skipped " Vinay Kumar
2021-06-17 11:34       ` Cyril Hrubis
2021-06-09 17:36     ` [LTP] [PATCH v2 09/10] sched_rr_get_interval03: Skipped " Vinay Kumar
2021-06-11 14:36       ` Cyril Hrubis
2021-06-09 17:36     ` [LTP] [PATCH v2 10/10] shmctl02 :Skipped " Vinay Kumar
2021-06-13 17:49       ` [LTP] [PATCH v3] ipc/shmctl02: Make use of TST_EXP_FAIL() Vinay Kumar
2021-06-14 15:55         ` Vinay Kumar
2021-06-17 11:40         ` Cyril Hrubis
2021-06-17 11:38       ` [LTP] [PATCH v2 10/10] shmctl02 :Skipped EFAULT tests for libc variant Cyril Hrubis
2021-06-11 13:41     ` [LTP] [PATCH v2 01/10] getitimer02 : Convert getitimer02 to new API Cyril Hrubis
2021-06-13 16:43       ` [LTP] [PATCH v3] getitimer02: " Vinay Kumar
2021-06-14 14:19         ` Cyril Hrubis
2021-06-09 17:38   ` [LTP] [PATCH 1/7] getitimer02: Skipped EFAULT tests for libc variant Vinay Kumar

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=YMNp8tAdF1usM1LM@yuki \
    --to=chrubis@suse.cz \
    --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.