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] Cleanup syscalls/utime test messages
Date: Thu, 19 Nov 2015 17:00:51 +0100	[thread overview]
Message-ID: <20151119160051.GF28969@rei.lan> (raw)
In-Reply-To: <20151115100916.GA24895@issan.sis.pasteur.fr>

> diff --git a/testcases/kernel/syscalls/utime/utime01.c b/testcases/kernel/syscalls/utime/utime01.c
> index 4bb33e9..2eb49d4 100644
> --- a/testcases/kernel/syscalls/utime/utime01.c
> +++ b/testcases/kernel/syscalls/utime/utime01.c
> @@ -131,8 +131,7 @@ int main(int ac, char **av)
>  		TEST(utime(TEMP_FILE, NULL));
>  
>  		if (TEST_RETURN == -1) {
> -			tst_resm(TFAIL, "utime(%s) Failed, errno=%d : %s",
> -				 TEMP_FILE, TEST_ERRNO, strerror(TEST_ERRNO));
> +			tst_resm(TFAIL|TTERRNO, "utime(%s) failed", TEMP_FILE);
>  		} else {
>  			/*
>  			 * Sleep for a second so that mod time and
> @@ -146,10 +145,9 @@ int main(int ac, char **av)
>  			 * utime(2)
>  			 */
>  			if ((pres_time = time(&tloc)) < 0) {
> -				tst_brkm(TFAIL, cleanup, "time() "
> +				tst_brkm(TFAIL|TERRNO, cleanup, "time() "
>  					 "failed to get present time "
> -					 "after utime, error=%d",
> -					 errno);
> +					 "after utime");

This part of code is not 100% correct, since time() returns precisely
(time_t)-1 on failure. If time_t is typedefed in system to unsigned it
will never be true. And it looks like it's defined to be long int at the
moment hence 4 bytes on 32bit arch and 8 bytes on 64bit arch, but that
may change because of 2038. Heh, and the test fails if you set time
before 01-01-1970 (yep, looks like it could be done since time_t is
signed type), not that it matters that much though.

Lookig at the time man page the only error defined for time is EFAULT
when you pass wrong pointer to it. So I would just remove the check for
failure for all time() calls. What do you think?

>  
>  			/*
> @@ -157,9 +155,8 @@ int main(int ac, char **av)
>  			 * temporary file using stat(2).
>  			 */
>  			if (stat(TEMP_FILE, &stat_buf) < 0) {
> -				tst_brkm(TFAIL, cleanup, "stat(2) of "
> -					 "%s failed, error:%d",
> -					 TEMP_FILE, TEST_ERRNO);
> +				tst_brkm(TFAIL|TERRNO, cleanup, "stat(2) of "
> +					 "%s failed", TEMP_FILE);
>  			}

Hint: we have safe macros so this could be easily done with just:

      SAFE_STAT(cleanup, TEMP_FILE, &stat_buf);

      And the same for creat(), close(), etc.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2015-11-19 16:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-15 10:09 [LTP] [PATCH] Cleanup syscalls/utime test messages Nicolas Joly
2015-11-19 16:00 ` Cyril Hrubis [this message]
2015-11-21  9:41   ` Nicolas Joly
2015-11-28  9:26     ` Nicolas Joly
2015-11-30 16:52       ` Cyril Hrubis

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=20151119160051.GF28969@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