Skip to contentSkip to conversation

access(2): add ELOOP, ENOTDIR, EROFS error number test

PATCH In review Wang, Xiaoguang 2 participants 2 messages Oct 22, 2013 – Oct 23, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 access(2): add ELOOP, ENOTDIR, EROFS error number test

access/access05.c: add ELOOP, ENOTDIR error number test

new access/access06.c: add EROFS error number test

---
 runtest/syscalls                            |    1 +
 testcases/kernel/syscalls/.gitignore        |    1 +
 testcases/kernel/syscalls/access/access05.c |   22 ++++-
 testcases/kernel/syscalls/access/access06.c |  171 +++++++++++++++++++++++++++
 4 files changed, 194 insertions(+), 1 deletions(-)
 create mode 100644 testcases/kernel/syscalls/access/access06.c
runtest/syscalls +1 -0
index 09e5f7f..791de7c 100644
@@ -9,6 +9,7 @@ access02 access02
 access03 access03
 access04 access04
 access05 access05
+access06 access06 -D DEVICE -T DEVICE_FS_TYPE
 
 acct01 acct01
 acct02 acct02
testcases/kernel/syscalls/.gitignore +1 -0
index ad23c2e..c005111 100644
@@ -6,6 +6,7 @@
 /access/access03
 /access/access04
 /access/access05
+/access/access06
 /acct/acct01
 /acct/acct02
 /add_key/add_key01
testcases/kernel/syscalls/access/access05.c +21 -1
index 739b4b2..792692c 100644
@@ -32,6 +32,10 @@
  *	if the specified file doesn't exist (or pathname is NULL).
  *   5. access() fails with -1 return value and sets errno to ENAMETOOLONG
  *      if the pathname size is > PATH_MAX characters.
+ *   6. access() fails with -1 return value and sets errno to ENOTDIR
+ *      if a component used as a directory in pathname is not a directory.
+ *   7. access() fails with -1 return value and sets errno to ELOOP
+ *      if too many symbolic links were encountered in resolving pathname.
  *
  *   07/2001 Ported by Wayne Boyer
  */
@@ -56,6 +60,8 @@
 #define TEST_FILE2	"test_file2"
 #define TEST_FILE3	"test_file3"
 #define TEST_FILE4	"test_file4"
+#define TEST_FILE5	"test_file5/test_file5"
+#define TEST_FILE6	"test_file6"
 
 
 #if !defined(UCLINUX)
@@ -79,12 +85,15 @@ static struct test_case_t {
 #endif
 	{"", W_OK, ENOENT},
 	{longpathname, R_OK, ENAMETOOLONG},
+	{TEST_FILE5, R_OK, ENOTDIR},
+	{TEST_FILE6, R_OK, ELOOP},
 };
 
 char *TCID = "access05";
 int TST_TOTAL = ARRAY_SIZE(test_cases);
 
-static int exp_enos[] = { EACCES, EFAULT, EINVAL, ENOENT, ENAMETOOLONG, 0 };
+static int exp_enos[] = { EACCES, EFAULT, EINVAL, ENOENT, ENAMETOOLONG,
+			  ENOTDIR, ELOOP, 0 };
 
 static const char nobody_uid[] = "nobody";
 static struct passwd *ltpuser;
@@ -172,6 +181,17 @@ static void setup(void)
 	 *the MAX length of PATH_MAX.
 	 */
 	memset(longpathname, 'a', sizeof(longpathname) - 1);
+
+	/* create test_file5 for test ENOTDIR. */
+	fd = SAFE_CREAT(cleanup, "test_file5", 0644);
+	SAFE_CLOSE(cleanup, fd);
+
+	/*
+	 * create two symbolic links who point to each other for
+	 * test ELOOP.
+	 */
+	SAFE_SYMLINK(cleanup, "test_file6", "test_file7");
+	SAFE_SYMLINK(cleanup, "test_file7", "test_file6");
 }
 
 static void access_verify(int i)
testcases/kernel/syscalls/access/access06.c new file +171 -0

171 lines not on this page · raw message

Signature · 16 lines
1.7.1

Regards,
Xiaogung Wang


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw

Hi!

Quoted 3 lines

access/access05.c: add ELOOP, ENOTDIR error number test

new access/access06.c: add EROFS error number test

Sorry for not being clear enough the first time. When I said adding the testcases to access05 I meant all of them including the EROFS (contrary to my first thoughts). (I can fix this myself if you want). Otherwise the code is fine.

Also looking at increased demand for EROFS tests, I'm trying to figure out more general LTP lib API for creating and mounting the readonly image, so that the code pattern is not repeated all over. But for now let's go with the manual approach and I will convert all usages once the new API is in place.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list