summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-11-01 17:33:08 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-11-01 17:33:08 +0000
commita14b982755d43c8b1b6795996625dce357a28714 (patch)
treece45fc6c4da1f98fce20824c6ffc2451ebbc3661 /testsuites
parent2010-11-01 Alin Rus <alin.codejunkie@gmail.com> (diff)
downloadrtems-a14b982755d43c8b1b6795996625dce357a28714.tar.bz2
2010-11-01 Alin Rus <alin.codejunkie@gmail.com>
* psxaio01/init.c, psxaio02/init.c: Improve coverage.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/psxtests/ChangeLog4
-rw-r--r--testsuites/psxtests/psxaio01/init.c148
-rw-r--r--testsuites/psxtests/psxaio02/init.c172
3 files changed, 178 insertions, 146 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog
index f09ac1de62..a8e22cd71c 100644
--- a/testsuites/psxtests/ChangeLog
+++ b/testsuites/psxtests/ChangeLog
@@ -1,3 +1,7 @@
+2010-11-01 Alin Rus <alin.codejunkie@gmail.com>
+
+ * psxaio01/init.c, psxaio02/init.c: Improve coverage.
+
2010-10-21 Joel Sherrill <joel.sherrill@oarcorp.com>
* psx05/init.c: Check for correct status returned.
diff --git a/testsuites/psxtests/psxaio01/init.c b/testsuites/psxtests/psxaio01/init.c
index 7af884201f..d4e8e05803 100644
--- a/testsuites/psxtests/psxaio01/init.c
+++ b/testsuites/psxtests/psxaio01/init.c
@@ -24,7 +24,7 @@
#define WRONG_FD 404
struct aiocb *
-create_aiocb (void)
+create_aiocb (int fd)
{
struct aiocb *aiocbp;
@@ -34,7 +34,7 @@ create_aiocb (void)
aiocbp->aio_nbytes = BUFSIZE;
aiocbp->aio_offset = 0;
aiocbp->aio_reqprio = 0;
- aiocbp->aio_fildes = open ("aio_fildes", O_RDWR | O_CREAT);
+ aiocbp->aio_fildes = fd;
return aiocbp;
}
@@ -49,101 +49,145 @@ free_aiocb (struct aiocb *aiocbp)
void *
POSIX_Init (void *argument)
{
- int result, policy;
+ int result, fd;
struct aiocb *aiocbp;
- rtems_status_code status;
- struct sched_param param;
+ int status;
+
+ rtems_aio_init ();
+
+ status = mkdir ("/tmp", S_IRWXU);
+ rtems_test_assert (!status);
+
+ fd = open ("/tmp/aio_fildes", O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
+ rtems_test_assert ( fd != -1);
puts ("\n\n*** POSIX AIO TEST 01 ***");
- puts ("\n*** POSIX aio_write() test ***");
+ puts (" Init: EBADF TESTS ");
- /* Request canceled */
- puts ("Init: aio_write - ECANCELED");
+ aiocbp = create_aiocb (WRONG_FD);
+ status = aio_write (aiocbp);
+ rtems_test_assert (status == -1);
+
+ /* Bad file descriptor */
+ puts ("Init: aio_write() - EBADF ");
- aiocbp = create_aiocb ();
- aio_write (aiocbp);
- aio_cancel (aiocbp->aio_fildes, aiocbp);
result = aio_return (aiocbp);
- rtems_test_assert (result != -1);
+ rtems_test_assert (result == -1);
status = aio_error (aiocbp);
- rtems_test_assert (status != ECANCELED);
- free_aiocb (aiocbp);
+ rtems_test_assert (status == EBADF);
- /* Successfull added request to queue */
- puts ("Init: aio_write - SUCCESSFUL");
- aiocbp = create_aiocb ();
- aiocbp->aio_fildes = WRONG_FD;
- status = aio_write (aiocbp);
- rtems_test_assert (!status);
+ status = aio_read (aiocbp);
+ rtems_test_assert (status == -1);
+
+ /* Bad file descriptor */
+ puts ("Init: aio_read() - EBADF ");
- pthread_getschedparam (pthread_self (), &policy, &param);
- policy = SCHED_RR;
- param.sched_priority = 30;
- pthread_setschedparam (pthread_self (), policy, &param);
- sleep (1);
+ result = aio_return (aiocbp);
+ rtems_test_assert (result == -1);
+ status = aio_error (aiocbp);
+ rtems_test_assert (status == EBADF);
- while (aio_error (aiocbp) == EINPROGRESS);
+ status = aio_cancel (WRONG_FD, NULL);
+ rtems_test_assert (status == -1);
/* Bad file descriptor */
- puts ("Init: aio_write() - EBADF ");
+ puts ("Init: aio_cancel() - EBADF ");
+
+ result = aio_return (aiocbp);
+ rtems_test_assert (result == -1);
+ status = aio_error (aiocbp);
+ rtems_test_assert (status == EBADF);
+
+ status = aio_fsync (O_SYNC, aiocbp);
+ rtems_test_assert (status == -1);
+
+ /* Bad file descriptor */
+ puts ("Init: aio_fsync() - EBADF ");
result = aio_return (aiocbp);
- rtems_test_assert (result != -1);
+ rtems_test_assert (result == -1);
status = aio_error (aiocbp);
- rtems_test_assert (status != EBADF);
+ rtems_test_assert (status == EBADF);
+
free_aiocb (aiocbp);
/* Invalid offset */
puts ("Init: aio_write() - EINVAL [aio_offset]");
- aiocbp = create_aiocb ();
+ aiocbp = create_aiocb (fd);
aiocbp->aio_offset = -1;
- aio_write (aiocbp);
- sleep (1);
+ status = aio_write (aiocbp);
+ rtems_test_assert (status == -1);
+
+ result = aio_return (aiocbp);
+ rtems_test_assert (result == -1);
+ status = aio_error (aiocbp);
+ rtems_test_assert (status == EINVAL);
- while (aio_error (aiocbp) == EINPROGRESS);
+ /* Invalid offset */
+ puts ("Init: aio_read() - EINVAL [aio_offset]");
+
+ status = aio_read (aiocbp);
+ rtems_test_assert (status == -1);
result = aio_return (aiocbp);
- rtems_test_assert (result != -1);
+ rtems_test_assert (result == -1);
status = aio_error (aiocbp);
- rtems_test_assert (status != EINVAL);
+ rtems_test_assert (status == EINVAL);
+
free_aiocb (aiocbp);
/* Invalid request priority */
puts ("Init: aio_write() - EINVAL [aio_reqprio]");
- aiocbp = create_aiocb ();
+ aiocbp = create_aiocb (fd);
aiocbp->aio_reqprio = AIO_PRIO_DELTA_MAX + 1;
- aio_write (aiocbp);
- sleep (1);
+ status = aio_write (aiocbp);
+ rtems_test_assert (status == -1);
+
+ result = aio_return (aiocbp);
+ rtems_test_assert (result == -1);
+ status = aio_error (aiocbp);
+ rtems_test_assert (status == EINVAL);
+
+ /* Invalid request priority */
+ puts ("Init: aio_read() - EINVAL [aio_reqprio]");
- while (aio_error (aiocbp) == EINPROGRESS);
+ status = aio_read (aiocbp);
+ rtems_test_assert (status == -1);
result = aio_return (aiocbp);
- rtems_test_assert (result != -1);
+ rtems_test_assert (result == -1);
status = aio_error (aiocbp);
- rtems_test_assert (status != EINVAL);
- free_aiocb (aiocbp);
+ rtems_test_assert (status == EINVAL);
- /* aio_nbytes > 0 and aio_offset >= SEEK_END */
- puts ("Init: aio_write() - EFBIG");
- aiocbp = create_aiocb ();
- aiocbp->aio_nbytes = 1;
- aiocbp->aio_offset = lseek (aiocbp->aio_fildes, 0, SEEK_END) + 1;
- aio_write (aiocbp);
- sleep (1);
+ /* Invalid request aio_cancel */
+ puts ("Init: aio_cancel() - EINVAL ");
- while (aio_error (aiocbp) == EINPROGRESS);
+ status = aio_cancel (WRONG_FD, aiocbp);
+ rtems_test_assert (status == -1);
result = aio_return (aiocbp);
- rtems_test_assert (result != -1);
+ rtems_test_assert (result == -1);
status = aio_error (aiocbp);
- rtems_test_assert (status != EFBIG);
+ rtems_test_assert (status == EINVAL);
+
+ /* Invalid operation to aio_fsync */
+ puts ("Init: aio_fsync() - EINVAL ");
+ status = aio_fsync (-1, aiocbp);
+ rtems_test_assert (status == -1);
+
+ result = aio_return (aiocbp);
+ rtems_test_assert (result == -1);
+ status = aio_error (aiocbp);
+ rtems_test_assert (status == EINVAL);
+
free_aiocb (aiocbp);
puts ("*** END OF POSIX AIO TEST 01 ***");
+ close (fd);
rtems_test_exit (0);
return NULL;
diff --git a/testsuites/psxtests/psxaio02/init.c b/testsuites/psxtests/psxaio02/init.c
index 240dd30e4c..7a1882c852 100644
--- a/testsuites/psxtests/psxaio02/init.c
+++ b/testsuites/psxtests/psxaio02/init.c
@@ -19,12 +19,13 @@
#include <stdio.h>
#include <sched.h>
#include <fcntl.h>
+#include <rtems/chain.h>
-#define BUFSIZE 512
-#define WRONG_FD 404
+#define BUFSIZE 32
+#define MAX 7
struct aiocb *
-create_aiocb (void)
+create_aiocb (int fd)
{
struct aiocb *aiocbp;
@@ -34,7 +35,7 @@ create_aiocb (void)
aiocbp->aio_nbytes = BUFSIZE;
aiocbp->aio_offset = 0;
aiocbp->aio_reqprio = 0;
- aiocbp->aio_fildes = open ("aio_fildes", O_RDWR | O_CREAT);
+ aiocbp->aio_fildes = fd;
return aiocbp;
}
@@ -49,101 +50,84 @@ free_aiocb (struct aiocb *aiocbp)
void *
POSIX_Init (void *argument)
{
- int result, policy;
- struct aiocb *aiocbp;
- rtems_status_code status;
- struct sched_param param;
-
- puts ("\n\n*** POSIX AIO TEST 02 ***");
-
- puts ("\n*** POSIX aio_read() test ***");
-
- /* Request canceled */
- puts ("Init: aio_read - ECANCELED");
-
- aiocbp = create_aiocb ();
- aio_read (aiocbp);
- aio_cancel (aiocbp->aio_fildes, aiocbp);
- result = aio_return (aiocbp);
- rtems_test_assert (result != -1);
- status = aio_error (aiocbp);
- rtems_test_assert (status != ECANCELED);
- free_aiocb (aiocbp);
-
- /* Successfull added request to queue */
- puts ("Init: aio_read - SUCCESSFUL");
- aiocbp = create_aiocb ();
- aiocbp->aio_fildes = WRONG_FD;
- status = aio_read (aiocbp);
+ int fd[MAX];
+ struct aiocb *aiocbp[MAX+2];
+ int status, i;
+ char filename[BUFSIZE];
+
+ status = rtems_aio_init ();
+ rtems_test_assert (status == 0);
+
+ status = mkdir ("/tmp", S_IRWXU);
rtems_test_assert (!status);
+
+ puts ("\n\n*** POSIX AIO TEST 02 ***");
+
+ puts (" Init: Open files ");
+
+ for (i=0; i<MAX; i++)
+ {
+ sprintf (filename, "/tmp/aio_fildes%d",i);
+ fd[i] = open (filename, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
+ rtems_test_assert ( fd[i] != -1);
+ }
+
+ puts (" Init: [WQ] aio_write on 1st file ");
+ aiocbp[0] = create_aiocb (fd[0]);
+ status = aio_write (aiocbp[0]);
+ rtems_test_assert (status != -1);
+
+ puts (" Init: [WQ] aio_write on 2nd file ");
+ aiocbp[1] = create_aiocb (fd[1]);
+ status = aio_write (aiocbp[1]);
+ rtems_test_assert (status != -1);
+
+ puts (" Init: [WQ] aio_read on 2nd file add by priority ");
+ aiocbp[2] = create_aiocb (fd[1]);
+ status = aio_read (aiocbp[2]);
+ rtems_test_assert (status != -1);
+
+ puts (" Init: [WQ] aio_write on 3rd file ");
+ aiocbp[3] = create_aiocb (fd[2]);
+ status = aio_write (aiocbp[3]);
+ rtems_test_assert (status != -1);
+
+ puts (" Init: [WQ] aio_write on 4th file ");
+ aiocbp[4] = create_aiocb (fd[3]);
+ status = aio_write (aiocbp[4]);
+ rtems_test_assert (status != -1);
+
+ puts (" Init: [WQ] aio_write on 5th file -- [WQ] full ");
+ aiocbp[5] = create_aiocb (fd[4]);
+ status = aio_write (aiocbp[5]);
+ rtems_test_assert (status != -1);
+
+ puts (" Init: [IQ] aio_write on 6th file ");
+ aiocbp[6] = create_aiocb (fd[5]);
+ status = aio_write (aiocbp[6]);
+ rtems_test_assert (status != -1);
+
+ puts (" Init: [IQ] aio_write on 7th file ");
+ aiocbp[7] = create_aiocb (fd[6]);
+ status = aio_write (aiocbp[7]);
+ rtems_test_assert (status != -1);
+
+ puts (" Init: [IQ] aio_read on 7th file add by priority ");
+ aiocbp[8] = create_aiocb (fd[6]);
+ status = aio_read (aiocbp[8]);
+ rtems_test_assert (status != -1);
- pthread_getschedparam (pthread_self (), &policy, &param);
- policy = SCHED_RR;
- param.sched_priority = 30;
- pthread_setschedparam (pthread_self (), policy, &param);
- sleep (1);
-
- while (aio_error (aiocbp) == EINPROGRESS);
-
- /* Bad file descriptor */
- puts ("Init: aio_read() - EBADF ");
-
- result = aio_return (aiocbp);
- rtems_test_assert (result != -1);
- status = aio_error (aiocbp);
- rtems_test_assert (status != EBADF);
- free_aiocb (aiocbp);
-
- /* Invalid offset */
- puts ("Init: aio_read() - EINVAL [aio_offset]");
-
- aiocbp = create_aiocb ();
- aiocbp->aio_offset = -1;
- aio_read (aiocbp);
- sleep (1);
-
- while (aio_error (aiocbp) == EINPROGRESS);
-
- result = aio_return (aiocbp);
- rtems_test_assert (result != -1);
- status = aio_error (aiocbp);
- rtems_test_assert (status != EINVAL);
- free_aiocb (aiocbp);
-
- /* Invalid request priority */
- puts ("Init: aio_read() - EINVAL [aio_reqprio]");
-
- aiocbp = create_aiocb ();
- aiocbp->aio_reqprio = AIO_PRIO_DELTA_MAX + 1;
- aio_read (aiocbp);
- sleep (1);
-
- while (aio_error (aiocbp) == EINPROGRESS);
-
- result = aio_return (aiocbp);
- rtems_test_assert (result != -1);
- status = aio_error (aiocbp);
- rtems_test_assert (status != EINVAL);
- free_aiocb (aiocbp);
-
- /* aio_nbytes > 0 && aio_nbytes + aio_offset > max offset of aio_fildes */
- puts ("Init: aio_read() - OVERFLOW");
- aiocbp = create_aiocb ();
- aiocbp->aio_nbytes = 10;
- aiocbp->aio_offset = lseek (aiocbp->aio_fildes, 0, SEEK_END);
- aio_read (aiocbp);
- sleep (1);
-
- while (aio_error (aiocbp) == EINPROGRESS);
-
- result = aio_return (aiocbp);
- rtems_test_assert (result != -1);
- status = aio_error (aiocbp);
- rtems_test_assert (status != EFBIG);
- free_aiocb (aiocbp);
+ puts ("\n\n*** POSIX AIO TEST 02 ***");
puts ("*** END OF POSIX AIO TEST 01 ***");
+ for (i = 0; i < MAX; i++)
+ {
+ close (fd[i]);
+ free_aiocb (aiocbp[i]);
+ }
+ free_aiocb (aiocbp[i]);
+ free_aiocb (aiocbp[i+1]);
rtems_test_exit (0);
return NULL;