change log for rtems (2010-06-24)

rtems-vc at rtems.org rtems-vc at rtems.org
Thu Jun 24 20:12:58 UTC 2010


 *joel*:
2010-06-24	Bharath Suri <bharath.s.jois at 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.

M  1.384  testsuites/sptests/ChangeLog
M   1.92  testsuites/sptests/Makefile.am
M   1.97  testsuites/sptests/configure.ac
M    1.3  testsuites/sptests/spfifo01/Makefile.am
M    1.4  testsuites/sptests/spfifo01/init.c
M    1.3  testsuites/sptests/spfifo02/Makefile.am
M    1.4  testsuites/sptests/spfifo02/init.c
M    1.3  testsuites/sptests/spfifo02/spfifo02.doc
M    1.2  testsuites/sptests/spfifo02/spfifo02.scn
M    1.3  testsuites/sptests/spfifo03/Makefile.am
M    1.4  testsuites/sptests/spfifo03/init.c
M    1.3  testsuites/sptests/spfifo03/spfifo03.doc
M    1.2  testsuites/sptests/spfifo03/spfifo03.scn
R    1.1  testsuites/sptests/spfifo04/.cvsignore
R    1.2  testsuites/sptests/spfifo04/Makefile.am
R    1.3  testsuites/sptests/spfifo04/init.c
R    1.2  testsuites/sptests/spfifo04/spfifo04.doc
R    1.1  testsuites/sptests/spfifo04/spfifo04.scn
R    1.1  testsuites/sptests/spfifo08/.cvsignore
R    1.1  testsuites/sptests/spfifo08/Makefile.am
R    1.2  testsuites/sptests/spfifo08/init.c
R    1.1  testsuites/sptests/spfifo08/spfifo08.doc
R    1.1  testsuites/sptests/spfifo08/spfifo08.scn

diff -u rtems/testsuites/sptests/ChangeLog:1.383 rtems/testsuites/sptests/ChangeLog:1.384
--- rtems/testsuites/sptests/ChangeLog:1.383	Tue Jun 22 11:14:43 2010
+++ rtems/testsuites/sptests/ChangeLog	Thu Jun 24 14:46:40 2010
@@ -1,3 +1,19 @@
+2010-06-24	Bharath Suri <bharath.s.jois at 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.
+
 2010-06-22	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
 	* Makefile.am, configure.ac: Add new test to exercise path where using

diff -u rtems/testsuites/sptests/Makefile.am:1.91 rtems/testsuites/sptests/Makefile.am:1.92
--- rtems/testsuites/sptests/Makefile.am:1.91	Tue Jun 22 11:14:43 2010
+++ rtems/testsuites/sptests/Makefile.am	Thu Jun 24 14:46:40 2010
@@ -20,7 +20,7 @@
     spfatal01 spfatal02 spfatal03 spfatal04 spfatal05 spfatal06 spfatal07 \
     spfatal08 spfatal09 spfatal10 spfatal11 spfatal12 spfatal13 spfatal14 \
     spfatal15 spfatal16 spfatal17 spfatal18 spfatal19 \
-    spfifo01 spfifo02 spfifo03 spfifo04 spfifo08 \
+    spfifo01 spfifo02 spfifo03 \
     spintrcritical01 spintrcritical02 spintrcritical03 spintrcritical04 \
     spintrcritical05 spintrcritical06 spintrcritical07 spintrcritical08 \
     spintrcritical09 spintrcritical10 spintrcritical11 spintrcritical12 \

diff -u rtems/testsuites/sptests/configure.ac:1.96 rtems/testsuites/sptests/configure.ac:1.97
--- rtems/testsuites/sptests/configure.ac:1.96	Tue Jun 22 11:14:43 2010
+++ rtems/testsuites/sptests/configure.ac	Thu Jun 24 14:46:40 2010
@@ -122,8 +122,6 @@
 spfifo01/Makefile
 spfifo02/Makefile
 spfifo03/Makefile
-spfifo04/Makefile
-spfifo08/Makefile
 spintrcritical01/Makefile
 spintrcritical02/Makefile
 spintrcritical03/Makefile

