From 98dc504a042a95d4c26ffde51c493ab106f4db8e Mon Sep 17 00:00:00 2001 From: Denis Drakhnia Date: Mon, 25 Dec 2023 07:38:16 +0200 Subject: [PATCH] base: add signal tests --- tests/asm/base/signal-1.S | 14 ++++++++ tests/asm/include/common.S | 73 ++++++++++++++++++++++++++++++++++++++ tests/asm/meson.build | 1 + tests/meson.build | 1 - 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 tests/asm/base/signal-1.S diff --git a/tests/asm/base/signal-1.S b/tests/asm/base/signal-1.S new file mode 100644 index 0000000..2e05d2b --- /dev/null +++ b/tests/asm/base/signal-1.S @@ -0,0 +1,14 @@ +#include "test_start.S" + + sys_rt_sigaction SIGSEGV, act + ldb,5 [ 0 ], %empty + sys_exit 1 + +#include "test_end.S" + +sig_handler: + sys_exit 0 + + .section ".rodata" +act: + init_sigaction sig_handler diff --git a/tests/asm/include/common.S b/tests/asm/include/common.S index 6bd5abd..25622de 100644 --- a/tests/asm/include/common.S +++ b/tests/asm/include/common.S @@ -3,6 +3,8 @@ #define NR_exit 1 #define NR_write 4 +#define NR_rt_sigaction 174 +#define NR_rt_sigreturn 173 #define SCRATCH_REG0 %g23 #define SCRATCH_REG1 %g22 @@ -92,6 +94,77 @@ #define writeln(MSG) write(MSG "\n") +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGRTMIN 32 + +#define SA_SIGINFO 0x00000004 + + .macro init_sigaction handler=0, flags=0, restorer=0, mask=0 + .quad \handler + .quad \flags + .quad \restorer + .quad \mask + .endm + + .macro sys_rt_sigaction sig, acc=0, oldacc=0 + { + setwd wsz=8, nfx=1 + addd,0 0, NR_rt_sigaction, %r8 + addd,1 0, \sig, %r9 + sdisp %ctpr1, 0x3 + nop 4 + } + { + addd,0 0, \acc, %r10 + addd,1 0, \oldacc, %r11 + addd,2 0, 8, %r12 + call %ctpr1, wbs=4 + } + .endm + + .macro sys_rt_sigreturn + { + setwd wsz=8, nfx=1 + sdisp %ctpr1, 0x3 + } + { + addd,0 0, NR_rt_sigreturn, %r8 + addd,1 0, 0, %r9 + call %ctpr1, wbs=4 + } + .endm + #define assert_(PRED, MSG) \ ibranch local(ok) ? PRED; \ write("assert at " __FILE__ ":" str(__LINE__) ":\n" \ diff --git a/tests/asm/meson.build b/tests/asm/meson.build index 4f66c9b..89d5e84 100644 --- a/tests/asm/meson.build +++ b/tests/asm/meson.build @@ -43,6 +43,7 @@ asm_tests = { 'exit-0': {}, 'exit-1': { 'should_fail': true }, 'template': {}, + 'signal-1': {}, }, 'win': { 'setwd-1': {}, diff --git a/tests/meson.build b/tests/meson.build index 1700b48..f906615 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,3 +1,2 @@ subdir('asm') subdir('c') -