Hi,
 
    This is a patch following  "[PATCH v2 1/2] pwrite/pwrite02.c: cleanup", 
thanks

Regards,
Wang
>From 11e724ef0e7d18930d2f25f845d46f264feb69b8 Mon Sep 17 00:00:00 2001
From: Xiaoguang Wang <wangxg.f...@cn.fujitsu.com>
Date: Tue, 6 May 2014 14:16:40 +0800
Subject: [PATCH v2 2/2] pwrite/pwrite02.c: make EBADF error value tests
 sufficient

Signed-off-by: Xiaoguang Wang <wangxg.f...@cn.fujitsu.com>
---
 testcases/kernel/syscalls/pwrite/pwrite02.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/syscalls/pwrite/pwrite02.c b/testcases/kernel/syscalls/pwrite/pwrite02.c
index c9fc840..a934de8 100644
--- a/testcases/kernel/syscalls/pwrite/pwrite02.c
+++ b/testcases/kernel/syscalls/pwrite/pwrite02.c
@@ -26,8 +26,9 @@
  *   	returns EINVAL.
  *   3) pwrite() fails if fd is not a valid file descriptor,
  *	returns EBADF.
- *   4) pwrite() fails when attempted to write with buf outside
- *      accessible address space, returns EFAULT.
+ *   4) pwrite() fails if fd is not open for writing, return EBADF.
+ *   5) pwrite() fails when attempted to write with buf outside
+ *      accessible address space.
  */
 
 #define _XOPEN_SOURCE 500
@@ -59,14 +60,15 @@ static int exp_enos[] = {
 
 static void test_espipe(void);
 static void test_einval(void);
-static void test_ebadf(void);
+static void test_ebadf1(void);
+static void test_ebadf2(void);
 
 #if !defined(UCLINUX)
 static void test_efault(void);
 #endif
 
 static void (*testfunc[])(void) = {
-	test_espipe, test_einval, test_ebadf,
+	test_espipe, test_einval, test_ebadf1, test_ebadf2,
 #if !defined(UCLINUX)
 	test_efault
 #endif
@@ -179,7 +181,7 @@ static void test_einval(void)
 	SAFE_CLOSE(cleanup, fd);
 }
 
-static void test_ebadf(void)
+static void test_ebadf1(void)
 {
 	int fd = -1;
 
@@ -188,6 +190,19 @@ static void test_ebadf(void)
 	print_test_result(errno, EBADF);
 }
 
+static void test_ebadf2(void)
+{
+	int fd;
+
+	fd = SAFE_OPEN(cleanup, TEMPFILE, O_RDONLY | O_CREAT, 0666);
+
+	TEST(pwrite(fd, write_buf, K1, 0));
+
+	print_test_result(errno, EBADF);
+
+	SAFE_CLOSE(cleanup, fd);
+}
+
 #if !defined(UCLINUX)
 static void test_efault(void)
 {
-- 
1.8.2.1

------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to