[cfde6479] | 1 | /* test_main |
---|
| 2 | * |
---|
| 3 | * This routine serves as a test routine. |
---|
| 4 | * Exercises the fifo_open |
---|
| 5 | * |
---|
| 6 | * Input parameters: NONE |
---|
| 7 | * |
---|
| 8 | * Output parameters: NONE |
---|
| 9 | * |
---|
| 10 | * COPYRIGHT (c) 1989-1999. |
---|
| 11 | * On-Line Applications Research Corporation (OAR). |
---|
| 12 | * |
---|
| 13 | * The license and distribution terms for this file may be |
---|
| 14 | * found in the file LICENSE in this distribution or at |
---|
| 15 | * http://www.rtems.com/license/LICENSE. |
---|
| 16 | * |
---|
| 17 | * $Id$ |
---|
| 18 | */ |
---|
| 19 | |
---|
| 20 | /* Includes */ |
---|
| 21 | |
---|
| 22 | #include <stdio.h> |
---|
| 23 | #include <sys/types.h> |
---|
| 24 | #include <sys/stat.h> |
---|
| 25 | #include <fcntl.h> |
---|
| 26 | #include <unistd.h> |
---|
| 27 | #include <errno.h> |
---|
| 28 | |
---|
| 29 | #include <tmacros.h> |
---|
| 30 | #include <rtems.h> |
---|
| 31 | #include <rtems/libio.h> |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | void test_main(void) |
---|
| 35 | { |
---|
| 36 | |
---|
| 37 | int status = -1; |
---|
| 38 | int fd = 0; |
---|
| 39 | |
---|
| 40 | puts("\n\n*** FIFO / PIPE OPEN TEST - 3 ***"); |
---|
| 41 | puts( |
---|
| 42 | "\n\nConfiguration: Pipes configured, \ |
---|
| 43 | but number of barriers configured = 1\n\ |
---|
| 44 | Required number of barriers = 2" |
---|
| 45 | ); |
---|
| 46 | |
---|
| 47 | puts("\n\nCreating directory /tmp"); |
---|
| 48 | status = mkdir("/tmp", 0777); |
---|
| 49 | rtems_test_assert(status == 0); |
---|
| 50 | |
---|
| 51 | puts("\n\nCreating fifo /tmp/fifo"); |
---|
| 52 | status = mkfifo("/tmp/fifo01", 0777); |
---|
| 53 | rtems_test_assert(status == 0); |
---|
| 54 | |
---|
| 55 | puts("\n\nAttempt to open the fifo file\n"); |
---|
| 56 | puts( |
---|
| 57 | "Must result in failure since \n\ |
---|
| 58 | number of barriers = 1 => not all resources\n\ |
---|
| 59 | were acquired" |
---|
| 60 | ); |
---|
| 61 | |
---|
| 62 | fd = open("/tmp/fifo01", O_RDONLY); |
---|
| 63 | rtems_test_assert(fd == -1); |
---|
| 64 | rtems_test_assert(errno == EINTR); // Should this |
---|
| 65 | // be ENOMEM? |
---|
| 66 | puts("\n\nRemove the entry /tmp/fifo01"); |
---|
| 67 | status = unlink("/tmp/fifo01"); |
---|
| 68 | rtems_test_assert(status == 0); |
---|
| 69 | |
---|
| 70 | puts("\n\nRemove directory /tmp"); |
---|
| 71 | status = rmdir("/tmp"); |
---|
| 72 | rtems_test_assert(status == 0); |
---|
| 73 | |
---|
| 74 | puts("\n\n*** END OF FIFO / PIPE OPEN TEST - 3 ***"); |
---|
| 75 | } |
---|
| 76 | |
---|