* [LTP] [PATCH] readdir/readdir21.c: Add EBADF and EFAULT errno testes
@ 2014-05-14 8:54 Zeng Linggang
2014-05-19 15:43 ` chrubis
0 siblings, 1 reply; 2+ messages in thread
From: Zeng Linggang @ 2014-05-14 8:54 UTC (permalink / raw)
To: ltp-list
Add EBADF and EFAULT errno testes for readdir(2).
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
testcases/kernel/syscalls/readdir/readdir21.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/testcases/kernel/syscalls/readdir/readdir21.c b/testcases/kernel/syscalls/readdir/readdir21.c
index daf6080..6db2371 100644
--- a/testcases/kernel/syscalls/readdir/readdir21.c
+++ b/testcases/kernel/syscalls/readdir/readdir21.c
@@ -20,6 +20,9 @@
* 1. Creat a directory and open it, then delete the directory, ENOENT would
* return.
* 2. File descriptor does not refer to a directory, ENOTDIR would return.
+ * 3. Invalid file descriptor fd, EBADF would return.
+ * 4. Argument points outside the calling process's address space, EFAULT
+ * would return.
*
* PS:
* This file is for readdir(2) and the other files(readdir01.c and
@@ -34,6 +37,7 @@
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
+#include <sys/mman.h>
#include "test.h"
#include "usctest.h"
#include "safe_macros.h"
@@ -43,11 +47,14 @@
char *TCID = "readdir21";
#define TEST_DIR "test_dir"
+#define TEST_DIR4 "test_dir4"
#define TEST_FILE "test_file"
#define DIR_MODE (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
S_IXGRP|S_IROTH|S_IXOTH)
static unsigned int del_dir_fd, file_fd;
+static unsigned int invalid_fd = 999;
+static unsigned int dir_fd;
static struct old_linux_dirent dirp;
static void setup(void);
static void cleanup(void);
@@ -60,6 +67,11 @@ static struct test_case_t {
} test_cases[] = {
{&del_dir_fd, &dirp, sizeof(struct old_linux_dirent), ENOENT},
{&file_fd, &dirp, sizeof(struct old_linux_dirent), ENOTDIR},
+ {&invalid_fd, &dirp, sizeof(struct old_linux_dirent), EBADF},
+#if !defined(UCLINUX)
+ {&dir_fd, (struct old_linux_dirent *)-1,
+ sizeof(struct old_linux_dirent), EFAULT},
+#endif
};
int TST_TOTAL = ARRAY_SIZE(test_cases);
@@ -102,6 +114,14 @@ static void setup(void)
SAFE_RMDIR(cleanup, TEST_DIR);
file_fd = SAFE_OPEN(cleanup, TEST_FILE, O_RDWR | O_CREAT, 0777);
+
+ SAFE_MKDIR(cleanup, TEST_DIR4, DIR_MODE);
+ dir_fd = SAFE_OPEN(cleanup, TEST_DIR4, O_RDONLY | O_DIRECTORY);
+
+#if !defined(UCLINUX)
+ test_cases[3].dirp = SAFE_MMAP(cleanup, 0, 1, PROT_NONE,
+ MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+#endif
}
static void readdir_verify(const struct test_case_t *test)
@@ -126,6 +146,9 @@ static void cleanup(void)
{
TEST_CLEANUP;
+ if (dir_fd > 0)
+ close(dir_fd);
+
if (del_dir_fd > 0)
close(del_dir_fd);
--
1.7.1
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] readdir/readdir21.c: Add EBADF and EFAULT errno testes
2014-05-14 8:54 [LTP] [PATCH] readdir/readdir21.c: Add EBADF and EFAULT errno testes Zeng Linggang
@ 2014-05-19 15:43 ` chrubis
0 siblings, 0 replies; 2+ messages in thread
From: chrubis @ 2014-05-19 15:43 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-19 15:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-14 8:54 [LTP] [PATCH] readdir/readdir21.c: Add EBADF and EFAULT errno testes Zeng Linggang
2014-05-19 15:43 ` chrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox