<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hello,<br>
<br>
Thanks for your advice, I've modified the patch to v5.<br>
<br>
<div class="moz-cite-prefix">On 06/15/2016 05:10 PM, Dmitry V. Levin
wrote:<br>
</div>
<blockquote cite="mid:20160615091055.GA25571@altlinux.org"
type="cite">
<pre wrap="">On Wed, Jun 15, 2016 at 01:20:27PM +0800, Fei Jie wrote:
</pre>
<blockquote type="cite">
<pre wrap="">* tests/signal_receive.c: New file.
* tests/signal_receive.test: New test.
* tests/.gitignore: Add signal_receive.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add signal_receive.test.
---
tests/.gitignore | 1 +
tests/Makefile.am | 2 ++
tests/signal_receive.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
tests/signal_receive.test | 8 ++++++++
4 files changed, 62 insertions(+)
create mode 100644 tests/signal_receive.c
create mode 100755 tests/signal_receive.test
diff --git a/tests/.gitignore b/tests/.gitignore
index 67d0d66..72e93d8 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -231,6 +231,7 @@ shmxt
sigaction
sigaltstack
siginfo
+signal_receive
signalfd
sigreturn
sleep
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a136e2a..94d3d23 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -285,6 +285,7 @@ check_PROGRAMS = \
sigaction \
sigaltstack \
siginfo \
+ signal_receive \
signalfd \
sigreturn \
sleep \
@@ -662,6 +663,7 @@ MISC_TESTS = \
qual_syscall.test \
redirect.test \
restart_syscall.test \
+ signal_receive.test \
strace-E.test \
strace-S.test \
strace-T.test \
diff --git a/tests/signal_receive.c b/tests/signal_receive.c
new file mode 100644
index 0000000..c3027a4
--- /dev/null
+++ b/tests/signal_receive.c
@@ -0,0 +1,51 @@
+#include "tests.h"
+#include <assert.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+void sig_print(const char *signame)
+{
+ printf("kill\\(%d, %s\\) = 0\n"
+ "--- %s {si_signo=%s, si_code=SI_USER, si_pid=%d,"
+ " si_uid=%d} ---\n",
+ getpid(), signame, signame, signame, getpid(), getuid());
</pre>
</blockquote>
<pre wrap="">
Invoking getpid() and getuid() so many times looks odd.
Let's invoke them once and pass the result to this function.
</pre>
<blockquote type="cite">
<pre wrap="">+}
+
+static void
+handler(int sig)
+{
+}
+
+int
+main(void)
+{
+ int sig;
+ const struct sigaction act = { .sa_handler = handler };
+ for (sig = 1; sig <= 31; sig++)
+ {
+ if( sig != SIGKILL && sig != SIGSTOP)
+ {
+ sigaction(sig, &act, NULL);
+ }
+ }
</pre>
</blockquote>
<pre wrap="">
Opening braces in this function are not in the right place.
The tradition is to put them on the same line with the statement.
</pre>
<blockquote type="cite">
<pre wrap="">+ sigset_t mask;
+ sigemptyset(&mask);
+ for (sig = 1; sig <= 31; sig++)
+ {
+ sigaddset(&mask, sig);
+ }
</pre>
</blockquote>
<pre wrap="">
This loop could be merged with the previous one.
</pre>
<blockquote type="cite">
<pre wrap="">+ sigprocmask(SIG_UNBLOCK, &mask, NULL);
+
+ for (sig = 1; sig <= 31; sig++)
+ {
+ if(sig != SIGKILL && sig != SIGSTOP)
+ {
+ assert(kill(getpid(), sig) == 0);
</pre>
</blockquote>
<pre wrap="">
I'd be very much surprised if this kill failed, but if it did,
I'd like to see the reason. Let's use perror_msg_and_fail
in cases like this.
</pre>
<blockquote type="cite">
<pre wrap="">+ sig_print(signal2name(sig));
+ }
+ }
+
+ return 0;
+}
diff --git a/tests/signal_receive.test b/tests/signal_receive.test
new file mode 100755
index 0000000..2e3e98d
--- /dev/null
+++ b/tests/signal_receive.test
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. "${srcdir=.}/init.sh"
</pre>
</blockquote>
<pre wrap="">
A comment explaining what the test does would be a good addition.
</pre>
<blockquote type="cite">
<pre wrap="">+run_prog > /dev/null
+run_strace -a16 -esignal $args > "$EXP"
+match_grep "$LOG" "$EXP"
+rm -f "$EXP"
</pre>
</blockquote>
<pre wrap="">
Is there any particular reason to use less precise match_grep
rather than run_strace_match_diff?
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. <a class="moz-txt-link-freetext" href="http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381">http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381</a></pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Strace-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Strace-devel@lists.sourceforge.net">Strace-devel@lists.sourceforge.net</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/strace-devel">https://lists.sourceforge.net/lists/listinfo/strace-devel</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Thanks!
Fei Jie</pre>
</body>
</html>