[PATCH v1 3/3] testsuite: Add machine exception signal map test

Kinsey Moore kinsey.moore at oarcorp.com
Wed Apr 14 15:47:00 UTC 2021


Add a test to verify that mapping of machine exceptions to POSIX signals
operates properly when the application requests it.
---
 spec/build/testsuites/psxtests/grp.yml        |  2 +
 .../build/testsuites/psxtests/psxsignal09.yml | 22 ++++++++
 testsuites/psxtests/psxsignal09/init.c        | 54 +++++++++++++++++++
 .../psxtests/psxsignal09/psxsignal09.doc      |  7 +++
 .../psxtests/psxsignal09/psxsignal09.scn      |  7 +++
 testsuites/psxtests/psxsignal09/system.h      | 39 ++++++++++++++
 6 files changed, 131 insertions(+)
 create mode 100644 spec/build/testsuites/psxtests/psxsignal09.yml
 create mode 100644 testsuites/psxtests/psxsignal09/init.c
 create mode 100644 testsuites/psxtests/psxsignal09/psxsignal09.doc
 create mode 100644 testsuites/psxtests/psxsignal09/psxsignal09.scn
 create mode 100644 testsuites/psxtests/psxsignal09/system.h

diff --git a/spec/build/testsuites/psxtests/grp.yml b/spec/build/testsuites/psxtests/grp.yml
index fb7ce465ae..f61f45dbe9 100644
--- a/spec/build/testsuites/psxtests/grp.yml
+++ b/spec/build/testsuites/psxtests/grp.yml
@@ -205,6 +205,8 @@ links:
   uid: psxsignal07
 - role: build-dependency
   uid: psxsignal08
+- role: build-dependency
+  uid: psxsignal09
 - role: build-dependency
   uid: psxspin01
 - role: build-dependency
diff --git a/spec/build/testsuites/psxtests/psxsignal09.yml b/spec/build/testsuites/psxtests/psxsignal09.yml
new file mode 100644
index 0000000000..228b1cf6c8
--- /dev/null
+++ b/spec/build/testsuites/psxtests/psxsignal09.yml
@@ -0,0 +1,22 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: test-program
+cflags: []
+copyrights:
+- Copyright (C) 2021 On-Line Applications Research (OAR)
+cppflags: []
+cxxflags: []
+enabled-by:
+- and:
+  - RTEMS_POSIX_API
+  - aarch64
+features: c cprogram
+includes: []
+ldflags: []
+links: []
+source:
+- testsuites/psxtests/psxsignal09/init.c
+stlib: []
+target: testsuites/psxtests/psxsignal09.exe
+type: build
+use-after: []
+use-before: []
diff --git a/testsuites/psxtests/psxsignal09/init.c b/testsuites/psxtests/psxsignal09/init.c
new file mode 100644
index 0000000000..a629edcb9f
--- /dev/null
+++ b/testsuites/psxtests/psxsignal09/init.c
@@ -0,0 +1,54 @@
+/*
+ *  COPYRIGHT (c) 1989-2012.
+ *  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.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+#include <signal.h>
+#include <errno.h>
+#include <reent.h>
+
+const char rtems_test_name[] = "PSXSIGNAL 9";
+
+static void Handler_1(
+  int signo
+)
+{
+  TEST_END();
+  rtems_test_exit(0);
+}
+
+void *POSIX_Init(
+  void *argument
+)
+{
+  int               status;
+  struct sigaction  act;
+
+  TEST_BEGIN();
+
+  /* Hook signals that can be generated from machine exceptions */
+  act.sa_handler = Handler_1;
+  act.sa_flags   = 0;
+  status = sigaction( SIGFPE, &act, NULL );
+  rtems_test_assert( !status );
+  status = sigaction( SIGILL, &act, NULL );
+  rtems_test_assert( !status );
+  status = sigaction( SIGSEGV, &act, NULL );
+  rtems_test_assert( !status );
+
+  /* Generate machine exception */
+  _CPU_Instruction_illegal();
+
+  rtems_test_exit(0);
+  return NULL;
+}
diff --git a/testsuites/psxtests/psxsignal09/psxsignal09.doc b/testsuites/psxtests/psxsignal09/psxsignal09.doc
new file mode 100644
index 0000000000..5375ee6c20
--- /dev/null
+++ b/testsuites/psxtests/psxsignal09/psxsignal09.doc
@@ -0,0 +1,7 @@
+#  COPYRIGHT (c) 2021.
+#  On-Line Applications Research Corporation (OAR).
+#
+#  SPDX-License-Identifier: BSD-2-Clause
+
+This test ensures that machine exceptions are mapped to POSIX signals when
+required by the application.
diff --git a/testsuites/psxtests/psxsignal09/psxsignal09.scn b/testsuites/psxtests/psxsignal09/psxsignal09.scn
new file mode 100644
index 0000000000..7a6811d4cd
--- /dev/null
+++ b/testsuites/psxtests/psxsignal09/psxsignal09.scn
@@ -0,0 +1,7 @@
+*** BEGIN OF TEST PSXSIGNAL 9 ***
+*** TEST VERSION: 6.0.0.ac1904e181f846c235e10a9c5ce3b5de71c782c8
+*** TEST STATE: EXPECTED_PASS
+*** TEST BUILD: RTEMS_POSIX_API
+*** TEST TOOLS: 10.2.1 20210315 (RTEMS 6, RSB f253cb8166f423fa1017a0410a18585ccf6b26a4-modified, Newlib d10d0d9)
+
+*** END OF TEST PSXSIGNAL 9 ***
diff --git a/testsuites/psxtests/psxsignal09/system.h b/testsuites/psxtests/psxsignal09/system.h
new file mode 100644
index 0000000000..c054794141
--- /dev/null
+++ b/testsuites/psxtests/psxsignal09/system.h
@@ -0,0 +1,39 @@
+/*  system.h
+ *
+ *  This include file contains information that is included in every
+ *  function in the test set.
+ *
+ *  COPYRIGHT (c) 1989-1999.
+ *  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.org/license/LICENSE.
+ */
+
+/* functions */
+
+#include <pmacros.h>
+
+void *POSIX_Init(
+  void *argument
+);
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_EXCEPTION_TO_SIGNAL_MAPPING
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS        1
+#define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 1
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE \
+        (RTEMS_MINIMUM_STACK_SIZE * 4)
+
+#include <rtems/confdefs.h>
+
+/* end of include file */
-- 
2.20.1



More information about the devel mailing list