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/spfifo02 | |
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/spfifo02')
-rw-r--r-- | testsuites/sptests/spfifo02/Makefile.am | 5 | ||||
-rw-r--r-- | testsuites/sptests/spfifo02/init.c | 222 | ||||
-rw-r--r-- | testsuites/sptests/spfifo02/spfifo02.doc | 18 | ||||
-rw-r--r-- | testsuites/sptests/spfifo02/spfifo02.scn | 32 |
4 files changed, 185 insertions, 92 deletions
diff --git a/testsuites/sptests/spfifo02/Makefile.am b/testsuites/sptests/spfifo02/Makefile.am index fa1e55a4ab..10c076de16 100644 --- a/testsuites/sptests/spfifo02/Makefile.am +++ b/testsuites/sptests/spfifo02/Makefile.am @@ -5,7 +5,7 @@ MANAGERS = all rtems_tests_PROGRAMS = spfifo02 -spfifo02_SOURCES = init.c +spfifo02_SOURCES = init.c ../../support/src/spin.c dist_rtems_tests_DATA = spfifo02.scn dist_rtems_tests_DATA += spfifo02.doc @@ -14,14 +14,13 @@ 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 = $(spfifo02_OBJECTS) $(spfifo02_LDADD) LINK_LIBS = $(spfifo02_LDLIBS) spfifo02$(EXEEXT): $(spfifo02_OBJECTS) $(spfifo02_DEPENDENCIES) - @rm -f spfifo02$(EXEEXT) + @rm -f spfifo08$(EXEEXT) $(make-exe) include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/spfifo02/init.c b/testsuites/sptests/spfifo02/init.c index 3b17eda996..d564e13138 100644 --- a/testsuites/sptests/spfifo02/init.c +++ b/testsuites/sptests/spfifo02/init.c @@ -1,6 +1,6 @@ /* - * COPYRIGHT (c) 2010 - * Bharath Suri<bharath.s.jois@gmail.com>. + * COPYRIGHT (c) 1989-2010. + * 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 @@ -9,85 +9,207 @@ * $Id$ */ -/* Includes */ -#include <bsp.h> #include <tmacros.h> +#include "test_support.h" -/* Includes */ -#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> +#include <rtems/score/heap.h> -#include <rtems.h> -#include <rtems/libio.h> +#define MAXIMUM 10 +#define NUM_OPEN_REQ 26 +rtems_id Barriers[MAXIMUM]; +int BarrierCount; -void test_main(void) -{ +rtems_id Semaphores[MAXIMUM]; +int SemaphoreCount; - int status = -1; - int fd = 0; +extern Heap_Control *RTEMS_Malloc_Heap; - puts("\n\n*** FIFO / PIPE OPEN TEST - 2 ***"); - puts( -"\n\nConfiguration: Pipes configured, \ -but number of barriers configured = 0" - ); +void create_all_barriers(void) +{ + rtems_status_code status; + int i; + + BarrierCount = 0; + + memset( Barriers, 0, sizeof(Barriers) ); + for ( i=0 ; i<MAXIMUM ; i++ ) { + status = rtems_barrier_create( + rtems_build_name( 'B', 'A', 'R', 0x30+i ), + RTEMS_BARRIER_MANUAL_RELEASE, + 0, + &Barriers[i] + ); + if ( status == RTEMS_TOO_MANY ) { + printf( "%d Barriers created\n", BarrierCount+1 ); + return; + } + + directive_failed( status, "barrier create" ); + BarrierCount++; + } +} - puts("\n\nCreating directory /tmp"); - status = mkdir("/tmp", 0777); - rtems_test_assert(status == 0); +void create_all_semaphores(void) +{ + rtems_status_code status; + int i; + + SemaphoreCount = 0; + + for ( i=0 ; i<MAXIMUM ; i++ ) { + status = rtems_semaphore_create( + rtems_build_name( 'S', 'E', 'M', 0x30+i ), + 0, + RTEMS_DEFAULT_ATTRIBUTES, + 0, + &Semaphores[i] + ); + if ( status == RTEMS_TOO_MANY ) { + printf( "%d Semaphores created\n", SemaphoreCount+1 ); + return; + } + + directive_failed( status, "semaphore create" ); + SemaphoreCount++; + } +} - puts("\n\nCreating fifo /tmp/fifo"); - status = mkfifo("/tmp/fifo01", 0777); - rtems_test_assert(status == 0); +void delete_barrier(void) +{ + rtems_status_code status; + + BarrierCount--; + printf( "Deleting barrier id=0x%08x\n", + (unsigned int)Barriers[BarrierCount] ); + status = rtems_barrier_delete( Barriers[BarrierCount] ); + directive_failed( status, "barrier delete" ); +} - puts("\n\nAttempt to open the fifo file\n"); - puts( -"Must result in failure since \n\ -number of barriers = 0 => not all resources\n\ -were acquired" - ); - - 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"); - rtems_test_assert(status == 0); +void delete_semaphore(void) +{ + rtems_status_code status; + + SemaphoreCount--; + printf( "Deleting semaphore id=0x%08x\n", + (unsigned int) Semaphores[SemaphoreCount] ); + status = rtems_semaphore_delete( Semaphores[SemaphoreCount] ); + directive_failed( status, "semaphore delete" ); +} - puts("\n\nRemove directory /tmp"); - status = rmdir("/tmp"); +void create_fifo(void) +{ + int status; + + status = mkfifo("/fifo01", 0777); rtems_test_assert(status == 0); +} - puts("\n\n*** END OF FIFO / PIPE OPEN TEST - 2 ***"); +void open_fifo(int expected, int flags) +{ + int fd; + + fd = open("/fifo01", flags); + printf( "status=%d errno=%d/(%s)\n", fd, errno, strerror(errno) ); + if ( expected ) { + rtems_test_assert(fd == -1); + rtems_test_assert(errno == expected); + } else { + rtems_test_assert(fd != -1); + close( fd ); + } } - + rtems_task Init( - rtems_task_argument not_used + rtems_task_argument argument ) { - test_main(); + void *alloc_ptr = (void *)0; + int num_opens = 0; + int index = 0; + Heap_Information_block Info; + + puts( "\n\n*** TEST FIFO 08 ***" ); + + puts( "Creating all barriers" ); + create_all_barriers(); + + puts( "Creating all semaphores" ); + create_all_semaphores(); + + puts( "Creating FIFO" ); + create_fifo(); + + puts( "Opening FIFO.. expect ENFILE (semaphore @ open could not be created)" ); + open_fifo(ENFILE, O_RDWR); + + delete_semaphore(); + puts( "Opening FIFO.. expect ENOMEM (semaphore for pipe could not be created)" ); + open_fifo(ENOMEM, O_RDWR); + + delete_semaphore(); + + _Heap_Get_information(RTEMS_Malloc_Heap, &Info); + alloc_ptr = malloc(Info.Free.largest-4); + puts("Opening FIFO.. expect ENOMEM since no memory is available"); + open_fifo(ENOMEM, O_RDWR); + + free(alloc_ptr); + puts( "Opening FIFO.. expect ENOMEM (barrier-1 for pipe could not be created)" ); + open_fifo(ENOMEM, O_RDWR); + + delete_barrier(); + puts( "Opening FIFO.. expect ENOMEM (barrier-2 for pipe could not be created" ); + open_fifo(ENOMEM, O_RDWR); + + delete_barrier(); + puts( "Opening FIFO.. expect ENOMEM (semaphore-1 for pipe could not be created" ); + open_fifo(ENOMEM, O_RDWR); + + delete_semaphore(); + puts( "Opening FIFO in RDWR mode. Expect OK" ); + open_fifo(0, O_RDWR); + ++num_opens; + + puts( "Opening FIFO in non blocking RDONLY mode. Expect OK"); + open_fifo(0, O_RDONLY | O_NONBLOCK); + ++num_opens; + + puts( "Opening FIFO in non blocking WRONLY mode. Expect ENXIO"); + open_fifo(ENXIO, O_WRONLY | O_NONBLOCK); + ++num_opens; + + puts("\nMultiple opens\n"); + for(index = 0; index < NUM_OPEN_REQ - num_opens; ++index) { + + open_fifo(0, O_RDONLY | O_NONBLOCK); + printf("%d... ", index+1); + } + + puts( "*** END OF TEST FIFO 08 ***" ); + rtems_test_exit(0); } +/* configuration information */ + #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER -#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM -#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 6 +#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE -#define CONFIGURE_PIPES_ENABLED -#define CONFIGURE_MAXIMUM_PIPES 1 -#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5 +#define CONFIGURE_FIFOS_ENABLED +#define CONFIGURE_MAXIMUM_FIFOS 1 -#define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_INIT #include <rtems/confdefs.h> - /* end of file */ diff --git a/testsuites/sptests/spfifo02/spfifo02.doc b/testsuites/sptests/spfifo02/spfifo02.doc index 3b0b8200da..06ae9b9d43 100644 --- a/testsuites/sptests/spfifo02/spfifo02.doc +++ b/testsuites/sptests/spfifo02/spfifo02.doc @@ -1,8 +1,8 @@ # # $Id$ # -# COPYRIGHT (c) 2010 -# Bharath Suri<bharath.s.jois@gmail.com>. +# COPYRIGHT (c) 1989-2010. +# 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 @@ -11,12 +11,14 @@ This file describes the directives and concepts tested by this test set. -Configuration: +test set name: spfifo08 -Pipes enabled. Maximum number of barriers is not defined and hence = -0. +directives: -Expected: + mkfifo() + open() - on FIFOs -Pipe requires 2 barriers to be created. With max number of barriers -set to 0, fifo_open fails with EINTR +concepts: + ++ memory allocation error cases ++ resource allocation error cases diff --git a/testsuites/sptests/spfifo02/spfifo02.scn b/testsuites/sptests/spfifo02/spfifo02.scn index c4cf9fee19..a63612096b 100644 --- a/testsuites/sptests/spfifo02/spfifo02.scn +++ b/testsuites/sptests/spfifo02/spfifo02.scn @@ -1,31 +1 @@ -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 - 2 ***
-
-
-Configuration: Pipes configured, but number of barriers configured = 0
-
-
-Creating directory /tmp
-
-
-Creating fifo /tmp/fifo
-
-
-Attempt to open the fifo file
-
-Must result in failure since
-number of barriers = 0 => not all resources
-were acquired
-
-
-Remove the entry /tmp/fifo01
-
-
-Remove directory /tmp
-
-
-*** END OF FIFO / PIPE OPEN TEST - 2 ***
+XXX fill in with test output |