diff -u rtems/testsuites/sptests/spfifo01/Makefile.am:1.2 rtems/testsuites/sptests/spfifo01/Makefile.am:1.3
--- rtems/testsuites/sptests/spfifo01/Makefile.am:1.2	Tue Jun  8 08:59:17 2010
+++ rtems/testsuites/sptests/spfifo01/Makefile.am	Thu Jun 24 14:46:40 2010
@@ -14,7 +14,6 @@
 include $(top_srcdir)/../automake/compile.am
 include $(top_srcdir)/../automake/leaf.am
 
-
 AM_CPPFLAGS += -I$(top_srcdir)/../support/include
 
 LINK_OBJS = $(spfifo01_OBJECTS) $(spfifo01_LDADD)

diff -u rtems/testsuites/sptests/spfifo01/init.c:1.3 rtems/testsuites/sptests/spfifo01/init.c:1.4
--- rtems/testsuites/sptests/spfifo01/init.c:1.3	Thu Jun 10 09:44:26 2010
+++ rtems/testsuites/sptests/spfifo01/init.c	Thu Jun 24 14:46:40 2010
@@ -23,7 +23,7 @@
   puts("\n\n*** FIFO / PIPE OPEN TEST - 1 ***");
 
   puts(
-    "Configuration: Pipes disabled.\n"
+    "\nConfiguration: Pipes disabled.\n"
     "Creating named fifo '" FIFO_PATH "'.\n"
     "Must result in failure since pipes are disabled in the configuration."
   );

