From 95a57280ebc3996547fccd6065a5652a846d1447 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 16 Dec 2013 13:12:22 +0100 Subject: libcsupport: Add and use rtems_libio_iovec_eval() --- testsuites/psxtests/psxrdwrv/psxrdwrv.scn | 8 ++++++-- testsuites/psxtests/psxrdwrv/test.c | 33 +++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 6 deletions(-) (limited to 'testsuites/psxtests/psxrdwrv') diff --git a/testsuites/psxtests/psxrdwrv/psxrdwrv.scn b/testsuites/psxtests/psxrdwrv/psxrdwrv.scn index 26e1ea5ac9..7d070eabdd 100644 --- a/testsuites/psxtests/psxrdwrv/psxrdwrv.scn +++ b/testsuites/psxtests/psxrdwrv/psxrdwrv.scn @@ -3,16 +3,20 @@ writev bad file descriptor -- EBADF readv bad file descriptor -- EBADF writev bad iovec pointer -- EINVAL readv bad iovec pointer -- EINVAL -readv bad iovcnt of 0 -- EINVAL +writev bad iovcnt of 0 -- EINVAL readv bad iovcnt of 0 -- EINVAL writev bad iovcnt negative -- EINVAL readv bad iovcnt negative -- EINVAL writev bad iov[i].iov_base -- EINVAL readv bad iov[i].iov_base -- EINVAL writev bad iov[i].iov_len < 0 -- EINVAL -readv bad iov[i].iov_len = 0 -- EINVAL +readv bad iov[i].iov_len < 0 -- EINVAL writev iov_len total overflows -- EINVAL readv iov_len total overflows -- EINVAL +writev iov_len works with no effect -- OK +readv iov_len works with no effect -- OK +readv bad iovcnt of IOV_MAX + 1 -- EINVAL +writev bad iovcnt of IOV_MAX + 1 -- EINVAL File written using writev .. OK File read using readv .. OK *** END OF TEST PSXRDWRV *** diff --git a/testsuites/psxtests/psxrdwrv/test.c b/testsuites/psxtests/psxrdwrv/test.c index cedca900a9..0e066746a9 100644 --- a/testsuites/psxtests/psxrdwrv/test.c +++ b/testsuites/psxtests/psxrdwrv/test.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -217,6 +218,7 @@ int doErrorTest(void) } fd = fileno(fp); +#ifdef __rtems__ /* writev -- bad iovec pointer */ puts("writev bad iovec pointer -- EINVAL"); rc = writev(fd, NULL, 4); @@ -236,7 +238,7 @@ int doErrorTest(void) } /* writev -- bad iovcnt 0 */ - puts("readv bad iovcnt of 0 -- EINVAL"); + puts("writev bad iovcnt of 0 -- EINVAL"); rc = writev(fd, vec, 0); if ( (rc != -1) || (errno != EINVAL) ) { printf( "writev error 3: %d=%s\n", errno, strerror(errno) ); @@ -252,6 +254,7 @@ int doErrorTest(void) fclose(fp); return FALSE; } +#endif /* __rtems__ */ /* writev -- bad iovcnt negative */ puts("writev bad iovcnt negative -- EINVAL"); @@ -271,6 +274,7 @@ int doErrorTest(void) return FALSE; } +#ifdef __rtems__ /* writev -- bad iov[i].iov_base */ vec[0].iov_base = vec; vec[0].iov_len = 100; @@ -296,6 +300,7 @@ int doErrorTest(void) fclose(fp); return FALSE; } +#endif /* __rtems__ */ /* writev -- bad iov[i].iov_len < 0 */ vec[0].iov_base = vec; @@ -310,12 +315,12 @@ int doErrorTest(void) return FALSE; } - /* readv -- bad iov[i].iov_len = 0 */ + /* readv -- bad iov[i].iov_len < 0 */ vec[0].iov_base = vec; vec[0].iov_len = 100; vec[1].iov_base = vec; vec[1].iov_len = -1024; - puts("readv bad iov[i].iov_len = 0 -- EINVAL"); + puts("readv bad iov[i].iov_len < 0 -- EINVAL"); rc = readv(fd, vec, 2); if ( (rc != -1) || (errno != EINVAL) ) { printf( "readv error 6: %d=%s\n", errno, strerror(errno) ); @@ -343,8 +348,10 @@ int doErrorTest(void) vec[0].iov_len = SIZE_MAX; vec[1].iov_base = vec; vec[1].iov_len = SIZE_MAX; + vec[2].iov_base = vec; + vec[2].iov_len = SIZE_MAX; puts("readv iov_len total overflows -- EINVAL"); - rc = readv(fd, vec, 2); + rc = readv(fd, vec, 3); if ( (rc != -1) || (errno != EINVAL) ) { printf( "read error 7: rc=%d %d=%s\n", rc, errno, strerror(errno) ); fclose(fp); @@ -377,6 +384,24 @@ int doErrorTest(void) return FALSE; } +#ifdef __rtems__ + puts("readv bad iovcnt of IOV_MAX + 1 -- EINVAL"); + rc = readv(fd, vec, IOV_MAX + 1); + if ( (rc != -1) || (errno != EINVAL) ) { + printf( "readv error 9: %d=%s\n", errno, strerror(errno) ); + fclose(fp); + return FALSE; + } + + puts("writev bad iovcnt of IOV_MAX + 1 -- EINVAL"); + rc = writev(fd, vec, IOV_MAX + 1); + if ( (rc != -1) || (errno != EINVAL) ) { + printf( "writev error 9: %d=%s\n", errno, strerror(errno) ); + fclose(fp); + return FALSE; + } +#endif /* __rtems__ */ + fclose(fp); return TRUE; } -- cgit v1.2.3