summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxaio01
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/psxtests/psxaio01
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/psxtests/psxaio01')
-rw-r--r--testsuites/psxtests/psxaio01/init.c148
1 files changed, 96 insertions, 52 deletions
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;