summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/spfifo04
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-02 18:07:12 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-02 18:07:12 +0000
commitb3eb018574d446fa5ae8e46aed54c02183f2e4d6 (patch)
treef376638ebd83949ce729f7109740d733ba08e04a /testsuites/sptests/spfifo04
parent2010-07-02 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-b3eb018574d446fa5ae8e46aed54c02183f2e4d6.tar.bz2
2010-07-02 Bharath Suri <bharath.s.jois@gmail.com>
PR 1600/testing * spfifo04/init.c, spfifo04/spfifo04.doc, spfifo04/spfifo04.scn, spfifo04/Makefile.am: New files to improve coverage on fifo/pipe routines * Makefile.am, configure.ac: Add new test.
Diffstat (limited to 'testsuites/sptests/spfifo04')
-rw-r--r--testsuites/sptests/spfifo04/.cvsignore2
-rw-r--r--testsuites/sptests/spfifo04/Makefile.am26
-rw-r--r--testsuites/sptests/spfifo04/init.c109
-rw-r--r--testsuites/sptests/spfifo04/spfifo04.doc22
-rw-r--r--testsuites/sptests/spfifo04/spfifo04.scn13
5 files changed, 172 insertions, 0 deletions
diff --git a/testsuites/sptests/spfifo04/.cvsignore b/testsuites/sptests/spfifo04/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/sptests/spfifo04/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/sptests/spfifo04/Makefile.am b/testsuites/sptests/spfifo04/Makefile.am
new file mode 100644
index 0000000000..a2281a031b
--- /dev/null
+++ b/testsuites/sptests/spfifo04/Makefile.am
@@ -0,0 +1,26 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = spfifo04
+spfifo04_SOURCES = init.c
+
+dist_rtems_tests_DATA = spfifo04.scn
+dist_rtems_tests_DATA += spfifo04.doc
+
+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 = $(spfifo04_OBJECTS) $(spfifo04_LDADD)
+LINK_LIBS = $(spfifo04_LDLIBS)
+
+spfifo04$(EXEEXT): $(spfifo04_OBJECTS) $(spfifo04_DEPENDENCIES)
+ @rm -f spfifo04$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spfifo04/init.c b/testsuites/sptests/spfifo04/init.c
new file mode 100644
index 0000000000..3bcdef09e3
--- /dev/null
+++ b/testsuites/sptests/spfifo04/init.c
@@ -0,0 +1,109 @@
+/*
+ * 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
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+/* Includes */
+#include <bsp.h>
+#include <tmacros.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <rtems.h>
+#include <rtems/libio.h>
+
+#define SEND_RCV_BUFSIZ 12
+
+rtems_task Init(
+ rtems_task_argument not_used
+)
+{
+ int fd = -1;
+ int status = -1;
+ off_t offset = 4;
+ int pipe_length = -1;
+ int flag = 1;
+
+ puts( "\n\n*** TEST PIPE/FIFO - 04 ***" );
+
+ puts( "Init - Creating /fifo" );
+ status = mkfifo( "/fifo", 0777 );
+ rtems_test_assert( status == 0 );
+
+ puts( "Init - Opening /fifo in readonly, non-blocking mode" );
+ fd = open( "/fifo", O_RDONLY | O_NONBLOCK );
+ rtems_test_assert( fd != -1 );
+
+ puts( "Init - Attempt to lseek on fifo -- Expected ESPIPE" );
+ offset = lseek( fd, offset, SEEK_CUR );
+ rtems_test_assert( offset == -1 );
+ rtems_test_assert( errno == ESPIPE );
+
+ puts( "Init - ioctl: FIONBIO -- Expected EFAULT" );
+ status = ioctl( fd, FIONBIO, NULL );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EFAULT );
+
+ puts( "Init - ioctl: FIONBIO -- OK" );
+ status = ioctl( fd, FIONBIO, &flag );
+ rtems_test_assert( status == 0 );
+
+ flag = 0;
+ puts( "Init - ioctl: FIONBIO -- OK" );
+ status = ioctl( fd, FIONBIO, &flag );
+ rtems_test_assert( status == 0 );
+
+ puts( "Init - ioctl: Dummy Command -- Expected EINVAL" );
+ status = ioctl( fd, -1, NULL );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EINVAL );
+
+ puts( "Init - ioctl: FIONREAD -- Expected EFAULT" );
+ status = ioctl( fd, FIONREAD, NULL );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EFAULT );
+
+ puts( "Init - ioctl: FIONREAD -- OK" );
+ status = ioctl( fd, FIONREAD, &pipe_length );
+ rtems_test_assert( status == 0 );
+ rtems_test_assert( pipe_length == 0 );
+
+ puts( "Init - closing /fifo" );
+ status = close( fd );
+ rtems_test_assert( status == 0 );
+
+ puts( "Init - removing /fifo" );
+ status = unlink( "/fifo" );
+ rtems_test_assert( status == 0 );
+
+ puts( "*** END OF TEST PIPE/FIFO - 04 ***" );
+ rtems_test_exit(0);
+}
+
+#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 3
+#define CONFIGURE_MAXIMUM_BARRIERS 1
+#define CONFIGURE_MAXIMUM_FIFOS 1
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_FIFOS_ENABLED
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+/* end of file */
diff --git a/testsuites/sptests/spfifo04/spfifo04.doc b/testsuites/sptests/spfifo04/spfifo04.doc
new file mode 100644
index 0000000000..671cf1dc70
--- /dev/null
+++ b/testsuites/sptests/spfifo04/spfifo04.doc
@@ -0,0 +1,22 @@
+#
+# $Id$
+#
+# 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
+# http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+directives:
+
++ pipe_lseek
++ pipe_ioctl
+
+concepts:
+
++ exercise pipe_lseek completely
++ exercise pipe_ioctl completely
diff --git a/testsuites/sptests/spfifo04/spfifo04.scn b/testsuites/sptests/spfifo04/spfifo04.scn
new file mode 100644
index 0000000000..3fed675ef2
--- /dev/null
+++ b/testsuites/sptests/spfifo04/spfifo04.scn
@@ -0,0 +1,13 @@
+*** TEST PIPE/FIFO - 04 ***
+Init - Creating /fifo
+Init - Opening /fifo in readonly, non-blocking mode
+Init - Attempt to lseek on fifo -- Expected ESPIPE
+Init - ioctl: FIONBIO -- Expected EFAULT
+Init - ioctl: FIONBIO -- OK
+Init - ioctl: FIONBIO -- OK
+Init - ioctl: Dummy Command -- Expected EINVAL
+Init - ioctl: FIONREAD -- Expected EFAULT
+Init - ioctl: FIONREAD -- OK
+Init - closing /fifo
+Init - removing /fifo
+*** END OF TEST PIPE/FIFO - 04 ***