diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-06-24 19:46:40 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-06-24 19:46:40 +0000 |
commit | 287febb50397f321d5a38f8d7df668833c192125 (patch) | |
tree | 55a6185fe030fc3190925d939ea680980c76f736 /testsuites/sptests/spfifo03 | |
parent | 2010-06-24 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff) | |
download | rtems-287febb50397f321d5a38f8d7df668833c192125.tar.bz2 |
2010-06-24 Bharath Suri <bharath.s.jois@gmail.com>
* Makefile.am, configure.ac: Removed some fifo tests.
* spfifo01/Makefile.am, spfifo01/init.c: Minor changes to avoid
excessive new lines in the output.
spfifo02/Makefile.am, spfifo02/init.c, spfifo02/spfifo02.doc,
spfifo02/spfifo02.scn, spfifo03/Makefile.am: Merge from spfifo08.
Also added a few more cases, mostly from spfifo04/init.c.
* spfifo03/init.c, spfifo03/spfifo03.doc, spfifo03/spfifo03.scn:
Previously was spfifo06. Configure parameter for pipes is used now.
* spfifo04/.cvsignore, spfifo04/Makefile.am, spfifo04/init.c,
spfifo04/spfifo04.doc, spfifo04/spfifo04.scn, spfifo08/.cvsignore,
spfifo08/Makefile.am, spfifo08/init.c, spfifo08/spfifo08.doc,
spfifo08/spfifo08.scn: Removed.
Diffstat (limited to 'testsuites/sptests/spfifo03')
-rw-r--r-- | testsuites/sptests/spfifo03/Makefile.am | 1 | ||||
-rw-r--r-- | testsuites/sptests/spfifo03/init.c | 196 | ||||
-rw-r--r-- | testsuites/sptests/spfifo03/spfifo03.doc | 18 | ||||
-rw-r--r-- | testsuites/sptests/spfifo03/spfifo03.scn | 35 |
4 files changed, 200 insertions, 50 deletions
diff --git a/testsuites/sptests/spfifo03/Makefile.am b/testsuites/sptests/spfifo03/Makefile.am index f4e8662b70..77a4f63866 100644 --- a/testsuites/sptests/spfifo03/Makefile.am +++ b/testsuites/sptests/spfifo03/Makefile.am @@ -14,7 +14,6 @@ include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg include $(top_srcdir)/../automake/compile.am include $(top_srcdir)/../automake/leaf.am - AM_CPPFLAGS += -I$(top_srcdir)/../support/include LINK_OBJS = $(spfifo03_OBJECTS) $(spfifo03_LDADD) diff --git a/testsuites/sptests/spfifo03/init.c b/testsuites/sptests/spfifo03/init.c index 4902a3bacc..610c328165 100644 --- a/testsuites/sptests/spfifo03/init.c +++ b/testsuites/sptests/spfifo03/init.c @@ -1,6 +1,16 @@ -/* - * COPYRIGHT (c) 2010 - * Bharath Suri<bharath.s.jois@gmail.com>. +/* Init + * + * This routine is the initialization task for this test program. + * It is a user initialization task and has the responsibility + * of invoking the test routine + * + * Input parameters: + * not_used + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -22,48 +32,169 @@ #include <rtems.h> #include <rtems/libio.h> +#define SEND_RCV_BUFSIZ 12 +rtems_id Barrier; -void test_main(void) +rtems_task read_task(rtems_task_argument not_used) { + int fd = 0; + int status = -1; + + char recvBuf_r1[SEND_RCV_BUFSIZ] = {0}; + char recvBuf_r2[SEND_RCV_BUFSIZ] = {0}; + + puts("\nRead task activated, waiting till writer opens"); + + status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT ); + rtems_test_assert( status == RTEMS_SUCCESSFUL ); + + sleep(1); + + puts("\nNow, reader opening file(1)"); + fd = open("/tmp/fifo01", O_RDONLY); + if(fd <= 0) { + printf("Error opening file: (%d) :: %s", errno, strerror(errno)); + rtems_test_assert(0); + } + + status = read(fd, recvBuf_r1, sizeof(recvBuf_r1)-1); + rtems_test_assert(status == sizeof(recvBuf_r1)-1); + + printf("\n@ receiver (being a unblocked reader): Got %s", recvBuf_r1); + + status = close(fd); + rtems_test_assert(status == 0); + + status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT ); + rtems_test_assert( status == RTEMS_SUCCESSFUL ); + + puts("\nReader opening file(2)"); + fd = open("/tmp/fifo01", O_RDONLY); + if(fd <= 0) { + printf("Error opening file: (%d) :: %s", errno, strerror(errno)); + rtems_test_assert(0); + } + + status = read(fd, recvBuf_r2, sizeof(recvBuf_r2)-1); + rtems_test_assert(status == sizeof(recvBuf_r2)-1); + + printf("\n@ receiver (being a blocked reader): Got %s", recvBuf_r2); + + status = close(fd); + rtems_test_assert(status == 0); + + + puts("\nReader done!"); + status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT ); + rtems_test_assert( status == RTEMS_SUCCESSFUL ); + rtems_task_delete( RTEMS_SELF ); +} + + +void test_main(void) //Also acts as the write task +{ + + rtems_id readTaskID; + rtems_name readTaskName; + + char sendBuf_r1[SEND_RCV_BUFSIZ] = {0}; + char sendBuf_r2[SEND_RCV_BUFSIZ] = {0}; int status = -1; int fd = 0; - puts("\n\n*** FIFO / PIPE OPEN TEST - 3 ***"); - puts( -"\n\nConfiguration: Pipes configured, \ -but number of barriers configured = 1\n\ -Required number of barriers = 2" - ); - puts("\n\nCreating directory /tmp"); + strcpy( sendBuf_r1, "SendBuffer1" ); + strcpy( sendBuf_r2, "SendBuffer2" ); + + memset( &Barrier, 0, sizeof(Barrier) ); + status = rtems_barrier_create ( + rtems_build_name ( 'B', 'A', 'R', 't' ), + RTEMS_BARRIER_AUTOMATIC_RELEASE, + 2, + &Barrier + ); + + rtems_test_assert( status == RTEMS_SUCCESSFUL ); + + puts("\n\n*** FIFO / PIPE OPEN TEST - 6 ***"); + + puts("\nCreating a task name and a task"); + readTaskName = rtems_build_name('T','A','r',' '); + + status = rtems_task_create( + readTaskName, + 1, + RTEMS_MINIMUM_STACK_SIZE * 2, + RTEMS_INTERRUPT_LEVEL(31), + RTEMS_DEFAULT_ATTRIBUTES, + &readTaskID + ); + + rtems_test_assert( status == RTEMS_SUCCESSFUL ); + + puts("\ncreating directory /tmp"); status = mkdir("/tmp", 0777); rtems_test_assert(status == 0); - puts("\n\nCreating fifo /tmp/fifo"); + puts("\ncreating fifo file /tmp/fifo01"); status = mkfifo("/tmp/fifo01", 0777); rtems_test_assert(status == 0); - puts("\n\nAttempt to open the fifo file\n"); - puts( -"Must result in failure since \n\ -number of barriers = 1 => not all resources\n\ -were acquired" - ); + puts("\nStarting the read task"); + status = rtems_task_start(readTaskID, read_task, 0); + rtems_test_assert(status == 0); - fd = open("/tmp/fifo01", O_RDONLY); - rtems_test_assert(fd == -1); - rtems_test_assert(errno == EINTR); // Should this - // be ENOMEM? - puts("\n\nRemove the entry /tmp/fifo01"); - status = unlink("/tmp/fifo01"); + status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT ); + rtems_test_assert( status == RTEMS_SUCCESSFUL ); + + puts("\nWriter opening file(1)"); + fd = open("/tmp/fifo01", O_WRONLY); + if(fd <= 0) { + printf("Error opening file: (%d) :: %s", errno, strerror(errno)); + rtems_test_assert(0); + } + + + printf("\n@ sender: %s", sendBuf_r1); + status = write(fd, sendBuf_r1, sizeof(sendBuf_r1)-1); + rtems_test_assert(status == sizeof(sendBuf_r1)-1); + + status = close(fd); rtems_test_assert(status == 0); + + status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT ); + rtems_test_assert( status == RTEMS_SUCCESSFUL ); - puts("\n\nRemove directory /tmp"); - status = rmdir("/tmp"); + sleep(1); + + // Reader would have blocked by now + puts("\nWriter opening file(2)"); + fd = open("/tmp/fifo01", O_WRONLY); + if(fd <= 0) { + printf("Error opening file: (%d) :: %s", errno, strerror(errno)); + rtems_test_assert(0); + } + + printf("\n@ sender: %s", sendBuf_r2); + status = write(fd, sendBuf_r2, sizeof(sendBuf_r2)-1); + rtems_test_assert(status == sizeof(sendBuf_r2)-1); + + status = close(fd); rtems_test_assert(status == 0); - puts("\n\n*** END OF FIFO / PIPE OPEN TEST - 3 ***"); + status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT ); + rtems_test_assert( status == RTEMS_SUCCESSFUL ); + + puts( "Removing the fifo" ); + status = unlink("/tmp/fifo01"); + rtems_test_assert(status == 0); + + puts( "Removing /tmp" ); + status = rmdir("/tmp"); + rtems_test_assert(status == 0); + + puts("\n*** END OF FIFO / PIPE OPEN TEST - 6 ***"); } rtems_task Init( @@ -80,13 +211,18 @@ rtems_task Init( #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 6 -#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_MAXIMUM_TASKS 3 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE -#define CONFIGURE_PIPES_ENABLED -#define CONFIGURE_MAXIMUM_PIPES 1 + +#define CONFIGURE_MAXIMUM_BARRIERS 1 + #define CONFIGURE_INIT +#define CONFIGURE_FIFOS_ENABLED +#define CONFIGURE_MAXIMUM_FIFOS 1 + +#define CONFIGURE_INIT #include <rtems/confdefs.h> /* end of file */ diff --git a/testsuites/sptests/spfifo03/spfifo03.doc b/testsuites/sptests/spfifo03/spfifo03.doc index 7c74bcbe1d..20a36b4b92 100644 --- a/testsuites/sptests/spfifo03/spfifo03.doc +++ b/testsuites/sptests/spfifo03/spfifo03.doc @@ -1,8 +1,8 @@ # # $Id$ # -# COPYRIGHT (c) 2010 -# Bharath Suri<bharath.s.jois@gmail.com>. +# COPYRIGHT (c) 1989-1999. +# On-Line Applications Research Corporation (OAR). # # The license and distribution terms for this file may be # found in the file LICENSE in this distribution or at @@ -13,9 +13,15 @@ This file describes the directives and concepts tested by this test set. Configuration: -Pipes enabled. Maximum number of barriers is set to 1. +- Pipes enabled +- Resources available >= Resources required + - Semaphores, pipes, barriers etc. -Expected: +Coverage concepts: -Pipe requires 2 barriers to be created. With max number of barriers -set to 1, fifo_open fails with EINTR +- Main task also acts as the write task +- Main task creates another task: for reading +- Write task is responsible for writing to the pipe and the read task + reads from the pipe +- The pipe is opened twice, such that the write task blocks on open + once and the read task blocks on open the 2nd time diff --git a/testsuites/sptests/spfifo03/spfifo03.scn b/testsuites/sptests/spfifo03/spfifo03.scn index 49dc5ebe8a..a0ccdb7db9 100644 --- a/testsuites/sptests/spfifo03/spfifo03.scn +++ b/testsuites/sptests/spfifo03/spfifo03.scn @@ -1,32 +1,41 @@ -Could not open '/dev/kqemu' - QEMU acceleration layer not activated: No such file or directory Initialized console on port COM1 9600-8-N-1 -*** FIFO / PIPE OPEN TEST - 3 ***
+*** FIFO / PIPE OPEN TEST - 6 ***
-Configuration: Pipes configured, but number of barriers configured = 1
-Required number of barriers = 2
+Creating a task name and a task
-Creating directory /tmp
+creating directory /tmp
-Creating fifo /tmp/fifo
+creating fifo file /tmp/fifo01
-Attempt to open the fifo file
+Starting the read task
-Must result in failure since
-number of barriers = 1 => not all resources
-were acquired
+Writer opening file(1)
-Remove the entry /tmp/fifo01
+Read task activated, sleeping to block the writer
-Remove directory /tmp
+Now, reader opening file(1)
-*** END OF FIFO / PIPE OPEN TEST - 3 ***
+
+@ sender:
+
+@ receiver (being a unblocked reader): Got
+
+Reader opening file(2)
+
+
+Writer opening file(2)
+
+
+@ sender: SendBuffer2
+
+*** END OF FIFO / PIPE OPEN TEST - 6 ***
|