summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxfile02
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>2010-06-23 18:43:24 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>2010-06-23 18:43:24 +0000
commit6cb72216e7bbf070c498a7a65272d0b546e45f8a (patch)
treeb55876cbfd1075d19a64b3fb433e143038dcb46b /testsuites/psxtests/psxfile02
parent2010-06-23 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff)
downloadrtems-6cb72216e7bbf070c498a7a65272d0b546e45f8a.tar.bz2
2010-06-23 Jennifer Averett <Jennifer Averett@OARcorp.com>
* Makefile.am, configure.ac: Added test case for calls that check for an unopened file descriptor. * psxfile02/.cvsignore, psxfile02/Makefile.am, psxfile02/init.c, psxfile02/psxfile02.doc, psxfile02/psxfile02.scn: New files.
Diffstat (limited to 'testsuites/psxtests/psxfile02')
-rw-r--r--testsuites/psxtests/psxfile02/.cvsignore2
-rw-r--r--testsuites/psxtests/psxfile02/Makefile.am26
-rw-r--r--testsuites/psxtests/psxfile02/init.c152
-rw-r--r--testsuites/psxtests/psxfile02/psxfile02.doc22
-rw-r--r--testsuites/psxtests/psxfile02/psxfile02.scn26
5 files changed, 228 insertions, 0 deletions
diff --git a/testsuites/psxtests/psxfile02/.cvsignore b/testsuites/psxtests/psxfile02/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/psxtests/psxfile02/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/psxtests/psxfile02/Makefile.am b/testsuites/psxtests/psxfile02/Makefile.am
new file mode 100644
index 0000000000..73f82c01ab
--- /dev/null
+++ b/testsuites/psxtests/psxfile02/Makefile.am
@@ -0,0 +1,26 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxfile02
+psxfile02_SOURCES = init.c ../../support/src/spin.c
+
+dist_rtems_tests_DATA = psxfile02.scn
+dist_rtems_tests_DATA += psxfile02.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 = $(psxfile02_OBJECTS) $(psxfile02_LDADD)
+LINK_LIBS = $(psxfile02_LDLIBS)
+
+psxfile02$(EXEEXT): $(psxfile02_OBJECTS) $(psxfile02_DEPENDENCIES)
+ @rm -f psxfile02$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxfile02/init.c b/testsuites/psxtests/psxfile02/init.c
new file mode 100644
index 0000000000..778e033b04
--- /dev/null
+++ b/testsuites/psxtests/psxfile02/init.c
@@ -0,0 +1,152 @@
+/*
+ * 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$
+ */
+#include <stdio.h>
+#include <sys/uio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <ctype.h>
+#include <rtems/imfs.h>
+
+#include <rtems.h>
+#include <rtems/libio.h>
+
+#include <tmacros.h>
+#include "test_support.h"
+
+int _fcntl_r(
+ struct _reent *ptr __attribute__((unused)),
+ int fd,
+ int cmd,
+ int arg
+);
+
+off_t _lseek_r(
+ struct _reent *ptr __attribute__((unused)),
+ int fd,
+ off_t offset,
+ int whence
+);
+
+
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ int fd;
+ struct stat stat_buff;
+ struct iovec vec[4];
+ off_t res;
+ int status;
+
+ puts( "\n\n*** PSXFILE02 TEST ***" );
+
+ /*
+ * Simple open case where the file is created.
+ */
+ puts( "mkdir /tmp" );
+ status = mkdir( "/tmp", S_IRWXU );
+ rtems_test_assert( !status );
+
+ puts( "open /tmp/j" );
+ fd = open( "/tmp/j", O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO );
+ rtems_test_assert( fd != -1 );
+ printf( "open returned file descriptor %d\n", fd );
+
+ puts( "close /tmp/j" );
+ status = close( fd );
+ rtems_test_assert( !status );
+
+ puts("ftruncate an unopened file");
+ status = ftruncate(fd, 40);
+ rtems_test_assert( status == -1 );
+ printf( "%d: %s\n", errno, strerror( errno ) );
+ rtems_test_assert( errno == EBADF );
+
+ puts("_fcntl_r unopened file");
+ status = _fcntl_r( NULL, fd, F_SETFD, 1 );
+ rtems_test_assert( status == -1 );
+ printf( "%d: %s\n", errno, strerror( errno ) );
+ rtems_test_assert( errno == EBADF );
+
+ puts("fdatasync unopened file");
+ status = fdatasync( fd );
+ rtems_test_assert( status == -1 );
+ printf( "%d: %s\n", errno, strerror( errno ) );
+ rtems_test_assert( errno == EBADF );
+
+ puts("fstat unopened file");
+ status = fstat( fd, &stat_buff );
+ rtems_test_assert( status == -1 );
+ printf( "%d: %s\n", errno, strerror( errno ) );
+ rtems_test_assert( errno == EBADF );
+
+ puts("fsync unopened file");
+ status = fsync( fd );
+ rtems_test_assert( status == -1 );
+ printf( "%d: %s\n", errno, strerror( errno ) );
+ rtems_test_assert( errno == EBADF );
+
+ puts("ioctl unopened file");
+ status = ioctl( fd, 0 );
+ rtems_test_assert( status == -1 );
+ printf( "%d: %s\n", errno, strerror( errno ) );
+ rtems_test_assert( errno == EBADF );
+
+ puts("_lseek_r unopened file");
+ res = _lseek_r (NULL, fd, 0, SEEK_SET);
+ rtems_test_assert( res == -1 );
+ printf( "%d: %s\n", errno, strerror( errno ) );
+ rtems_test_assert( errno == EBADF );
+
+ puts("readv unopened file");
+ status = readv(fd, vec, 4);
+ rtems_test_assert( status == -1 );
+ printf( "%d: %s\n", errno, strerror( errno ) );
+ rtems_test_assert( errno == EBADF );
+
+ puts("writev unopened file");
+ status = writev(fd, vec, 4);
+ rtems_test_assert( status == -1 );
+ printf( "%d: %s\n", errno, strerror( errno ) );
+ rtems_test_assert( errno == EBADF );
+
+ puts("write unopened file");
+ status = write(fd, "1234", 4);
+ rtems_test_assert( status == -1 );
+ printf( "%d: %s\n", errno, strerror( errno ) );
+ rtems_test_assert( errno == EBADF );
+
+
+
+
+ puts( "*** END OF PSXFILE02 TEST ***" );
+
+ 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_INIT
+
+#include <rtems/confdefs.h>
+/* end of file */
diff --git a/testsuites/psxtests/psxfile02/psxfile02.doc b/testsuites/psxtests/psxfile02/psxfile02.doc
new file mode 100644
index 0000000000..38dcb887d0
--- /dev/null
+++ b/testsuites/psxtests/psxfile02/psxfile02.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.
+
+test set name: psxfile02
+
+directives:
+
+ XXX list them
+
+concepts:
+
++ XXX list them
diff --git a/testsuites/psxtests/psxfile02/psxfile02.scn b/testsuites/psxtests/psxfile02/psxfile02.scn
new file mode 100644
index 0000000000..b581c52b52
--- /dev/null
+++ b/testsuites/psxtests/psxfile02/psxfile02.scn
@@ -0,0 +1,26 @@
+*** PSXFILE02 TEST ***
+mkdir /tmp
+open /tmp/j
+open returned file descriptor 3
+close /tmp/j
+ftruncate an unopened file
+9: Bad file number
+_fcntl_r unopened file
+9: Bad file number
+fdatasync unopened file
+9: Bad file number
+fstat unopened file
+9: Bad file number
+fsync unopened file
+9: Bad file number
+ioctl unopened file
+9: Bad file number
+_lseek_r unopened file
+9: Bad file number
+readv unopened file
+9: Bad file number
+writev unopened file
+9: Bad file number
+write unopened file
+9: Bad file number
+*** END OF PSXFILE02 TEST ***