Skip to contentSkip to conversation

pwrite/pwrite02.c: make EBADF error value tests sufficient

PATCH In review Xiaoguang Wang 2 participants 2 messages May 6, 2014 – May 28, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 pwrite/pwrite02.c: make EBADF error value tests sufficient

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 <[email protected]>
Date: Tue, 6 May 2014 14:16:40 +0800
Subject: [PATCH v2 2/2] pwrite/pwrite02.c: make EBADF error value tests
sufficient

---
 testcases/kernel/syscalls/pwrite/pwrite02.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/pwrite/pwrite02.c +20 -5
index c9fc840..a934de8 100644
@@ -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)
 {
Signature · 1 line
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#1 lore raw

Hi!
Pushed, thanks.

Signature · 11 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list