Ticket #2484: pipe_test.c

File pipe_test.c, 2.3 KB (added by Steve Helmer, on 12/07/15 at 17:46:59)

Verification test of pipe function call.

Line 
1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *  It is called from init_exec and has the responsibility for creating
5 *  and starting the tasks that make up the test.  If the time of day
6 *  clock is required for the test, it should also be set to a known
7 *  value by this function.
8 *
9 *  Input parameters:  NONE
10 *
11 *  Output parameters:  NONE
12 *
13 *  COPYRIGHT (c) 1989-1999.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.com/license/LICENSE.
19 *
20 *  $Id: nfs.c,v 1.6 2014/02/27 13:07:55 helmers Exp $
21 */
22
23#include <bsp.h>                /* for device driver prototypes */
24#include <stdio.h>
25#include <stdlib.h>
26#include <errno.h>
27#include <string.h>
28
29#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 50
30#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
31#define CONFIGURE_FILESYSTEM_NFS
32
33#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
34#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
35#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
36
37#define CONFIGURE_MAXIMUM_DRIVERS       20
38#define CONFIGURE_MAXIMUM_SEMAPHORES        20
39#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES    20
40#define CONFIGURE_MAXIMUM_TASKS            20
41
42#define CONFIGURE_MICROSECONDS_PER_TICK    1000
43
44#define CONFIGURE_INIT_TASK_STACK_SIZE    (10*1024)
45#define CONFIGURE_INIT_TASK_PRIORITY    50
46#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
47                                           RTEMS_NO_TIMESLICE | \
48                                           RTEMS_NO_ASR | \
49                                           RTEMS_INTERRUPT_LEVEL(0))
50
51#define CONFIGURE_INIT
52#include <bsp/networkconfig-SPv1.h>
53#include <rtems/confdefs.h>
54#include <unistd.h>
55
56int
57main (int argc, const char *argv[])
58{
59  int i;
60  int fd[2];
61
62  for (i = 0; i < argc; ++i)
63    printf ("argv[%i] = %s\n", i, argv[i]);
64
65  i = pipe (&fd);
66  if (i != 0)
67    printf ("opened 2 pipes: %i and %i\n", fd[0], fd[1]);
68  else
69    printf ("could not create pipe: %s\n", strerror (errno));
70
71  /* now try to create a 2nd pair */
72  fd[0] = -1;
73  fd[1] = -1
74  i = pipe (&fd);
75  if (i != 0)
76    printf ("opened 2nd pair of pipes: %i and %i\n", fd[0], fd[1]);
77  else
78    printf ("could not create pipe: %s\n", strerror (errno));
79
80  exit (0);
81}