diff -u rtems/testsuites/sptests/spfifo02/Makefile.am:1.2 rtems/testsuites/sptests/spfifo02/Makefile.am:1.3
--- rtems/testsuites/sptests/spfifo02/Makefile.am:1.2	Tue Jun  8 08:59:17 2010
+++ rtems/testsuites/sptests/spfifo02/Makefile.am	Thu Jun 24 14:46:40 2010
@@ -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 $(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 -u rtems/testsuites/sptests/spfifo02/init.c:1.3 rtems/testsuites/sptests/spfifo02/init.c:1.4
--- rtems/testsuites/sptests/spfifo02/init.c:1.3	Sun Jun 20 17:02:24 2010
+++ rtems/testsuites/sptests/spfifo02/init.c	Thu Jun 24 14:46:40 2010
@@ -1,6 +1,6 @@
 /*
- *  COPYRIGHT (c) 2010
- *  Bharath Suri<bharath.s.jois at 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;
+
+extern Heap_Control  *RTEMS_Malloc_Heap;
+
+void create_all_barriers(void)
 {
+  rtems_status_code status;
+  int               i;
 
-  int status = -1;
-  int fd = 0;
+  BarrierCount = 0;
 
-  puts("\n\n*** FIFO / PIPE OPEN TEST - 2 ***");
-  puts(
-"\n\nConfiguration: Pipes configured, \
-but number of barriers configured = 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;
 
-  puts("\n\nCreating fifo /tmp/fifo");
-  status = mkfifo("/tmp/fifo01", 0777);
-  rtems_test_assert(status == 0);
+  SemaphoreCount = 0;
 
-  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);
+  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++;
+  }
+}
+
+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\nRemove directory /tmp");
-  status = rmdir("/tmp");
+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" );
+}
+
+void create_fifo(void)
+{
+  int status;
+
+  status = mkfifo("/fifo01", 0777);
   rtems_test_assert(status == 0);
+}
+
+void open_fifo(int expected, int flags)
+{
+  int fd;
 
-  puts("\n\n*** END OF FIFO / PIPE OPEN TEST - 2 ***");
+  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 -u rtems/testsuites/sptests/spfifo02/spfifo02.doc:1.2 rtems/testsuites/sptests/spfifo02/spfifo02.doc:1.3
--- rtems/testsuites/sptests/spfifo02/spfifo02.doc:1.2	Thu Jun 10 09:44:26 2010
+++ rtems/testsuites/sptests/spfifo02/spfifo02.doc	Thu Jun 24 14:46:40 2010
@@ -1,8 +1,8 @@
 #
 #  $Id$
 #
-#  COPYRIGHT (c) 2010
-#  Bharath Suri<bharath.s.jois at 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 -u rtems/testsuites/sptests/spfifo02/spfifo02.scn:1.1 rtems/testsuites/sptests/spfifo02/spfifo02.scn:1.2
--- rtems/testsuites/sptests/spfifo02/spfifo02.scn:1.1	Mon Jun  7 14:09:27 2010
+++ rtems/testsuites/sptests/spfifo02/spfifo02.scn	Thu Jun 24 14:46:40 2010
@@ -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

diff -u rtems/testsuites/sptests/spfifo03/Makefile.am:1.2 rtems/testsuites/sptests/spfifo03/Makefile.am:1.3
--- rtems/testsuites/sptests/spfifo03/Makefile.am:1.2	Tue Jun  8 08:59:17 2010
+++ rtems/testsuites/sptests/spfifo03/Makefile.am	Thu Jun 24 14:46:40 2010
@@ -14,7 +14,6 @@
 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 -u rtems/testsuites/sptests/spfifo03/init.c:1.3 rtems/testsuites/sptests/spfifo03/init.c:1.4
--- rtems/testsuites/sptests/spfifo03/init.c:1.3	Sun Jun 20 17:02:24 2010
+++ rtems/testsuites/sptests/spfifo03/init.c	Thu Jun 24 14:46:40 2010
@@ -1,6 +1,16 @@
-/*
- *  COPYRIGHT (c) 2010
- *  Bharath Suri<bharath.s.jois at 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 );
+
+  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);
 
-  puts("\n\nRemove directory /tmp");
-  status = rmdir("/tmp");
+  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 @@
 #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 -u rtems/testsuites/sptests/spfifo03/spfifo03.doc:1.2 rtems/testsuites/sptests/spfifo03/spfifo03.doc:1.3
--- rtems/testsuites/sptests/spfifo03/spfifo03.doc:1.2	Thu Jun 10 09:44:27 2010
+++ rtems/testsuites/sptests/spfifo03/spfifo03.doc	Thu Jun 24 14:46:40 2010
@@ -1,8 +1,8 @@
 #
 #  $Id$
 #
-#  COPYRIGHT (c) 2010
-#  Bharath Suri<bharath.s.jois at 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 @@
 
 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 -u rtems/testsuites/sptests/spfifo03/spfifo03.scn:1.1 rtems/testsuites/sptests/spfifo03/spfifo03.scn:1.2
--- rtems/testsuites/sptests/spfifo03/spfifo03.scn:1.1	Mon Jun  7 14:09:28 2010
+++ rtems/testsuites/sptests/spfifo03/spfifo03.scn	Thu Jun 24 14:46:40 2010
@@ -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 ***


 *joel* (on branch rtems-4-10-branch):
2010-06-24	Bharath Suri <bharath.s.jois at gmail.com>

	PR 1542/filesystem
	PR 1585/filesystem
	* libfs/src/pipe/fifo.c: pipe_control_t was not deallocated if
	fifo_open() was attempted with (O_WRONLY|O_NONBLOCK).
	Mutex was locked too many times on this path and we needed an unlock.

M 1.2457  cpukit/ChangeLog
M 1.2346.2.49  cpukit/ChangeLog
M    1.9  cpukit/libfs/src/pipe/fifo.c
M 1.4.2.3  cpukit/libfs/src/pipe/fifo.c

diff -u rtems/cpukit/ChangeLog:1.2456 rtems/cpukit/ChangeLog:1.2457
--- rtems/cpukit/ChangeLog:1.2456	Thu Jun 24 08:28:38 2010
+++ rtems/cpukit/ChangeLog	Thu Jun 24 14:57:58 2010
@@ -1,3 +1,11 @@
+2010-06-24	Bharath Suri <bharath.s.jois at gmail.com>
+
+	PR 1542/filesystem
+	PR 1585/filesystem
+	* libfs/src/pipe/fifo.c: pipe_control_t was not deallocated if
+	fifo_open() was attempted with (O_WRONLY|O_NONBLOCK).
+	Mutex was locked too many times on this path and we needed an unlock.
+
 2010-06-24	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
 	PR 1587/filesystem

diff -u rtems/cpukit/ChangeLog:1.2346.2.48 rtems/cpukit/ChangeLog:1.2346.2.49
--- rtems/cpukit/ChangeLog:1.2346.2.48	Thu Jun 24 08:28:53 2010
+++ rtems/cpukit/ChangeLog	Thu Jun 24 14:57:59 2010
@@ -1,3 +1,11 @@
+2010-06-24	Bharath Suri <bharath.s.jois at gmail.com>
+
+	PR 1542/filesystem
+	PR 1585/filesystem
+	* libfs/src/pipe/fifo.c: pipe_control_t was not deallocated if
+	fifo_open() was attempted with (O_WRONLY|O_NONBLOCK).
+	Mutex was locked too many times on this path and we needed an unlock.
+
 2010-06-24	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
 	PR 1587/filesystem

diff -u rtems/cpukit/libfs/src/pipe/fifo.c:1.8 rtems/cpukit/libfs/src/pipe/fifo.c:1.9
--- rtems/cpukit/libfs/src/pipe/fifo.c:1.8	Wed Jun 23 00:01:46 2010
+++ rtems/cpukit/libfs/src/pipe/fifo.c	Thu Jun 24 14:57:58 2010
@@ -104,6 +104,8 @@
   if (! pipe->Buffer)
     goto err_buf;
 
+  err = -ENOMEM;
+
   if (rtems_barrier_create(
         rtems_build_name ('P', 'I', 'r', c),
         RTEMS_BARRIER_MANUAL_RELEASE, 0,
@@ -342,15 +344,17 @@
       break;
 
     case LIBIO_FLAGS_WRITE:
+      pipe->writerCounter ++;
+
+      if (pipe->Writers ++ == 0)
+        PIPE_WAKEUPREADERS(pipe);
+
       if (pipe->Readers == 0 && LIBIO_NODELAY(iop)) {
+	PIPE_UNLOCK(pipe);
         err = -ENXIO;
         goto out_error;
       }
 
-      pipe->writerCounter ++;
-      if (pipe->Writers ++ == 0)
-        PIPE_WAKEUPREADERS(pipe);
-
       if (pipe->Readers == 0) {
         prevCounter = pipe->readerCounter;
         err = -EINTR;

diff -u rtems/cpukit/libfs/src/pipe/fifo.c:1.4.2.2 rtems/cpukit/libfs/src/pipe/fifo.c:1.4.2.3
--- rtems/cpukit/libfs/src/pipe/fifo.c:1.4.2.2	Wed Jun 23 00:06:34 2010
+++ rtems/cpukit/libfs/src/pipe/fifo.c	Thu Jun 24 14:58:00 2010
@@ -102,6 +102,7 @@
   if (! pipe->Buffer)
     goto err_buf;
 
+  err = -ENOMEM;
   if (rtems_barrier_create(
         rtems_build_name ('P', 'I', 'r', c),
         RTEMS_BARRIER_MANUAL_RELEASE, 0,
@@ -301,15 +302,17 @@
       break;
 
     case LIBIO_FLAGS_WRITE:
+      pipe->writerCounter ++;
+
+      if (pipe->Writers ++ == 0)
+        PIPE_WAKEUPREADERS(pipe);
+
       if (pipe->Readers == 0 && LIBIO_NODELAY(iop)) {
+	PIPE_UNLOCK(pipe);
         err = -ENXIO;
         goto out_error;
       }
 
-      pipe->writerCounter ++;
-      if (pipe->Writers ++ == 0)
-        PIPE_WAKEUPREADERS(pipe);
-
       if (pipe->Readers == 0) {
         prevCounter = pipe->readerCounter;
         err = -EINTR;



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20100624/c859213f/attachment-0001.html>


More information about the vc mailing list