public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: chrubis@suse.cz
To: shuang.qiu@oracle.com
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] syscalls/fstatfs02: Using temporary file description to test the syscall
Date: Tue, 10 Jun 2014 16:24:58 +0200	[thread overview]
Message-ID: <20140610142457.GA18940@rei.Home> (raw)
In-Reply-To: <1402040858-5701-1-git-send-email-shuang.qiu@oracle.com>

Hi!
> It is not expected to use stdout as the file description to test the
> system call fstatfs().Using ltp temporary file instead.
> 
> Signed-off-by: Shuang Qiu <shuang.qiu@oracle.com>
> ---
>  testcases/kernel/syscalls/fstatfs/fstatfs02.c |   10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/testcases/kernel/syscalls/fstatfs/fstatfs02.c b/testcases/kernel/syscalls/fstatfs/fstatfs02.c
> index f851c97..9e00a67 100644
> --- a/testcases/kernel/syscalls/fstatfs/fstatfs02.c
> +++ b/testcases/kernel/syscalls/fstatfs/fstatfs02.c
> @@ -27,6 +27,7 @@
>  #include <errno.h>
>  #include "test.h"
>  #include "usctest.h"
> +#include "safe_macros.h"
>  
>  static void setup(void);
>  static void cleanup(void);
> @@ -48,6 +49,7 @@ static struct test_case_t {
>  #ifndef UCLINUX
>  	    /* Skip since uClinux does not implement memory protection */
>  	    /* EFAULT - address for buf is invalid */
> +	    /* Using the init "1" as fd is not actually expected,will assign a tmp file later */
>  	{
>  	1, (void *)-1, EFAULT}
>  #endif
> @@ -107,11 +109,19 @@ static void setup(void)
>  	TEST_PAUSE;
>  
>  	tst_tmpdir();
> +#ifndef UCLINUX
> +	TC[1].fd = SAFE_OPEN(cleanup, "tempfile", O_RDWR | O_CREAT, 0700);
> +#endif
>  }
>  
>  static void cleanup(void)
>  {
>  	TEST_CLEANUP;
>  
> +#ifndef UCLINUX
> +	if (TC[1].fd > 0 && close(TC[1].fd))

             ^
	     This does not work as expected because the fd is
	     initialized to 1. If we get here after the open() has
	     failed it will close stdout at this point.

	     You should change the initial value in the test strucure to
	     -1 (you don't have to add the comment in this case too).

> +		tst_resm(TWARN | TERRNO, "Failed to close fd");
> +#endif
> +
>  	tst_rmdir();
>  }

The rest is Ok.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

      reply	other threads:[~2014-06-10 14:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-06  7:47 [LTP] [PATCH] syscalls/fstatfs02: Using temporary file description to test the syscall shuang.qiu
2014-06-10 14:24 ` chrubis [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=20140610142457.GA18940@rei.Home \
    --to=chrubis@suse.cz \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=shuang.qiu@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox