summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/strace
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2016-02-29 19:41:43 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-09 16:58:12 +0000
commit2193e9d064c1f99617e3010e884741657d856419 (patch)
treec257f009a1a0721f16914342e03bc7f6f1de3ce1 /meta/recipes-devtools/strace
parentee8ff4263476f2f5c45c08b212e0e7423e6abedf (diff)
downloadpoky-2193e9d064c1f99617e3010e884741657d856419.tar.gz
strace: Backport fixes for compiling with clang
Backport fixes needed to avoid use of VLAs which is not available on clang/llvm (From OE-Core rev: 57881c3dc68bd8697aaac7fa3587202121a042a4) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/strace')
-rw-r--r--meta/recipes-devtools/strace/strace/0001-Move-gcc-compat-macros-to-gcc_compat.h.patch176
-rw-r--r--meta/recipes-devtools/strace/strace/0001-scm_rights-fd.test-rewrite-without-fork.patch198
-rw-r--r--meta/recipes-devtools/strace/strace/0001-tests-introduce-libtests.patch306
-rw-r--r--meta/recipes-devtools/strace/strace/0001-tests-scm_rights.c-use-libtests.patch54
-rw-r--r--meta/recipes-devtools/strace/strace_4.11.bb4
5 files changed, 738 insertions, 0 deletions
diff --git a/meta/recipes-devtools/strace/strace/0001-Move-gcc-compat-macros-to-gcc_compat.h.patch b/meta/recipes-devtools/strace/strace/0001-Move-gcc-compat-macros-to-gcc_compat.h.patch
new file mode 100644
index 0000000000..aa61e15c81
--- /dev/null
+++ b/meta/recipes-devtools/strace/strace/0001-Move-gcc-compat-macros-to-gcc_compat.h.patch
@@ -0,0 +1,176 @@
1From f32126ba790dd4e61d43a2140b24f02426297bb6 Mon Sep 17 00:00:00 2001
2From: "Dmitry V. Levin" <ldv@altlinux.org>
3Date: Thu, 31 Dec 2015 14:19:41 +0000
4Subject: [PATCH] Move gcc compat macros to gcc_compat.h
5
6* defs.h: Include "gcc_compat.h".
7(GNUC_PREREQ, ATTRIBUTE_NORETURN, ATTRIBUTE_FORMAT,
8ATTRIBUTE_ALIGNED, ATTRIBUTE_PACKED, ATTRIBUTE_MALLOC,
9ATTRIBUTE_NOINLINE, ATTRIBUTE_ALLOC_SIZE): Move ...
10* gcc_compat.h: ... here.
11* Makefile.am (strace_SOURCES): Add gcc_compat.h.
12---
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14Upstream-Status: Backport
15
16 Makefile.am | 1 +
17 defs.h | 43 +----------------------------------
18 gcc_compat.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19 3 files changed, 75 insertions(+), 42 deletions(-)
20 create mode 100644 gcc_compat.h
21
22diff --git a/Makefile.am b/Makefile.am
23index ab52778..d43608d 100644
24--- a/Makefile.am
25+++ b/Makefile.am
26@@ -97,6 +97,7 @@ strace_SOURCES = \
27 flock.c \
28 flock.h \
29 futex.c \
30+ gcc_compat.h \
31 get_robust_list.c \
32 getcpu.c \
33 getcwd.c \
34diff --git a/defs.h b/defs.h
35index 283ab1f..bae212c 100644
36--- a/defs.h
37+++ b/defs.h
38@@ -55,6 +55,7 @@
39 #include <sys/syscall.h>
40
41 #include "mpers_type.h"
42+#include "gcc_compat.h"
43
44 #ifndef HAVE_STRERROR
45 const char *strerror(int);
46@@ -68,48 +69,6 @@ const char *strerror(int);
47 extern char *stpcpy(char *dst, const char *src);
48 #endif
49
50-#if defined __GNUC__ && defined __GNUC_MINOR__
51-# define GNUC_PREREQ(maj, min) \
52- ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
53-#else
54-# define __attribute__(x) /* empty */
55-# define GNUC_PREREQ(maj, min) 0
56-#endif
57-
58-#if GNUC_PREREQ(2, 5)
59-# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
60-#else
61-# define ATTRIBUTE_NORETURN /* empty */
62-#endif
63-
64-#if GNUC_PREREQ(2, 7)
65-# define ATTRIBUTE_FORMAT(args) __attribute__((__format__ args))
66-# define ATTRIBUTE_ALIGNED(arg) __attribute__((__aligned__(arg)))
67-# define ATTRIBUTE_PACKED __attribute__((__packed__))
68-#else
69-# define ATTRIBUTE_FORMAT(args) /* empty */
70-# define ATTRIBUTE_ALIGNED(arg) /* empty */
71-# define ATTRIBUTE_PACKED /* empty */
72-#endif
73-
74-#if GNUC_PREREQ(3, 0)
75-# define ATTRIBUTE_MALLOC __attribute__((__malloc__))
76-#else
77-# define ATTRIBUTE_MALLOC /* empty */
78-#endif
79-
80-#if GNUC_PREREQ(3, 1)
81-# define ATTRIBUTE_NOINLINE __attribute__((__noinline__))
82-#else
83-# define ATTRIBUTE_NOINLINE /* empty */
84-#endif
85-
86-#if GNUC_PREREQ(4, 3)
87-# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__((__alloc_size__ args))
88-#else
89-# define ATTRIBUTE_ALLOC_SIZE(args) /* empty */
90-#endif
91-
92 #ifndef offsetof
93 # define offsetof(type, member) \
94 (((char *) &(((type *) NULL)->member)) - ((char *) (type *) NULL))
95diff --git a/gcc_compat.h b/gcc_compat.h
96new file mode 100644
97index 0000000..1f2c835
98--- /dev/null
99+++ b/gcc_compat.h
100@@ -0,0 +1,73 @@
101+/*
102+ * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
103+ * All rights reserved.
104+ *
105+ * Redistribution and use in source and binary forms, with or without
106+ * modification, are permitted provided that the following conditions
107+ * are met:
108+ * 1. Redistributions of source code must retain the above copyright
109+ * notice, this list of conditions and the following disclaimer.
110+ * 2. Redistributions in binary form must reproduce the above copyright
111+ * notice, this list of conditions and the following disclaimer in the
112+ * documentation and/or other materials provided with the distribution.
113+ * 3. The name of the author may not be used to endorse or promote products
114+ * derived from this software without specific prior written permission.
115+ *
116+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
117+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
118+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
119+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
120+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
121+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
122+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
123+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
124+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
125+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
126+ */
127+
128+#ifndef GCC_COMPAT_H_
129+#define GCC_COMPAT_H_
130+
131+#if defined __GNUC__ && defined __GNUC_MINOR__
132+# define GNUC_PREREQ(maj, min) \
133+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
134+#else
135+# define __attribute__(x) /* empty */
136+# define GNUC_PREREQ(maj, min) 0
137+#endif
138+
139+#if GNUC_PREREQ(2, 5)
140+# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
141+#else
142+# define ATTRIBUTE_NORETURN /* empty */
143+#endif
144+
145+#if GNUC_PREREQ(2, 7)
146+# define ATTRIBUTE_FORMAT(args) __attribute__((__format__ args))
147+# define ATTRIBUTE_ALIGNED(arg) __attribute__((__aligned__(arg)))
148+# define ATTRIBUTE_PACKED __attribute__((__packed__))
149+#else
150+# define ATTRIBUTE_FORMAT(args) /* empty */
151+# define ATTRIBUTE_ALIGNED(arg) /* empty */
152+# define ATTRIBUTE_PACKED /* empty */
153+#endif
154+
155+#if GNUC_PREREQ(3, 0)
156+# define ATTRIBUTE_MALLOC __attribute__((__malloc__))
157+#else
158+# define ATTRIBUTE_MALLOC /* empty */
159+#endif
160+
161+#if GNUC_PREREQ(3, 1)
162+# define ATTRIBUTE_NOINLINE __attribute__((__noinline__))
163+#else
164+# define ATTRIBUTE_NOINLINE /* empty */
165+#endif
166+
167+#if GNUC_PREREQ(4, 3)
168+# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__((__alloc_size__ args))
169+#else
170+# define ATTRIBUTE_ALLOC_SIZE(args) /* empty */
171+#endif
172+
173+#endif
174--
1751.9.1
176
diff --git a/meta/recipes-devtools/strace/strace/0001-scm_rights-fd.test-rewrite-without-fork.patch b/meta/recipes-devtools/strace/strace/0001-scm_rights-fd.test-rewrite-without-fork.patch
new file mode 100644
index 0000000000..c4e645b81f
--- /dev/null
+++ b/meta/recipes-devtools/strace/strace/0001-scm_rights-fd.test-rewrite-without-fork.patch
@@ -0,0 +1,198 @@
1From 3fdcdd47c6a67585123a0a0c8fffabcc9f79a3a2 Mon Sep 17 00:00:00 2001
2From: "Dmitry V. Levin" <ldv@altlinux.org>
3Date: Tue, 12 Jan 2016 14:47:12 +0000
4Subject: [PATCH] scm_rights-fd.test: rewrite without fork
5
6* tests/scm_rights.c (main): Rewrite without fork.
7Place all objects passed to sendmsg and recvmsg at the end
8of memory pages followed by inaccessible pages.
9* tests/scm_rights-fd.test: Update.
10---
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12Upstream-Status: Backport
13
14 tests/scm_rights-fd.test | 12 ++---
15 tests/scm_rights.c | 122 ++++++++++++++++++++++-------------------------
16 2 files changed, 63 insertions(+), 71 deletions(-)
17
18diff --git a/tests/scm_rights-fd.test b/tests/scm_rights-fd.test
19index a32ef36..48c5028 100755
20--- a/tests/scm_rights-fd.test
21+++ b/tests/scm_rights-fd.test
22@@ -49,18 +49,18 @@ touch -- "$file" ||
23 framework_skip_ 'failed to create a file'
24
25 run_prog ./scm_rights /dev/zero
26-run_strace_merge -y -x -enetwork $args "$file"
27+run_strace -y -x -enetwork $args "$file"
28
29+sample='\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff'
30 n='[1-9][0-9]*'
31-msg='\{msg_name\(0\)=NULL, msg_iov\(1\)=\[\{"\\x00\\x00\\x00\\x00[^"]*", '"$n"'\}\], msg_controllen='"$n"
32-rights='\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, \[3</dev/null>, 4</dev/zero>, 5</[^}>]*/(A\\n){127}Z>\]\}'
33+msg='\{msg_name\(0\)=NULL, msg_iov\(1\)=\[\{"'"$sample"'", 15\}\], msg_controllen='"$n"
34+rights='\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, \[4</dev/null>, 5</dev/zero>, 6</[^}>]*/(A\\n){127}Z>\]\}'
35 creds='\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS, \{pid='"$n"', uid=[0-9]+, gid=[0-9]+\}\}'
36-prefix='[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +'
37 EXPECTED="$LOG.expected"
38
39 cat > "$EXPECTED" << __EOF__
40-${prefix}sendmsg\\(1<socket:\\[[0-9]+\\]>, $msg, \\[$rights\\], msg_flags=0\\}, 0\\) += $n
41-${prefix}recvmsg\\(0<socket:\\[[0-9]+\\]>, $msg, \\[$creds, $rights\\], msg_flags=0\\}, 0\\) += $n
42+sendmsg\\(3<socket:\\[[0-9]+\\]>, $msg, \\[$rights\\], msg_flags=0\\}, 0\\) = 15
43+recvmsg\\(0<socket:\\[[0-9]+\\]>, $msg, \\[$creds, $rights\\], msg_flags=0\\}, 0\\) = 15
44 __EOF__
45
46 match_grep "$LOG" "$EXPECTED"
47diff --git a/tests/scm_rights.c b/tests/scm_rights.c
48index 1e5e850..00af4d5 100644
49--- a/tests/scm_rights.c
50+++ b/tests/scm_rights.c
51@@ -27,26 +27,39 @@
52
53 #include "tests.h"
54 #include <assert.h>
55-#include <string.h>
56-#include <stdlib.h>
57-#include <unistd.h>
58 #include <errno.h>
59 #include <fcntl.h>
60+#include <stdlib.h>
61+#include <string.h>
62+#include <unistd.h>
63 #include <sys/socket.h>
64-#include <sys/wait.h>
65
66 int main(int ac, const char **av)
67 {
68- int i;
69- int data = 0;
70- struct iovec iov = {
71- .iov_base = &data,
72- .iov_len = sizeof(iov)
73- };
74+ assert(ac > 0);
75+ int fds[ac];
76+
77+ static const char sample[] =
78+ "\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
79+ const unsigned int data_size = sizeof(sample) - 1;
80+ void *data = tail_alloc(data_size);
81+ memcpy(data, sample, data_size);
82+
83+ struct iovec *iov = tail_alloc(sizeof(struct iovec));
84+ iov->iov_base = data;
85+ iov->iov_len = data_size;
86
87- while ((i = open("/dev/null", O_RDWR)) < 3)
88+ struct msghdr *mh = tail_alloc(sizeof(struct msghdr));
89+ memset(mh, 0, sizeof(*mh));
90+ mh->msg_iov = iov;
91+ mh->msg_iovlen = 1;
92+
93+ int i;
94+ while ((i = open("/dev/null", O_RDWR)) <= ac + 2)
95 assert(i >= 0);
96- (void) close(3);
97+ while (i > 2)
98+ assert(close(i--) == 0);
99+ assert(close(0) == 0);
100
101 int sv[2];
102 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv))
103@@ -55,60 +68,39 @@ int main(int ac, const char **av)
104 if (setsockopt(sv[0], SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)))
105 perror_msg_and_skip("setsockopt");
106
107- pid_t pid = fork();
108- if (pid < 0)
109- perror_msg_and_fail("fork");
110-
111- if (pid) {
112- assert(close(sv[0]) == 0);
113- assert(dup2(sv[1], 1) == 1);
114- assert(close(sv[1]) == 0);
115-
116- int fds[ac];
117- assert((fds[0] = open("/dev/null", O_RDWR)) == 3);
118- for (i = 1; i < ac; ++i)
119- assert((fds[i] = open(av[i], O_RDONLY)) == i + 3);
120-
121- union {
122- struct cmsghdr cmsg;
123- char buf[CMSG_LEN(sizeof(fds))];
124- } control;
125-
126- control.cmsg.cmsg_level = SOL_SOCKET;
127- control.cmsg.cmsg_type = SCM_RIGHTS;
128- control.cmsg.cmsg_len = CMSG_LEN(sizeof(fds));
129- memcpy(CMSG_DATA(&control.cmsg), fds, sizeof(fds));
130-
131- struct msghdr mh = {
132- .msg_iov = &iov,
133- .msg_iovlen = 1,
134- .msg_control = &control,
135- .msg_controllen = sizeof(control)
136- };
137-
138- assert(sendmsg(1, &mh, 0) == sizeof(iov));
139- assert(close(1) == 0);
140-
141- int status;
142- assert(waitpid(pid, &status, 0) == pid);
143- assert(status == 0);
144- } else {
145- assert(close(sv[1]) == 0);
146- assert(dup2(sv[0], 0) == 0);
147- assert(close(sv[0]) == 0);
148-
149- struct cmsghdr control[4 + ac * sizeof(int) / sizeof(struct cmsghdr)];
150-
151- struct msghdr mh = {
152- .msg_iov = &iov,
153- .msg_iovlen = 1,
154- .msg_control = control,
155- .msg_controllen = sizeof(control)
156- };
157-
158- assert(recvmsg(0, &mh, 0) == sizeof(iov));
159- assert(close(0) == 0);
160+ assert((fds[0] = open("/dev/null", O_RDWR)) == 4);
161+ for (i = 1; i < ac; ++i)
162+ assert((fds[i] = open(av[i], O_RDONLY)) == i + 4);
163+
164+ unsigned int cmsg_size = CMSG_SPACE(sizeof(fds));
165+ struct cmsghdr *cmsg = tail_alloc(cmsg_size);
166+ memset(cmsg, 0, cmsg_size);
167+ cmsg->cmsg_level = SOL_SOCKET;
168+ cmsg->cmsg_type = SCM_RIGHTS;
169+ cmsg->cmsg_len = CMSG_LEN(sizeof(fds));
170+ memcpy(CMSG_DATA(cmsg), fds, sizeof(fds));
171+
172+ mh->msg_control = cmsg;
173+ mh->msg_controllen = cmsg_size;
174+
175+ assert(sendmsg(sv[1], mh, 0) == (int) data_size);
176+
177+ assert(close(sv[1]) == 0);
178+ assert(open("/dev/null", O_RDWR) == sv[1]);
179+
180+ for (i = 0; i < ac; ++i) {
181+ assert(close(fds[i]) == 0);
182+ fds[i] = 0;
183 }
184
185+ cmsg_size += CMSG_SPACE(sizeof(struct ucred));
186+ cmsg = tail_alloc(cmsg_size);
187+ memset(cmsg, 0, cmsg_size);
188+ mh->msg_control = cmsg;
189+ mh->msg_controllen = cmsg_size;
190+
191+ assert(recvmsg(0, mh, 0) == (int) data_size);
192+ assert(close(0) == 0);
193+
194 return 0;
195 }
196--
1971.9.1
198
diff --git a/meta/recipes-devtools/strace/strace/0001-tests-introduce-libtests.patch b/meta/recipes-devtools/strace/strace/0001-tests-introduce-libtests.patch
new file mode 100644
index 0000000000..1575ecd229
--- /dev/null
+++ b/meta/recipes-devtools/strace/strace/0001-tests-introduce-libtests.patch
@@ -0,0 +1,306 @@
1From 87e6b230fff800eb768b68b2e5173ebbe83fd3ef Mon Sep 17 00:00:00 2001
2From: "Dmitry V. Levin" <ldv@altlinux.org>
3Date: Sat, 2 Jan 2016 12:05:14 +0000
4Subject: [PATCH] tests: introduce libtests
5
6Introduce tests/libtests.a with common functions for use in tests.
7
8* tests/tests.h: New file.
9* tests/error_msg.c: Likewise.
10* tests/tail_alloc.c: Likewise.
11* tests/get_page_size.c: Likewise.
12* tests/Makefile.am (libtests_a_SOURCES, libtests_a_CPPFLAGS,
13check_LIBRARIES, LDADD): New variables.
14(clock_xettime_LDADD, filter_unavailable_LDADD, mq_LDADD,
15pc_LDADD, times_LDADD): Add $(LDADD).
16* tests/.gitignore: Add libtests.a.
17---
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19Upstream-Status: Backport
20
21 tests/.gitignore | 1 +
22 tests/Makefile.am | 20 ++++++++++----
23 tests/error_msg.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++
24 tests/get_page_size.c | 13 +++++++++
25 tests/tail_alloc.c | 52 ++++++++++++++++++++++++++++++++++++
26 tests/tests.h | 62 ++++++++++++++++++++++++++++++++++++++++++
27 6 files changed, 217 insertions(+), 5 deletions(-)
28 create mode 100644 tests/error_msg.c
29 create mode 100644 tests/get_page_size.c
30 create mode 100644 tests/tail_alloc.c
31 create mode 100644 tests/tests.h
32
33diff --git a/tests/Makefile.am b/tests/Makefile.am
34index 386a2c2..62d0e56 100644
35--- a/tests/Makefile.am
36+++ b/tests/Makefile.am
37@@ -40,6 +40,16 @@ AM_CPPFLAGS = $(ARCH_MFLAGS) \
38 -I$(top_srcdir)
39 AM_LDFLAGS = $(ARCH_MFLAGS)
40
41+libtests_a_SOURCES = \
42+ get_page_size.c \
43+ error_msg.c \
44+ tail_alloc.c \
45+ tests.h \
46+ # end of libtests_a_SOURCES
47+libtests_a_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
48+check_LIBRARIES = libtests.a
49+LDADD = libtests.a
50+
51 check_PROGRAMS = \
52 _newselect \
53 adjtimex \
54@@ -146,19 +156,19 @@ check_PROGRAMS = \
55 xettimeofday \
56 # end of check_PROGRAMS
57
58-clock_xettime_LDADD = -lrt
59-filter_unavailable_LDADD = -lpthread
60+clock_xettime_LDADD = -lrt $(LDADD)
61+filter_unavailable_LDADD = -lpthread $(LDADD)
62 fstat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
63 fstatat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
64 ftruncate64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
65 lstat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
66 mmap64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
67-mq_LDADD = -lrt
68+mq_LDADD = -lrt $(LDADD)
69 newfstatat_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
70-pc_LDADD = $(dl_LIBS)
71+pc_LDADD = $(dl_LIBS) $(LDADD)
72 stat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
73 statfs_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
74-times_LDADD = -lrt
75+times_LDADD = -lrt $(LDADD)
76 truncate64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
77 uio_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
78 stack_fcall_SOURCES = stack-fcall.c \
79diff --git a/tests/error_msg.c b/tests/error_msg.c
80new file mode 100644
81index 0000000..3fd3411
82--- /dev/null
83+++ b/tests/error_msg.c
84@@ -0,0 +1,74 @@
85+/*
86+ * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
87+ * All rights reserved.
88+ *
89+ * Redistribution and use in source and binary forms, with or without
90+ * modification, are permitted provided that the following conditions
91+ * are met:
92+ * 1. Redistributions of source code must retain the above copyright
93+ * notice, this list of conditions and the following disclaimer.
94+ * 2. Redistributions in binary form must reproduce the above copyright
95+ * notice, this list of conditions and the following disclaimer in the
96+ * documentation and/or other materials provided with the distribution.
97+ * 3. The name of the author may not be used to endorse or promote products
98+ * derived from this software without specific prior written permission.
99+ *
100+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
101+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
102+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
103+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
104+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
105+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
106+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
107+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
108+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
109+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
110+ */
111+
112+#include "tests.h"
113+#include <errno.h>
114+#include <stdarg.h>
115+#include <stdio.h>
116+#include <stdlib.h>
117+#include <string.h>
118+
119+void
120+perror_msg_and_fail(const char *fmt, ...)
121+{
122+ int err_no = errno;
123+ va_list p;
124+
125+ va_start(p, fmt);
126+ vfprintf(stderr, fmt, p);
127+ if (err_no)
128+ fprintf(stderr, ": %s\n", strerror(err_no));
129+ else
130+ putc('\n', stderr);
131+ exit(1);
132+}
133+
134+void
135+error_msg_and_skip(const char *fmt, ...)
136+{
137+ va_list p;
138+
139+ va_start(p, fmt);
140+ vfprintf(stderr, fmt, p);
141+ putc('\n', stderr);
142+ exit(77);
143+}
144+
145+void
146+perror_msg_and_skip(const char *fmt, ...)
147+{
148+ int err_no = errno;
149+ va_list p;
150+
151+ va_start(p, fmt);
152+ vfprintf(stderr, fmt, p);
153+ if (err_no)
154+ fprintf(stderr, ": %s\n", strerror(err_no));
155+ else
156+ putc('\n', stderr);
157+ exit(77);
158+}
159diff --git a/tests/get_page_size.c b/tests/get_page_size.c
160new file mode 100644
161index 0000000..aeea861
162--- /dev/null
163+++ b/tests/get_page_size.c
164@@ -0,0 +1,13 @@
165+#include "tests.h"
166+#include <unistd.h>
167+
168+size_t
169+get_page_size(void)
170+{
171+ static size_t page_size;
172+
173+ if (!page_size)
174+ page_size = sysconf(_SC_PAGESIZE);
175+
176+ return page_size;
177+}
178diff --git a/tests/tail_alloc.c b/tests/tail_alloc.c
179new file mode 100644
180index 0000000..2b8b14e
181--- /dev/null
182+++ b/tests/tail_alloc.c
183@@ -0,0 +1,52 @@
184+/*
185+ * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
186+ * All rights reserved.
187+ *
188+ * Redistribution and use in source and binary forms, with or without
189+ * modification, are permitted provided that the following conditions
190+ * are met:
191+ * 1. Redistributions of source code must retain the above copyright
192+ * notice, this list of conditions and the following disclaimer.
193+ * 2. Redistributions in binary form must reproduce the above copyright
194+ * notice, this list of conditions and the following disclaimer in the
195+ * documentation and/or other materials provided with the distribution.
196+ * 3. The name of the author may not be used to endorse or promote products
197+ * derived from this software without specific prior written permission.
198+ *
199+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
200+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
201+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
202+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
203+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
204+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
205+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
206+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
207+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
208+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
209+ */
210+
211+#include "tests.h"
212+#include <string.h>
213+#include <sys/mman.h>
214+
215+void *
216+tail_alloc(const size_t size)
217+{
218+ const size_t page_size = get_page_size();
219+ const size_t len = (size + page_size - 1) & -page_size;
220+ const size_t alloc_size = len + 2 * page_size;
221+
222+ void *p = mmap(NULL, alloc_size, PROT_READ | PROT_WRITE,
223+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
224+ if (MAP_FAILED == p)
225+ perror_msg_and_fail("mmap(%zu)", alloc_size);
226+
227+ void *start_work = p + page_size;
228+ void *tail_guard = start_work + len;
229+
230+ if (munmap(p, page_size) || munmap(tail_guard, page_size))
231+ perror_msg_and_fail("munmap");
232+
233+ memset(start_work, 0xff, len);
234+ return tail_guard - size;
235+}
236diff --git a/tests/tests.h b/tests/tests.h
237new file mode 100644
238index 0000000..91fa24e
239--- /dev/null
240+++ b/tests/tests.h
241@@ -0,0 +1,62 @@
242+/*
243+ * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
244+ * All rights reserved.
245+ *
246+ * Redistribution and use in source and binary forms, with or without
247+ * modification, are permitted provided that the following conditions
248+ * are met:
249+ * 1. Redistributions of source code must retain the above copyright
250+ * notice, this list of conditions and the following disclaimer.
251+ * 2. Redistributions in binary form must reproduce the above copyright
252+ * notice, this list of conditions and the following disclaimer in the
253+ * documentation and/or other materials provided with the distribution.
254+ * 3. The name of the author may not be used to endorse or promote products
255+ * derived from this software without specific prior written permission.
256+ *
257+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
258+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
259+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
260+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
261+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
262+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
263+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
264+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
265+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
266+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
267+ */
268+
269+#ifndef TESTS_H_
270+# define TESTS_H_
271+
272+# ifdef HAVE_CONFIG_H
273+# include "config.h"
274+# endif
275+
276+# include <sys/types.h>
277+# include "gcc_compat.h"
278+
279+/* Cached sysconf(_SC_PAGESIZE). */
280+size_t get_page_size(void);
281+
282+/* Print message and strerror(errno) to stderr, then exit(1). */
283+void perror_msg_and_fail(const char *, ...)
284+ ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
285+/* Print message to stderr, then exit(77). */
286+void error_msg_and_skip(const char *, ...)
287+ ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
288+/* Print message and strerror(errno) to stderr, then exit(77). */
289+void perror_msg_and_skip(const char *, ...)
290+ ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
291+
292+/*
293+ * Allocate memory that ends on the page boundary.
294+ * Pages allocated by this call are preceeded by an unmapped page
295+ * and followed also by an unmapped page.
296+ */
297+void *tail_alloc(const size_t)
298+ ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE((1));
299+
300+# define SKIP_MAIN_UNDEFINED(arg) \
301+ int main(void) { error_msg_and_skip("undefined: %s", arg); }
302+
303+#endif
304--
3051.9.1
306
diff --git a/meta/recipes-devtools/strace/strace/0001-tests-scm_rights.c-use-libtests.patch b/meta/recipes-devtools/strace/strace/0001-tests-scm_rights.c-use-libtests.patch
new file mode 100644
index 0000000000..3fbab8b66f
--- /dev/null
+++ b/meta/recipes-devtools/strace/strace/0001-tests-scm_rights.c-use-libtests.patch
@@ -0,0 +1,54 @@
1From 339a15b619b479c63cafba21d5fc359e613d9ee8 Mon Sep 17 00:00:00 2001
2From: "Dmitry V. Levin" <ldv@altlinux.org>
3Date: Mon, 4 Jan 2016 23:53:31 +0000
4Subject: [PATCH] tests/scm_rights.c: use libtests
5
6* tests/scm_rights.c (main): Use perror_msg_and_fail and perror_msg_and_skip.
7---
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9Upstream-Status: Backport
10
11 tests/scm_rights.c | 12 ++++++++----
12 1 file changed, 8 insertions(+), 4 deletions(-)
13
14diff --git a/tests/scm_rights.c b/tests/scm_rights.c
15index c41444f..1e5e850 100644
16--- a/tests/scm_rights.c
17+++ b/tests/scm_rights.c
18@@ -1,5 +1,5 @@
19 /*
20- * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
21+ * Copyright (c) 2014-2016 Dmitry V. Levin <ldv@altlinux.org>
22 * All rights reserved.
23 *
24 * Redistribution and use in source and binary forms, with or without
25@@ -25,6 +25,7 @@
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29+#include "tests.h"
30 #include <assert.h>
31 #include <string.h>
32 #include <stdlib.h>
33@@ -48,12 +49,15 @@ int main(int ac, const char **av)
34 (void) close(3);
35
36 int sv[2];
37- assert(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
38+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv))
39+ perror_msg_and_skip("socketpair");
40 int one = 1;
41- assert(setsockopt(sv[0], SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) == 0);
42+ if (setsockopt(sv[0], SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)))
43+ perror_msg_and_skip("setsockopt");
44
45 pid_t pid = fork();
46- assert(pid >= 0);
47+ if (pid < 0)
48+ perror_msg_and_fail("fork");
49
50 if (pid) {
51 assert(close(sv[0]) == 0);
52--
531.9.1
54
diff --git a/meta/recipes-devtools/strace/strace_4.11.bb b/meta/recipes-devtools/strace/strace_4.11.bb
index 51ec5b5427..7391388020 100644
--- a/meta/recipes-devtools/strace/strace_4.11.bb
+++ b/meta/recipes-devtools/strace/strace_4.11.bb
@@ -11,6 +11,10 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/strace/strace-${PV}.tar.xz \
11 file://use-asm-sgidefs.h.patch \ 11 file://use-asm-sgidefs.h.patch \
12 file://0001-arc-metag-nios2-or1k-tile-fix-build.patch \ 12 file://0001-arc-metag-nios2-or1k-tile-fix-build.patch \
13 file://Makefile-ptest.patch \ 13 file://Makefile-ptest.patch \
14 file://0001-tests-scm_rights.c-use-libtests.patch \
15 file://0001-scm_rights-fd.test-rewrite-without-fork.patch \
16 file://0001-Move-gcc-compat-macros-to-gcc_compat.h.patch \
17 file://0001-tests-introduce-libtests.patch \
14 file://run-ptest \ 18 file://run-ptest \
15 " 19 "
16 20