0001 KSelfTest arm64/signal/
0002 =======================
0003
0004 Signals Tests
0005 +++++++++++++
0006
0007 - Tests are built around a common main compilation unit: such shared main
0008 enforces a standard sequence of operations needed to perform a single
0009 signal-test (setup/trigger/run/result/cleanup)
0010
0011 - The above mentioned ops are configurable on a test-by-test basis: each test
0012 is described (and configured) using the descriptor signals.h::struct tdescr
0013
0014 - Each signal testcase is compiled into its own executable: a separate
0015 executable is used for each test since many tests complete successfully
0016 by receiving some kind of fatal signal from the Kernel, so it's safer
0017 to run each test unit in its own standalone process, so as to start each
0018 test from a clean slate.
0019
0020 - New tests can be simply defined in testcases/ dir providing a proper struct
0021 tdescr overriding all the defaults we wish to change (as of now providing a
0022 custom run method is mandatory though)
0023
0024 - Signals' test-cases hereafter defined belong currently to two
0025 principal families:
0026
0027 - 'mangle_' tests: a real signal (SIGUSR1) is raised and used as a trigger
0028 and then the test case code modifies the signal frame from inside the
0029 signal handler itself.
0030
0031 - 'fake_sigreturn_' tests: a brand new custom artificial sigframe structure
0032 is placed on the stack and a sigreturn syscall is called to simulate a
0033 real signal return. This kind of tests does not use a trigger usually and
0034 they are just fired using some simple included assembly trampoline code.
0035
0036 - Most of these tests are successfully passing if the process gets killed by
0037 some fatal signal: usually SIGSEGV or SIGBUS. Since while writing this
0038 kind of tests it is extremely easy in fact to end-up injecting other
0039 unrelated SEGV bugs in the testcases, it becomes extremely tricky to
0040 be really sure that the tests are really addressing what they are meant
0041 to address and they are not instead falling apart due to unplanned bugs
0042 in the test code.
0043 In order to alleviate the misery of the life of such test-developer, a few
0044 helpers are provided:
0045
0046 - a couple of ASSERT_BAD/GOOD_CONTEXT() macros to easily parse a ucontext_t
0047 and verify if it is indeed GOOD or BAD (depending on what we were
0048 expecting), using the same logic/perspective as in the arm64 Kernel signals
0049 routines.
0050
0051 - a sanity mechanism to be used in 'fake_sigreturn_'-alike tests: enabled by
0052 default it takes care to verify that the test-execution had at least
0053 successfully progressed up to the stage of triggering the fake sigreturn
0054 call.
0055
0056 In both cases test results are expected in terms of:
0057 - some fatal signal sent by the Kernel to the test process
0058 or
0059 - analyzing some final regs state