Changeset 287febb5 in rtems for testsuites/sptests/spfifo03


Ignore:
Timestamp:
Jun 24, 2010, 7:46:40 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
2d1994c9
Parents:
eb8c45d
Message:

2010-06-24 Bharath Suri <bharath.s.jois@…>

  • 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.
Location:
testsuites/sptests/spfifo03
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/spfifo03/Makefile.am

    reb8c45d r287febb5  
    1515include $(top_srcdir)/../automake/leaf.am
    1616
    17 
    1817AM_CPPFLAGS += -I$(top_srcdir)/../support/include
    1918
  • testsuites/sptests/spfifo03/init.c

    reb8c45d r287febb5  
    1 /*
    2  *  COPYRIGHT (c) 2010
    3  *  Bharath Suri<bharath.s.jois@gmail.com>.
     1/*  Init
     2 *
     3 *  This routine is the initialization task for this test program.
     4 *  It is a user initialization task and has the responsibility
     5 *  of invoking the test routine
     6 *
     7 *  Input parameters:
     8 *    not_used
     9 *
     10 *  Output parameters:  NONE
     11 *
     12 *  COPYRIGHT (c) 1989-1999.
     13 *  On-Line Applications Research Corporation (OAR).
    414 *
    515 *  The license and distribution terms for this file may be
     
    2333#include <rtems/libio.h>
    2434
    25 
    26 void test_main(void)
     35#define SEND_RCV_BUFSIZ 12
     36rtems_id Barrier;
     37
     38rtems_task read_task(rtems_task_argument not_used)
    2739{
    28 
     40  int fd = 0;
     41  int status = -1;
     42
     43  char recvBuf_r1[SEND_RCV_BUFSIZ] = {0};
     44  char recvBuf_r2[SEND_RCV_BUFSIZ] = {0};
     45
     46  puts("\nRead task activated, waiting till writer opens");
     47
     48  status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT );
     49  rtems_test_assert( status == RTEMS_SUCCESSFUL );
     50
     51  sleep(1);
     52
     53  puts("\nNow, reader opening file(1)"); 
     54  fd = open("/tmp/fifo01", O_RDONLY);
     55  if(fd <= 0) {
     56    printf("Error opening file: (%d) :: %s", errno, strerror(errno));
     57    rtems_test_assert(0);
     58  }
     59
     60  status = read(fd, recvBuf_r1, sizeof(recvBuf_r1)-1);
     61  rtems_test_assert(status == sizeof(recvBuf_r1)-1);
     62
     63  printf("\n@ receiver (being a unblocked reader): Got %s", recvBuf_r1);
     64
     65  status = close(fd);
     66  rtems_test_assert(status == 0);
     67
     68  status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT );
     69  rtems_test_assert( status == RTEMS_SUCCESSFUL );
     70 
     71  puts("\nReader opening file(2)");
     72  fd = open("/tmp/fifo01", O_RDONLY);
     73  if(fd <= 0) {
     74    printf("Error opening file: (%d) :: %s", errno, strerror(errno));
     75    rtems_test_assert(0);
     76  }
     77
     78  status = read(fd, recvBuf_r2, sizeof(recvBuf_r2)-1);
     79  rtems_test_assert(status == sizeof(recvBuf_r2)-1);
     80
     81  printf("\n@ receiver (being a blocked reader): Got %s", recvBuf_r2);
     82
     83  status = close(fd);
     84  rtems_test_assert(status == 0);
     85 
     86 
     87  puts("\nReader done!");
     88  status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT );
     89  rtems_test_assert( status == RTEMS_SUCCESSFUL );
     90  rtems_task_delete( RTEMS_SELF );
     91}
     92
     93
     94void test_main(void) //Also acts as the write task
     95{
     96
     97  rtems_id readTaskID;
     98
     99  rtems_name readTaskName;
     100
     101  char sendBuf_r1[SEND_RCV_BUFSIZ] = {0};
     102  char sendBuf_r2[SEND_RCV_BUFSIZ] = {0};
    29103  int status = -1;
    30104  int fd = 0;
    31105
    32   puts("\n\n*** FIFO / PIPE OPEN TEST - 3 ***");
    33   puts(
    34 "\n\nConfiguration: Pipes configured, \
    35 but number of barriers configured = 1\n\
    36 Required number of barriers = 2"
    37        );
    38 
    39   puts("\n\nCreating directory /tmp");
     106
     107  strcpy( sendBuf_r1, "SendBuffer1" );
     108  strcpy( sendBuf_r2, "SendBuffer2" );
     109
     110  memset( &Barrier, 0, sizeof(Barrier) );
     111  status = rtems_barrier_create (
     112    rtems_build_name ( 'B', 'A', 'R', 't' ),
     113    RTEMS_BARRIER_AUTOMATIC_RELEASE,
     114    2,
     115    &Barrier
     116    );
     117
     118  rtems_test_assert( status == RTEMS_SUCCESSFUL );
     119
     120  puts("\n\n*** FIFO / PIPE OPEN TEST - 6 ***");
     121
     122  puts("\nCreating a task name and a task");
     123  readTaskName = rtems_build_name('T','A','r',' ');
     124
     125  status = rtems_task_create(
     126                             readTaskName,
     127                             1,
     128                             RTEMS_MINIMUM_STACK_SIZE * 2,
     129                             RTEMS_INTERRUPT_LEVEL(31),
     130                             RTEMS_DEFAULT_ATTRIBUTES,
     131                             &readTaskID
     132                             );
     133 
     134  rtems_test_assert( status == RTEMS_SUCCESSFUL );
     135
     136  puts("\ncreating directory /tmp");
    40137  status = mkdir("/tmp", 0777);
    41138  rtems_test_assert(status == 0);
    42139
    43   puts("\n\nCreating fifo /tmp/fifo");
     140  puts("\ncreating fifo file /tmp/fifo01");
    44141  status = mkfifo("/tmp/fifo01", 0777);
    45142  rtems_test_assert(status == 0);
    46143
    47   puts("\n\nAttempt to open the fifo file\n");
    48   puts(
    49 "Must result in failure since \n\
    50 number of barriers = 1 => not all resources\n\
    51 were acquired"
    52        );
    53 
    54   fd = open("/tmp/fifo01", O_RDONLY);
    55   rtems_test_assert(fd == -1);
    56   rtems_test_assert(errno == EINTR); // Should this
    57                                      // be ENOMEM?
    58   puts("\n\nRemove the entry /tmp/fifo01");
     144  puts("\nStarting the read task");
     145  status = rtems_task_start(readTaskID, read_task, 0);
     146  rtems_test_assert(status == 0);
     147
     148  status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT );
     149  rtems_test_assert( status == RTEMS_SUCCESSFUL );
     150
     151  puts("\nWriter opening file(1)");
     152  fd = open("/tmp/fifo01", O_WRONLY);
     153  if(fd <= 0) {
     154    printf("Error opening file: (%d) :: %s", errno, strerror(errno));
     155    rtems_test_assert(0);
     156  }
     157
     158 
     159  printf("\n@ sender: %s", sendBuf_r1);
     160  status = write(fd, sendBuf_r1, sizeof(sendBuf_r1)-1);
     161  rtems_test_assert(status == sizeof(sendBuf_r1)-1);
     162
     163  status = close(fd);
     164  rtems_test_assert(status == 0);
     165 
     166  status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT );
     167  rtems_test_assert( status == RTEMS_SUCCESSFUL );
     168
     169  sleep(1);
     170
     171  // Reader would have blocked by now
     172  puts("\nWriter opening file(2)");
     173  fd = open("/tmp/fifo01", O_WRONLY);
     174  if(fd <= 0) {
     175    printf("Error opening file: (%d) :: %s", errno, strerror(errno));
     176    rtems_test_assert(0);
     177  }
     178
     179  printf("\n@ sender: %s", sendBuf_r2);
     180  status = write(fd, sendBuf_r2, sizeof(sendBuf_r2)-1);
     181  rtems_test_assert(status == sizeof(sendBuf_r2)-1);
     182
     183  status = close(fd);
     184  rtems_test_assert(status == 0);
     185
     186  status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT );
     187  rtems_test_assert( status == RTEMS_SUCCESSFUL );
     188
     189  puts( "Removing the fifo" );
    59190  status = unlink("/tmp/fifo01");
    60191  rtems_test_assert(status == 0);
    61 
    62   puts("\n\nRemove directory /tmp");
     192 
     193  puts( "Removing /tmp" );
    63194  status = rmdir("/tmp");
    64195  rtems_test_assert(status == 0);
    65 
    66   puts("\n\n*** END OF FIFO / PIPE OPEN TEST - 3 ***");
     196 
     197  puts("\n*** END OF FIFO / PIPE OPEN TEST - 6 ***");
    67198}
    68199
     
    81212#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 6
    82213
    83 #define CONFIGURE_MAXIMUM_TASKS 1
     214#define CONFIGURE_MAXIMUM_TASKS 3
    84215
    85216#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
    86 #define CONFIGURE_PIPES_ENABLED
    87 #define CONFIGURE_MAXIMUM_PIPES 1
     217
     218#define CONFIGURE_MAXIMUM_BARRIERS 1
     219
    88220#define CONFIGURE_INIT
    89 
     221#define CONFIGURE_FIFOS_ENABLED
     222#define CONFIGURE_MAXIMUM_FIFOS 1
     223
     224
     225#define CONFIGURE_INIT
    90226#include <rtems/confdefs.h>
    91227
  • testsuites/sptests/spfifo03/spfifo03.scn

    reb8c45d r287febb5  
    1 Could not open '/dev/kqemu' - QEMU acceleration layer not activated: No such file or directory
    21Initialized console on port COM1 9600-8-N-1
    32
     
    54
    65
    7 *** FIFO / PIPE OPEN TEST - 3 ***
     6*** FIFO / PIPE OPEN TEST - 6 ***
    87
    98
    10 Configuration: Pipes configured, but number of barriers configured = 1
    11 Required number of barriers = 2
     9Creating a task name and a task
    1210
    1311
    14 Creating directory /tmp
     12creating directory /tmp
    1513
    1614
    17 Creating fifo /tmp/fifo
     15creating fifo file /tmp/fifo01
    1816
    1917
    20 Attempt to open the fifo file
    21 
    22 Must result in failure since
    23 number of barriers = 1 => not all resources
    24 were acquired
     18Starting the read task
    2519
    2620
    27 Remove the entry /tmp/fifo01
     21Writer opening file(1)
    2822
    2923
    30 Remove directory /tmp
     24Read task activated, sleeping to block the writer
    3125
    3226
    33 *** END OF FIFO / PIPE OPEN TEST - 3 ***
     27Now, reader opening file(1)
     28
     29
     30@ sender:
     31
     32@ receiver (being a unblocked reader): Got
     33
     34Reader opening file(2)
     35
     36
     37Writer opening file(2)
     38
     39
     40@ sender: SendBuffer2
     41
     42*** END OF FIFO / PIPE OPEN TEST - 6 ***
Note: See TracChangeset for help on using the changeset viewer.