public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] statvfs/statvfs01.c: cleanup
@ 2014-05-30  2:56 Zeng Linggang
  2014-05-30  2:57 ` [LTP] [PATCH 2/2] statvfs/statvfs02.c: add new errno testes Zeng Linggang
  0 siblings, 1 reply; 3+ messages in thread
From: Zeng Linggang @ 2014-05-30  2:56 UTC (permalink / raw)
  To: ltp-list

* Delete some useless commtents.

* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/statvfs/statvfs01.c | 49 +++++++--------------------
 1 file changed, 12 insertions(+), 37 deletions(-)

diff --git a/testcases/kernel/syscalls/statvfs/statvfs01.c b/testcases/kernel/syscalls/statvfs/statvfs01.c
index 306ca00..0ea882a 100644
--- a/testcases/kernel/syscalls/statvfs/statvfs01.c
+++ b/testcases/kernel/syscalls/statvfs/statvfs01.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) Wipro Technologies Ltd, 2005.  All Rights Reserved.
+ *    AUTHOR: Prashant P Yendigeri <prashant.yendigeri@wipro.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
@@ -14,25 +15,12 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  */
-/**********************************************************
- *
- *    TEST IDENTIFIER   : statvfs01
- *
- *    EXECUTED BY       : root / superuser
- *
- *    TEST TITLE        : Basic tests for statvfs(2)
- *
- *    TEST CASE TOTAL   : 1
- *
- *    AUTHOR            : Prashant P Yendigeri
- *                        <prashant.yendigeri@wipro.com>
- *
+/*
  *    DESCRIPTION
  *      This is a Phase I test for the statvfs(2) system call.
  *      It is intended to provide a limited exposure of the system call.
  *	This call behaves similar to statfs.
- *
- **********************************************************/
+ */
 
 #include <stdio.h>
 #include <unistd.h>
@@ -43,15 +31,15 @@
 #include "test.h"
 #include "usctest.h"
 
-#define TEST_PATH "/"		/* Should be a mounted FS */
+#define TEST_PATH "/"
 
-void setup();
-void cleanup();
+static void setup(void);
+static void cleanup(void);
 
 char *TCID = "statvfs01";
 int TST_TOTAL = 1;
 
-int exp_enos[] = { 0 };		/* must be a 0 terminated list */
+int exp_enos[] = { 0 };
 
 int main(int ac, char **av)
 {
@@ -64,7 +52,6 @@ int main(int ac, char **av)
 
 	setup();
 
-	/* set the expected errnos... */
 	TEST_EXP_ENOS(exp_enos);
 
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
@@ -73,11 +60,12 @@ int main(int ac, char **av)
 
 		TEST(statvfs(TEST_PATH, &buf));
 
-		if (TEST_RETURN == -1)
+		if (TEST_RETURN == -1) {
 			tst_resm(TFAIL | TERRNO, "statvfs(%s, ...) failed",
 				 TEST_PATH);
-		else
+		} else {
 			tst_resm(TPASS, "statvfs(%s, ...) passed", TEST_PATH);
+		}
 
 	}
 
@@ -96,30 +84,17 @@ int main(int ac, char **av)
 	tst_resm(TINFO, "file system max filename length = %lu", buf.f_namemax);
 
 	cleanup();
-
 	tst_exit();
 }
 
-/***************************************************************
- * setup() - performs all ONE TIME setup for this test.
- ***************************************************************/
-void setup(void)
+static void setup(void)
 {
-
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
 	TEST_PAUSE;
 }
 
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- *              completion or premature exit.
- ***************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-	/*
-	 * print timing stats if that option was specified.
-	 * print errno log if that option was specified.
-	 */
 	TEST_CLEANUP;
 }
-- 
1.8.4.2




------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH 2/2] statvfs/statvfs02.c: add new errno testes
  2014-05-30  2:56 [LTP] [PATCH 1/2] statvfs/statvfs01.c: cleanup Zeng Linggang
@ 2014-05-30  2:57 ` Zeng Linggang
  2014-06-03 15:29   ` chrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Zeng Linggang @ 2014-05-30  2:57 UTC (permalink / raw)
  To: ltp-list

* Add new errno testes for statvfs(2)
  - EFAULT
  - ELOOP
  - ENAMETOOLONG
  - ENOENT
  - ENOTDIR

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 runtest/ltplite                               |   1 +
 runtest/stress.part3                          |   1 +
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/.gitignore          |   1 +
 testcases/kernel/syscalls/statvfs/statvfs02.c | 124 ++++++++++++++++++++++++++
 5 files changed, 128 insertions(+)
 create mode 100644 testcases/kernel/syscalls/statvfs/statvfs02.c

diff --git a/runtest/ltplite b/runtest/ltplite
index 11b6ffc..d71f137 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -867,6 +867,7 @@ statfs02 statfs02
 statfs03 statfs03
 
 statvfs01 statvfs01
+statvfs02 statvfs02
 
 # This syscall is obsoleted by settimeofday.
 #stime01 stime01
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index ed877b0..bc71013 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -773,6 +773,7 @@ statfs02 statfs02
 statfs03 statfs03
 
 statvfs01 statvfs01
+statvfs02 statvfs02
 
 # This syscall is obsoleted by settimeofday.
 #stime01 stime01
diff --git a/runtest/syscalls b/runtest/syscalls
index 9207356..cb8ff4f 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1176,6 +1176,7 @@ statfs03 statfs03
 statfs03_64 statfs03_64
 
 statvfs01 statvfs01
+statvfs02 statvfs02
 
 stime01 stime01
 stime02 stime02
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index 61c836c..d3939cd 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -918,6 +918,7 @@
 /statfs/statfs03
 /statfs/statfs03_64
 /statvfs/statvfs01
+/statvfs/statvfs02
 /stime/stime01
 /stime/stime02
 /string/string01
diff --git a/testcases/kernel/syscalls/statvfs/statvfs02.c b/testcases/kernel/syscalls/statvfs/statvfs02.c
new file mode 100644
index 0000000..adf08f3
--- /dev/null
+++ b/testcases/kernel/syscalls/statvfs/statvfs02.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Zeng Linggang <zenglg.jy@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:
+ *  Verify that,
+ *   1. path is NULL, EFAULT would return.
+ *   2. Too many symbolic links were encountered in translating path,
+ *	ELOOP would return.
+ *   3. path is too long, ENAMETOOLONG would return.
+ *   4. The file referred to by path does not exist, ENOENT would return.
+ *   5. A component of the path prefix of path is not a directory,
+ *	ENOENT would return.
+ */
+
+#include <errno.h>
+#include <sys/statvfs.h>
+
+#include "test.h"
+#include "usctest.h"
+#include "safe_macros.h"
+
+#define TEST_SYMLINK	"statvfs_symlink"
+#define TEST_FILE	"statvfs_file"
+
+char *TCID = "statvfs02";
+
+static struct statvfs buf;
+static char nametoolong[PATH_MAX+2];
+static void setup(void);
+static void cleanup(void);
+
+static struct test_case_t {
+	char *path;
+	struct statvfs *buf;
+	int exp_errno;
+} test_cases[] = {
+	{NULL, &buf, EFAULT},
+	{TEST_SYMLINK, &buf, ELOOP},
+	{nametoolong, &buf, ENAMETOOLONG},
+	{"filenoexist", &buf, ENOENT},
+	{"statvfs_file/test", &buf, ENOTDIR},
+};
+
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+static int exp_enos[] = { EFAULT, ELOOP, ENAMETOOLONG, ENOENT, ENOTDIR, 0 };
+static void statvfs_verify(const struct test_case_t *);
+
+int main(int argc, char **argv)
+{
+	int i, lc;
+	const char *msg;
+
+	msg = parse_opts(argc, argv, NULL, NULL);
+	if (msg != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+		for (i = 0; i < TST_TOTAL; i++)
+			statvfs_verify(&test_cases[i]);
+	}
+
+	cleanup();
+	tst_exit();
+}
+
+static void setup(void)
+{
+	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+	TEST_EXP_ENOS(exp_enos);
+
+	TEST_PAUSE;
+
+	tst_tmpdir();
+
+	SAFE_SYMLINK(cleanup, TEST_SYMLINK, "statfs_symlink_2");
+	SAFE_SYMLINK(cleanup, "statfs_symlink_2", TEST_SYMLINK);
+
+	memset(nametoolong, 'a', PATH_MAX+1);
+
+	SAFE_TOUCH(cleanup, TEST_FILE, 0644, NULL);
+}
+
+static void statvfs_verify(const struct test_case_t *test)
+{
+	TEST(statvfs(test->path, test->buf));
+
+	if (TEST_RETURN != -1) {
+		tst_resm(TFAIL, "statvfs() succeeded unexpectedly");
+		return;
+	}
+
+	if (TEST_ERRNO == test->exp_errno) {
+		tst_resm(TPASS | TTERRNO, "statvfs() failed as expected");
+	} else {
+		tst_resm(TFAIL | TTERRNO,
+			 "statvfs() failed unexpectedly; expected: %d - %s",
+			 test->exp_errno, strerror(test->exp_errno));
+	}
+}
+
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+
+	tst_rmdir();
+}
-- 
1.8.4.2




------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH 2/2] statvfs/statvfs02.c: add new errno testes
  2014-05-30  2:57 ` [LTP] [PATCH 2/2] statvfs/statvfs02.c: add new errno testes Zeng Linggang
@ 2014-06-03 15:29   ` chrubis
  0 siblings, 0 replies; 3+ messages in thread
From: chrubis @ 2014-06-03 15:29 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
Both pushed, thanks.

> +static struct test_case_t {
> +	char *path;
> +	struct statvfs *buf;
> +	int exp_errno;
> +} test_cases[] = {
> +	{NULL, &buf, EFAULT},

I've changed the testcase, for now, to map PROT_NONE page and set
pointer to it to a path for this testcase because there architectures
that have something mapped on NULL address (itanium if I recall
correctly).

I will deal with this by creating a library function to provide invalid
addresses and fix all the testcases later.

> +	{TEST_SYMLINK, &buf, ELOOP},
> +	{nametoolong, &buf, ENAMETOOLONG},
> +	{"filenoexist", &buf, ENOENT},
> +	{"statvfs_file/test", &buf, ENOTDIR},
> +};

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-03 15:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-30  2:56 [LTP] [PATCH 1/2] statvfs/statvfs01.c: cleanup Zeng Linggang
2014-05-30  2:57 ` [LTP] [PATCH 2/2] statvfs/statvfs02.c: add new errno testes Zeng Linggang
2014-06-03 15:29   ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox