source: rtems/testsuites/psxtests/psxsignal09/init.c @ c5986a5

Last change on this file since c5986a5 was c5986a5, checked in by Kinsey Moore <kinsey.moore@…>, on 04/05/21 at 20:14:22

testsuite: Add machine exception signal map test

Add a test to verify that mapping of machine exceptions to POSIX signals
operates properly when the application requests it.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup psxtests
7 */
8
9/*
10 * Copyright (C) 2021 On-Line Applications Research Corporation (OAR)
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 *    notice, this list of conditions and the following disclaimer in the
19 *    documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifdef HAVE_CONFIG_H
35#include "config.h"
36#endif
37
38#define CONFIGURE_INIT
39#include "system.h"
40#include <signal.h>
41#include <errno.h>
42#include <reent.h>
43
44const char rtems_test_name[] = "PSXSIGNAL 9";
45
46static void Handler_1( int signo )
47{
48  TEST_END();
49  rtems_test_exit(0);
50}
51
52void *POSIX_Init( void *argument )
53{
54  int              status;
55  struct sigaction act;
56
57  TEST_BEGIN();
58
59  /* Hook signals that can be generated from machine exceptions */
60  act.sa_handler = Handler_1;
61  act.sa_flags   = 0;
62  status = sigaction( SIGFPE, &act, NULL );
63  rtems_test_assert( !status );
64  status = sigaction( SIGILL, &act, NULL );
65  rtems_test_assert( !status );
66  status = sigaction( SIGSEGV, &act, NULL );
67  rtems_test_assert( !status );
68
69  /* Generate machine exception */
70  _CPU_Instruction_illegal();
71
72  return NULL;
73}
Note: See TracBrowser for help on using the repository browser.