summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-07-20 07:45:51 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-07-23 09:27:48 +0200
commit6b795cd75d76fe68e6b9d841f7b69488984fa9e7 (patch)
tree52eb6fdbf56b3f3630f78900bd67a346e6bf48d9 /testsuites
parentspintrcritical23: Use T_interrupt_test() (diff)
downloadrtems-6b795cd75d76fe68e6b9d841f7b69488984fa9e7.tar.bz2
spintrcritical24: Use T_interrupt_test()
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/sptests/Makefile.am4
-rw-r--r--testsuites/sptests/spintrcritical24/init.c122
-rw-r--r--testsuites/sptests/spintrcritical24/spintrcritical24.scn32
3 files changed, 119 insertions, 39 deletions
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 14826811dc..5404ba4302 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -1380,9 +1380,7 @@ if TEST_spintrcritical24
sp_tests += spintrcritical24
sp_screens += spintrcritical24/spintrcritical24.scn
sp_docs += spintrcritical24/spintrcritical24.doc
-spintrcritical24_SOURCES = spintrcritical24/init.c \
- spintrcritical_support/intrcritical.h \
- spintrcritical_support/intrcritical.c
+spintrcritical24_SOURCES = spintrcritical24/init.c
spintrcritical24_CPPFLAGS = $(AM_CPPFLAGS) \
$(TEST_FLAGS_spintrcritical24) $(support_includes) \
-I$(top_srcdir)/spintrcritical_support
diff --git a/testsuites/sptests/spintrcritical24/init.c b/testsuites/sptests/spintrcritical24/init.c
index 785ebacadd..347b707355 100644
--- a/testsuites/sptests/spintrcritical24/init.c
+++ b/testsuites/sptests/spintrcritical24/init.c
@@ -1,11 +1,5 @@
/*
- * Copyright (c) 2017 embedded brains GmbH. All rights reserved.
- *
- * embedded brains GmbH
- * Dornierstr. 4
- * 82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
+ * Copyright (C) 2017, 2020 embedded brains GmbH (http://www.embedded-brains.de)
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -17,25 +11,29 @@
#endif
#include <sys/stat.h>
+#include <errno.h>
#include <fcntl.h>
+#include <string.h>
#include <unistd.h>
-#include <errno.h>
#include <rtems/imfs.h>
-
-#include <tmacros.h>
-#include <intrcritical.h>
+#include <rtems/libio_.h>
+#include <rtems/test-info.h>
+#include <rtems/test.h>
const char rtems_test_name[] = "SPINTRCRITICAL 24";
typedef struct {
int fd;
+ rtems_libio_t *iop;
+ long early_count;
+ long late_count;
+ long potential_hit_count;
long append_count;
long no_append_count;
+ volatile bool closed;
} test_context;
-static test_context test_instance;
-
static const char path[] = "generic";
static int handler_close(rtems_libio_t *iop)
@@ -43,6 +41,7 @@ static int handler_close(rtems_libio_t *iop)
test_context *ctx;
ctx = IMFS_generic_get_context_by_iop(iop);
+ ctx->closed = true;
if (rtems_libio_iop_is_append(iop)) {
++ctx->append_count;
@@ -67,67 +66,120 @@ static const IMFS_node_control node_control = {
.node_destroy = IMFS_node_destroy_default
};
-static void do_fcntl(rtems_id timer, void *arg)
+static T_interrupt_test_state interrupt(void *arg)
{
- /* The arg is NULL */
test_context *ctx;
+ T_interrupt_test_state state;
int rv;
+ unsigned int flags;
+
+ state = T_interrupt_test_get_state();
- ctx = &test_instance;
+ if (state != T_INTERRUPT_TEST_ACTION) {
+ return T_INTERRUPT_TEST_CONTINUE;
+ }
+
+ ctx = arg;
+ flags = rtems_libio_iop_flags_set(ctx->iop, 0);
+
+ if ((flags & LIBIO_FLAGS_OPEN) != 0) {
+ ++ctx->early_count;
+ state = T_INTERRUPT_TEST_EARLY;
+ } else if (ctx->closed) {
+ ++ctx->late_count;
+ state = T_INTERRUPT_TEST_LATE;
+ } else {
+ ++ctx->potential_hit_count;
+
+ if (ctx->potential_hit_count >= 13) {
+ state = T_INTERRUPT_TEST_DONE;
+ } else {
+ state = T_INTERRUPT_TEST_CONTINUE;
+ }
+ }
rv = fcntl(ctx->fd, F_SETFL, O_APPEND);
if (rv != 0) {
- rtems_test_assert(rv == -1);
- rtems_test_assert(errno == EBADF);
+ T_quiet_psx_error(rv, EBADF);
}
+
+ return state;
}
-static bool test_body(void *arg)
+static void prepare(void *arg)
{
test_context *ctx;
- int rv;
ctx = arg;
ctx->fd = open(path, O_RDWR);
- rtems_test_assert(ctx->fd >= 0);
+ T_quiet_ge_int(ctx->fd, 0);
+
+ ctx->closed = false;
+ ctx->iop = rtems_libio_iop(ctx->fd);
+}
+
+static void action(void *arg)
+{
+ test_context *ctx;
+ int rv;
+
+ ctx = arg;
rv = close(ctx->fd);
- rtems_test_assert(rv == 0);
+ T_quiet_psx_success(rv);
- return false;
+ T_interrupt_test_busy_wait_for_interrupt();
}
-static void test(test_context *ctx)
+static const T_interrupt_test_config config = {
+ .prepare = prepare,
+ .action = action,
+ .interrupt = interrupt,
+ .max_iteration_count = 10000
+};
+
+T_TEST_CASE(CloseInterrupt)
{
+ test_context ctx;
const char *path = "generic";
int rv;
+ T_interrupt_test_state state;
+
+ memset(&ctx, 0, sizeof(ctx));
rv = IMFS_make_generic_node(
path,
S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
&node_control,
- ctx
+ &ctx
);
- rtems_test_assert(rv == 0);
+ T_psx_success(rv);
+
+ state = T_interrupt_test(&config, &ctx);
+ T_eq_int(state, T_INTERRUPT_TEST_DONE);
- interrupt_critical_section_test(test_body, ctx, do_fcntl);
+ T_log(T_NORMAL, "early count = %ld", ctx.early_count);
+ T_log(T_NORMAL, "late count = %ld", ctx.late_count);
+ T_log(T_NORMAL, "potential hit count = %ld", ctx.potential_hit_count);
+ T_log(T_NORMAL, "append count = %ld", ctx.append_count);
+ T_log(T_NORMAL, "no append count = %ld", ctx.no_append_count);
/* 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);
+ T_gt_int(ctx.early_count, 0);
+ T_gt_int(ctx.late_count, 0);
+ T_gt_int(ctx.potential_hit_count, 0);
+ T_gt_int(ctx.append_count, 0);
+ T_gt_int(ctx.no_append_count, 0);
rv = unlink(path);
- rtems_test_assert(rv == 0);
+ T_psx_success(rv);
}
static void Init(rtems_task_argument arg)
{
- TEST_BEGIN();
- test(&test_instance);
- TEST_END();
- rtems_test_exit(0);
+ rtems_test_run(arg, TEST_STATE);
}
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
@@ -138,8 +190,6 @@ static void Init(rtems_task_argument arg)
#define CONFIGURE_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
diff --git a/testsuites/sptests/spintrcritical24/spintrcritical24.scn b/testsuites/sptests/spintrcritical24/spintrcritical24.scn
index 3f2eef3853..9022f5d6e4 100644
--- a/testsuites/sptests/spintrcritical24/spintrcritical24.scn
+++ b/testsuites/sptests/spintrcritical24/spintrcritical24.scn
@@ -1,2 +1,34 @@
*** BEGIN OF TEST SPINTRCRITICAL 24 ***
+*** TEST VERSION: 6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
+*** TEST STATE: EXPECTED_PASS
+*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API RTEMS_SMP
+*** TEST TOOLS: 10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
+A:SPINTRCRITICAL 24
+S:Platform:RTEMS
+S:Compiler:10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
+S:Version:6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
+S:BSP:realview_pbx_a9_qemu
+S:RTEMS_DEBUG:1
+S:RTEMS_MULTIPROCESSING:0
+S:RTEMS_POSIX_API:1
+S:RTEMS_PROFILING:0
+S:RTEMS_SMP:1
+B:CloseInterrupt
+P:0:0:UI1:init.c:164
+P:1:0:UI1:init.c:167
+L:early count = 743
+L:late count = 805
+L:potential hit count = 13
+L:append count = 743
+L:no append count = 818
+P:2:0:UI1:init.c:176
+P:3:0:UI1:init.c:177
+P:4:0:UI1:init.c:178
+P:5:0:UI1:init.c:179
+P:6:0:UI1:init.c:180
+P:7:0:UI1:init.c:183
+E:CloseInterrupt:N:8:F:0:D:2.052931
+Z:SPINTRCRITICAL 24:C:1:N:8:F:0:D:2.054026
+Y:ReportHash:SHA256:950758e81490ad319486e6dc135fe5634bc9c9e7b19537346335e759f932fb56
+
*** END OF TEST SPINTRCRITICAL 24 ***