summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-13 09:22:19 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-15 10:29:34 +0200
commitbaef823cd550449bfbcc36625b9571389d8ad1af (patch)
tree238c1952d23dc09d41ae99d186d0656f78ed857b /testsuites/sptests
parentlibio: Unify readv() and writev() (diff)
downloadrtems-baef823cd550449bfbcc36625b9571389d8ad1af.tar.bz2
libio: Add hold/drop iop reference
Check iop reference count in close() and return -1 with errno set to EBUSY in case the file descriptor is still in use. Update #3132.
Diffstat (limited to 'testsuites/sptests')
-rw-r--r--testsuites/sptests/Makefile.am1
-rw-r--r--testsuites/sptests/configure.ac1
-rw-r--r--testsuites/sptests/spintrcritical24/Makefile.am22
-rw-r--r--testsuites/sptests/spintrcritical24/init.c150
-rw-r--r--testsuites/sptests/spintrcritical24/spintrcritical24.doc13
-rw-r--r--testsuites/sptests/spintrcritical24/spintrcritical24.scn2
6 files changed, 189 insertions, 0 deletions
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 890dd38571..e873718e72 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -33,6 +33,7 @@ _SUBDIRS = \
spsignal_err01 spport_err01 spmsgq_err01 spmsgq_err02 spsem_err01 \
spsem_err02 sptask_err01 spevent_err03 sptask_err03 sptask_err02 \
sptask_err04 spclock_err01
+_SUBDIRS += spintrcritical24
_SUBDIRS += spfatal29
_SUBDIRS += spfatal30
_SUBDIRS += spfatal31
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 88d6ed6aa2..7bdb02c9a7 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -36,6 +36,7 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes")
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile
+spintrcritical24/Makefile
spfatal31/Makefile
spfatal30/Makefile
spmutex01/Makefile
diff --git a/testsuites/sptests/spintrcritical24/Makefile.am b/testsuites/sptests/spintrcritical24/Makefile.am
new file mode 100644
index 0000000000..798666e361
--- /dev/null
+++ b/testsuites/sptests/spintrcritical24/Makefile.am
@@ -0,0 +1,22 @@
+rtems_tests_PROGRAMS = spintrcritical24
+spintrcritical24_SOURCES = init.c
+spintrcritical24_SOURCES += ../spintrcritical_support/intrcritical.h
+spintrcritical24_SOURCES += ../spintrcritical_support/intrcritical.c
+
+dist_rtems_tests_DATA = spintrcritical24.scn spintrcritical24.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
+AM_CPPFLAGS += -I$(top_srcdir)/spintrcritical_support
+
+LINK_OBJS = $(spintrcritical24_OBJECTS)
+LINK_LIBS = $(spintrcritical24_LDLIBS)
+
+spintrcritical24$(EXEEXT): $(spintrcritical24_OBJECTS) $(spintrcritical24_DEPENDENCIES)
+ @rm -f spintrcritical24$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spintrcritical24/init.c b/testsuites/sptests/spintrcritical24/init.c
new file mode 100644
index 0000000000..8f60c1ce70
--- /dev/null
+++ b/testsuites/sptests/spintrcritical24/init.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2017 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <rtems/imfs.h>
+
+#include <tmacros.h>
+#include <intrcritical.h>
+
+const char rtems_test_name[] = "SPINTRCRITICAL 24";
+
+typedef struct {
+ int fd;
+ long append_count;
+ long no_append_count;
+} test_context;
+
+static test_context test_instance;
+
+static const char path[] = "generic";
+
+static int handler_close(rtems_libio_t *iop)
+{
+ test_context *ctx;
+
+ ctx = IMFS_generic_get_context_by_iop(iop);
+
+ if (rtems_libio_iop_is_append(iop)) {
+ ++ctx->append_count;
+ } else {
+ ++ctx->no_append_count;
+ }
+
+ return 0;
+}
+
+static const rtems_filesystem_file_handlers_r node_handlers = {
+ .open_h = rtems_filesystem_default_open,
+ .close_h = handler_close,
+ .fstat_h = rtems_filesystem_default_fstat,
+ .fcntl_h = rtems_filesystem_default_fcntl
+};
+
+static const IMFS_node_control node_control = {
+ .handlers = &node_handlers,
+ .node_initialize = IMFS_node_initialize_generic,
+ .node_remove = IMFS_node_remove_default,
+ .node_destroy = IMFS_node_destroy_default
+};
+
+static void do_fcntl(rtems_id timer, void *arg)
+{
+ /* The arg is NULL */
+ test_context *ctx;
+ int rv;
+
+ ctx = &test_instance;
+
+ rv = fcntl(ctx->fd, F_SETFL, O_APPEND);
+
+ if (rv != 0) {
+ rtems_test_assert(rv == -1);
+ rtems_test_assert(errno == EBADF);
+ }
+}
+
+static bool test_body(void *arg)
+{
+ test_context *ctx;
+ int rv;
+
+ ctx = arg;
+
+ ctx->fd = open(path, O_RDWR);
+ rtems_test_assert(ctx->fd >= 0);
+
+ rv = close(ctx->fd);
+ rtems_test_assert(rv == 0);
+
+ return false;
+}
+
+static void test(test_context *ctx)
+{
+ const char *path = "generic";
+ int rv;
+
+ rv = IMFS_make_generic_node(
+ path,
+ S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
+ &node_control,
+ ctx
+ );
+ rtems_test_assert(rv == 0);
+
+ interrupt_critical_section_test(test_body, ctx, do_fcntl);
+
+ /* There is no reliable indicator if the test case has been hit */
+ rtems_test_assert(ctx->append_count > 0);
+ rtems_test_assert(ctx->no_append_count > 0);
+
+ rv = unlink(path);
+ rtems_test_assert(rv == 0);
+}
+
+static void Init(rtems_task_argument arg)
+{
+ TEST_BEGIN();
+ test(&test_instance);
+ TEST_END();
+ rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 1000
+
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+#define CONFIGURE_MAXIMUM_TIMERS 1
+#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/sptests/spintrcritical24/spintrcritical24.doc b/testsuites/sptests/spintrcritical24/spintrcritical24.doc
new file mode 100644
index 0000000000..c8714bedf2
--- /dev/null
+++ b/testsuites/sptests/spintrcritical24/spintrcritical24.doc
@@ -0,0 +1,13 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: spintrcritical24
+
+directives:
+
+ - fcntl()
+ - close()
+
+concepts:
+
+ - Try to ensure that a close completes successful in case it is interrupted
+ by a call to fcntl() altering the iop flags.
diff --git a/testsuites/sptests/spintrcritical24/spintrcritical24.scn b/testsuites/sptests/spintrcritical24/spintrcritical24.scn
new file mode 100644
index 0000000000..3f2eef3853
--- /dev/null
+++ b/testsuites/sptests/spintrcritical24/spintrcritical24.scn
@@ -0,0 +1,2 @@
+*** BEGIN OF TEST SPINTRCRITICAL 24 ***
+*** END OF TEST SPINTRCRITICAL 24 ***