1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
From 4c8c4a9c3a92300e3e6500e5a278ca37514a1fdb Mon Sep 17 00:00:00 2001
From: Yi Fan Yu <yifan.yu@windriver.com>
Date: Thu, 1 Apr 2021 15:31:47 -0400
Subject: [PATCH] drd/tests/swapcontext: Add SIGALRM handler to avoid
stacktrace
During testing for oe-core build on QEMU,
SIGALRM can trigger during nanosleep.
This results a different stderr output than expected.
```
==277== Process terminating with default action of signal 14 (SIGALRM)
==277== at 0x36C74C3943: clock_nanosleep@@GLIBC_2.17 (clock_nanosleep.c:43)
==277== by 0x36C74C8726: nanosleep (nanosleep.c:25)
```
This stacktrace printing will not occur
if we add a handler that simply exits.
https://bugs.kde.org/show_bug.cgi?id=435160
Signed-off-by: Yi Fan Yu <yifan.yu@windriver.com>
---
drd/tests/swapcontext.c | 5 +++++
drd/tests/swapcontext.stderr.exp | 4 ----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drd/tests/swapcontext.c b/drd/tests/swapcontext.c
index 622c70bc5..2cb969a5e 100644
--- a/drd/tests/swapcontext.c
+++ b/drd/tests/swapcontext.c
@@ -25,6 +25,10 @@ typedef struct thread_local {
size_t nrsw;
} thread_local_t;
+static void sig_alrm_handler(int signo) {
+ _exit(1);
+}
+
static void f(void *data, int n)
{
enum { NR_SWITCHES = 200000 };
@@ -76,6 +80,7 @@ int main(int argc, char *argv[])
pthread_attr_t attr;
int i, res;
+ signal(SIGALRM, sig_alrm_handler);
memset(tlocal, 0, sizeof(tlocal));
pthread_attr_init(&attr);
diff --git a/drd/tests/swapcontext.stderr.exp b/drd/tests/swapcontext.stderr.exp
index fcb5d5ed4..d18786f80 100644
--- a/drd/tests/swapcontext.stderr.exp
+++ b/drd/tests/swapcontext.stderr.exp
@@ -1,7 +1,3 @@
-Process terminating with default action of signal 14 (SIGALRM)
- at 0x........: swapcontext (in /...libc...)
- by 0x........: f (swapcontext.c:?)
-
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
--
2.17.1
|