public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 1/1] syscalls/clock_getres01: convert to use new test library API
Date: Tue, 15 Nov 2016 17:08:44 +0100	[thread overview]
Message-ID: <20161115160843.GC24751@rei.lan> (raw)
In-Reply-To: <20161115134929.8471-1-pvorel@suse.cz>

Hi!
> +	TEST(clock_getres(tcase[i].clk_id, tcase[i].res));
> +
> +	if (TEST_RETURN != tcase[i].ret) {
> +		if (TEST_ERRNO != EINVAL) {
> +				tst_res(TFAIL | TTERRNO,
> +				 "clock_getres %s failed",
> +				 tcase[i].name);
                ^
		Fix the indentation here, (1 tab instead of two).

> +		} else {
> +				tst_res(TCONF,
> +				 "clock_getres %s NO SUPPORTED",
> +				 tcase[i].name);
> +		}

And we can simplify the code flow a bit as:


	if (TEST_RETURN != tcase[i].ret) {
		if (TEST_ERRNO == EINVAL) {
			tst_res(TCONF, ...);
			return;
		}

		tst_res(TFAIL ...);
		return;
	}


	if (TEST_ERRNO != tcase[i].err) {
		tst_res(TFAIL, ...);
		return;
	}

	tst_res(TPASS, ...);


> +	} else {
> +		if (TEST_ERRNO != tcase[i].err) {
> +				tst_res(TFAIL,
> +				 "clock_getres %s failed with "
> +				 "unexpect errno: %d",
> +				 tcase[i].name, TEST_ERRNO);
                                     ^

				 This message should print what errno we
				 got and what was the expected one, it
				 should be something as:


				 tst_res(TFAIL | TTERRNO,
				         "clock_getres(%s, ...) failed unexpectedly, expected %s",
					 tcase[i].name, tst_strerrno(tcase[i].err));

> +		} else {
> +				tst_res(TPASS,
> +				 "clock_getres %s succeeded",
> +				 tcase[i].name);
>  		}
>  	}
> -
> -	cleanup();
> -	tst_exit();
> -}
> -
> -static void setup(void)
> -{
> -	TEST_PAUSE;
>  }
>  
> -static void cleanup(void)
> -{
> -}
> +static struct tst_test test = {
> +	.tid = "clock_getres01",
> +	.test = do_test,
> +	.tcnt = ARRAY_SIZE(tcase),
> +};
> -- 
> 2.10.2
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

      reply	other threads:[~2016-11-15 16:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15 13:49 [LTP] [PATCH v2 1/1] syscalls/clock_getres01: convert to use new test library API Petr Vorel
2016-11-15 16:08 ` Cyril Hrubis [this message]

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=20161115160843.GC24751@rei.lan \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox