public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
To: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] getdents/getdents05.c: add ENOENT test for getdents(2)
Date: Mon, 06 Jan 2014 11:49:55 +0800	[thread overview]
Message-ID: <52CA27E3.8060100@cn.fujitsu.com> (raw)
In-Reply-To: <52B1565D.50406@cn.fujitsu.com>

Could anyone help to review this?

Thanks,
Xiaoguang Wang


On 12/18/2013 04:01 PM, Xiaoguang Wang wrote:
> create a new case to test ENOENT error value for getdents(2)
>
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
>  runtest/ltplite                                 |   1 +
>  runtest/stress.part3                            |   1 +
>  runtest/syscalls                                |   2 +
>  testcases/kernel/syscalls/getdents/getdents05.c | 133 ++++++++++++++++++++++++
>  4 files changed, 137 insertions(+)
>  create mode 100644 testcases/kernel/syscalls/getdents/getdents05.c
>
> diff --git a/runtest/ltplite b/runtest/ltplite
> index c90bc48..953f5a6 100644
> --- a/runtest/ltplite
> +++ b/runtest/ltplite
> @@ -277,6 +277,7 @@ getdents01 getdents01
>  getdents02 getdents02
>  getdents03 getdents03
>  getdents04 getdents04
> +getdents05 getdents05
>  
>  getdomainname01 getdomainname01
>  
> diff --git a/runtest/stress.part3 b/runtest/stress.part3
> index eac28d0..a4b1a66 100644
> --- a/runtest/stress.part3
> +++ b/runtest/stress.part3
> @@ -216,6 +216,7 @@ getdents01 getdents01
>  getdents02 getdents02
>  getdents03 getdents03
>  getdents04 getdents04
> +getdents05 getdents05
>  
>  getdomainname01 getdomainname01
>  
> diff --git a/runtest/syscalls b/runtest/syscalls
> index c5bbe8f..aa2d30c 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -327,11 +327,13 @@ getdents01 getdents01
>  getdents02 getdents02
>  getdents03 getdents03
>  getdents04 getdents04
> +getdents05 getdents05
>  
>  getdents01_64 getdents01 -l
>  getdents02_64 getdents02 -l
>  getdents03_64 getdents03 -l
>  getdents04_64 getdents04 -l
> +getdents05_64 getdents05 -l
>  
>  getdomainname01 getdomainname01
>  
> diff --git a/testcases/kernel/syscalls/getdents/getdents05.c b/testcases/kernel/syscalls/getdents/getdents05.c
> new file mode 100644
> index 0000000..b4df82a
> --- /dev/null
> +++ b/testcases/kernel/syscalls/getdents/getdents05.c
> @@ -0,0 +1,133 @@
> +/*
> + * Copyright (c) 2013 Fujitsu Ltd.
> + * Author: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of version 2 of the GNU General Public License as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it would be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, write the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */
> +
> +/*
> + * Test Description:
> + *   test ENOENT error value for getdents(2)
> + */
> +
> +#define _GNU_SOURCE
> +#include <stdio.h>
> +#include <errno.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +
> +#include "test.h"
> +#include "usctest.h"
> +#include "safe_macros.h"
> +#include "getdents.h"
> +
> +static void cleanup(void);
> +static void setup(void);
> +
> +#define DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
> +			 S_IXGRP|S_IROTH|S_IXOTH)
> +#define TEST_DIR	"test_dir"
> +
> +char *TCID = "getdents05";
> +int TST_TOTAL = 1;
> +
> +static int exp_enos[] = { ENOENT, 0 };
> +
> +static int longsyscall;
> +
> +static option_t options[] = {
> +		/* -l long option. Tests getdents64 */
> +		{"l", &longsyscall, NULL},
> +		{NULL, NULL, NULL}
> +};
> +
> +static void help(void)
> +{
> +	printf("  -l      Test the getdents64 system call\n");
> +}
> +
> +int main(int ac, char **av)
> +{
> +	int lc;
> +	char *msg;
> +	int rval, fd;
> +	struct linux_dirent64 dir64;
> +	struct linux_dirent dir;
> +
> +	msg = parse_opts(ac, av, options, &help);
> +	if (msg != NULL)
> +		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
> +
> +	setup();
> +
> +	for (lc = 0; TEST_LOOPING(lc); lc++) {
> +		tst_count = 0;
> +
> +		SAFE_MKDIR(cleanup, TEST_DIR, DIR_MODE);
> +
> +		fd = SAFE_OPEN(cleanup, TEST_DIR, O_DIRECTORY);
> +		if (rmdir(TEST_DIR) == -1) {
> +			tst_brkm(TBROK | TERRNO, cleanup,
> +				 "rmdir(%s) failed", TEST_DIR);
> +		}
> +
> +		if (longsyscall)
> +			rval = getdents64(fd, &dir64, sizeof(dir64));
> +		else
> +			rval = getdents(fd, &dir, sizeof(dir));
> +
> +		if (rval < 0) {
> +			TEST_ERROR_LOG(errno);
> +
> +			switch (errno) {
> +			case ENOENT:
> +				tst_resm(TPASS, "getdents failed as "
> +					 "expected with ENOENT");
> +			break;
> +			case ENOSYS:
> +				tst_resm(TCONF, "syscall not implemented");
> +			break;
> +			default:
> +				tst_resm(TFAIL | TERRNO,
> +					 "getdents failed unexpectedly");
> +			break;
> +			}
> +		} else {
> +			tst_resm(TFAIL, "getdents call succeeded unexpectedly");
> +		}
> +
> +		SAFE_CLOSE(cleanup, fd);
> +	}
> +
> +	cleanup();
> +	tst_exit();
> +}
> +
> +static void setup(void)
> +{
> +	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> +
> +	tst_tmpdir();
> +
> +	TEST_EXP_ENOS(exp_enos);
> +
> +	TEST_PAUSE;
> +}
> +
> +static void cleanup(void)
> +{
> +	TEST_CLEANUP;
> +
> +	tst_rmdir();
> +}


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2014-01-06  3:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18  8:01 [LTP] [PATCH] getdents/getdents05.c: add ENOENT test for getdents(2) Xiaoguang Wang
2014-01-06  3:49 ` Wang Xiaoguang [this message]
2014-02-05 17:09 ` chrubis

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=52CA27E3.8060100@cn.fujitsu.com \
    --to=wangxg.fnst@cn.fujitsu.com \
    --cc=ltp-list@lists.sourceforge.net \
    /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