<div><div>From 8995d87f0c27d40d574f032bf483f6ae2b5f7375 Mon Sep 17 00:00:00 2001</div><div>From: JingPiao Chen <chenjingpiao@foxmail.com></div><div>Date: Thu, 17 Nov 2016 21:15:51 +0800</div><div>Subject: [PATCH] tests: add prctl-name.test, prctl-pdeathsig.test and</div><div> prctl-tsc.test</div><div><br></div><div>* tests/prctl-name.c:New file.</div><div>* tests/prctl-name.test: Likewise.</div><div>* tests/prctl-pdeathsig.c:Likewise.</div><div>* tests/prctl-pdeathsig.test: Likewise.</div><div>* tests/prctl-tsc.c: Likewise.</div><div>* tests/prctl-tsc.test: Likewise</div><div>* tests/.gitignore: Add prctl-name, prctl-pdeathsig and prctl-tsc.</div><div>* tests/Makefile.am (check_PROGRAMS): Likewise.</div><div>(DECODER_TESTS): Add prctl-name.test, prctl-pdeathsig.test and prctl-tsc.test</div><div>---</div><div> tests/.gitignore           |  3 +++</div><div> tests/Makefile.am          |  6 +++++</div><div> tests/prctl-name.c         | 63 ++++++++++++++++++++++++++++++++++++++++++++++</div><div> tests/prctl-name.test      |  6 +++++</div><div> tests/prctl-pdeathsig.c    | 61 ++++++++++++++++++++++++++++++++++++++++++++</div><div> tests/prctl-pdeathsig.test |  6 +++++</div><div> tests/prctl-tsc.c          | 60 +++++++++++++++++++++++++++++++++++++++++++</div><div> tests/prctl-tsc.test       |  6 +++++</div><div> 8 files changed, 211 insertions(+)</div><div> create mode 100644 tests/prctl-name.c</div><div> create mode 100755 tests/prctl-name.test</div><div> create mode 100644 tests/prctl-pdeathsig.c</div><div> create mode 100755 tests/prctl-pdeathsig.test</div><div> create mode 100644 tests/prctl-tsc.c</div><div> create mode 100755 tests/prctl-tsc.test</div><div><br></div><div>diff --git a/tests/.gitignore b/tests/.gitignore</div><div>index 6fc3cd1..8497dfa 100644</div><div>--- a/tests/.gitignore</div><div>+++ b/tests/.gitignore</div><div>@@ -207,8 +207,11 @@ pkey_free</div><div> pkey_mprotect</div><div> poll</div><div> ppoll</div><div>+prctl-name</div><div>+prctl-pdeathsig</div><div> prctl-seccomp-filter-v</div><div> prctl-seccomp-strict</div><div>+prctl-tsc</div><div> pread64-pwrite64</div><div> preadv</div><div> preadv-pwritev</div><div>diff --git a/tests/Makefile.am b/tests/Makefile.am</div><div>index df5ddb2..744ed25 100644</div><div>--- a/tests/Makefile.am</div><div>+++ b/tests/Makefile.am</div><div>@@ -265,8 +265,11 @@ check_PROGRAMS = \</div><div> <span class="Apple-tab-span" style="white-space:pre">  </span>pkey_mprotect \</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>poll \</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>ppoll \</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>prctl-name \</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>prctl-pdeathsig \</div><div> <span class="Apple-tab-span" style="white-space:pre">      </span>prctl-seccomp-filter-v \</div><div> <span class="Apple-tab-span" style="white-space:pre">       </span>prctl-seccomp-strict \</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>prctl-tsc \</div><div> <span class="Apple-tab-span" style="white-space:pre">    </span>pread64-pwrite64 \</div><div> <span class="Apple-tab-span" style="white-space:pre">     </span>preadv \</div><div> <span class="Apple-tab-span" style="white-space:pre">       </span>preadv-pwritev \</div><div>@@ -637,8 +640,11 @@ DECODER_TESTS = \</div><div> <span class="Apple-tab-span" style="white-space:pre">  </span>pkey_mprotect.test \</div><div> <span class="Apple-tab-span" style="white-space:pre">   </span>poll.test \</div><div> <span class="Apple-tab-span" style="white-space:pre">    </span>ppoll.test \</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>prctl-name.test \</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>prctl-pdeathsig.test \</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>prctl-seccomp-filter-v.test \</div><div> <span class="Apple-tab-span" style="white-space:pre">  </span>prctl-seccomp-strict.test \</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>prctl-tsc.test \</div><div> <span class="Apple-tab-span" style="white-space:pre">       </span>pread64-pwrite64.test \</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>preadv-pwritev.test \</div><div> <span class="Apple-tab-span" style="white-space:pre">  </span>preadv2-pwritev2.test \</div><div>diff --git a/tests/prctl-name.c b/tests/prctl-name.c</div><div>new file mode 100644</div><div>index 0000000..a508969</div><div>--- /dev/null</div><div>+++ b/tests/prctl-name.c</div><div>@@ -0,0 +1,63 @@</div><div>+/*</div><div>+ * Copyright (c) 2016 JingPiao Chen <chenjingpiao@foxmail.com></div><div>+ * All rights reserved.</div><div>+ *</div><div>+ * Redistribution and use in source and binary forms, with or without</div><div>+ * modification, are permitted provided that the following conditions</div><div>+ * are met:</div><div>+ * 1. Redistributions of source code must retain the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer.</div><div>+ * 2. Redistributions in binary form must reproduce the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer in the</div><div>+ *    documentation and/or other materials provided with the distribution.</div><div>+ * 3. The name of the author may not be used to endorse or promote products</div><div>+ *    derived from this software without specific prior written permission.</div><div>+ *</div><div>+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR</div><div>+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</div><div>+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.</div><div>+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,</div><div>+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT</div><div>+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</div><div>+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</div><div>+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</div><div>+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF</div><div>+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</div><div>+ */</div><div>+</div><div>+#include "tests.h"</div><div>+#include <asm/unistd.h></div><div>+</div><div>+#ifdef HAVE_PRCTL</div><div>+# include <sys/prctl.h></div><div>+#endif</div><div>+</div><div>+#if defined HAVE_PRCTL && defined PR_GET_NAME && defined PR_SET_NAME</div><div>+</div><div>+#include <stdio.h></div><div>+#include <unistd.h></div><div>+</div><div>+int</div><div>+main(void)</div><div>+{</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>char setname[16] = "test-set-name";</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>char getname[16];</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>long rc;</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>rc = syscall(__NR_prctl, PR_SET_NAME, setname);</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>printf("prctl(PR_SET_NAME, \"%s\\0\\0\\0\") = %s\n",</div><div>+<span class="Apple-tab-span" style="white-space:pre">                    </span>setname, sprintrc(rc));</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>rc = syscall(__NR_prctl, PR_GET_NAME, getname);</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>printf("prctl(PR_GET_NAME, \"%s\")       = %s\n",</div><div>+<span class="Apple-tab-span" style="white-space:pre">                        </span>getname, sprintrc(rc));</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>puts("+++ exited with 0 +++");</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>return 0;</div><div>+}</div><div>+</div><div>+#else</div><div>+</div><div>+SKIP_MAIN_UNDEFINED("HAVE_PRCTL && PR_GET_NAME && PR_SET_NAME")</div><div>+</div><div>+#endif</div><div>diff --git a/tests/prctl-name.test b/tests/prctl-name.test</div><div>new file mode 100755</div><div>index 0000000..fae18b3</div><div>--- /dev/null</div><div>+++ b/tests/prctl-name.test</div><div>@@ -0,0 +1,6 @@</div><div>+#!/bin/sh</div><div>+</div><div>+# Check prctl PR_GET_NAME PR_SET_NAME decoding.</div><div>+</div><div>+. "${srcdir=.}/init.sh"</div><div>+run_strace_match_diff -a42 -e trace=prctl</div><div>diff --git a/tests/prctl-pdeathsig.c b/tests/prctl-pdeathsig.c</div><div>new file mode 100644</div><div>index 0000000..db2e7b3</div><div>--- /dev/null</div><div>+++ b/tests/prctl-pdeathsig.c</div><div>@@ -0,0 +1,61 @@</div><div>+/*</div><div>+ * Copyright (c) 2016 JingPiao Chen <chenjingpiao@foxmail.com></div><div>+ * All rights reserved.</div><div>+ *</div><div>+ * Redistribution and use in source and binary forms, with or without</div><div>+ * modification, are permitted provided that the following conditions</div><div>+ * are met:</div><div>+ * 1. Redistributions of source code must retain the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer.</div><div>+ * 2. Redistributions in binary form must reproduce the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer in the</div><div>+ *    documentation and/or other materials provided with the distribution.</div><div>+ * 3. The name of the author may not be used to endorse or promote products</div><div>+ *    derived from this software without specific prior written permission.</div><div>+ *</div><div>+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR</div><div>+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</div><div>+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.</div><div>+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,</div><div>+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT</div><div>+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</div><div>+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</div><div>+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</div><div>+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF</div><div>+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</div><div>+ */</div><div>+</div><div>+#include "tests.h"</div><div>+#include <asm/unistd.h></div><div>+</div><div>+#ifdef HAVE_PRCTL</div><div>+# include <sys/prctl.h></div><div>+#endif</div><div>+</div><div>+#if defined HAVE_PRCTL && defined PR_GET_PDEATHSIG && defined PR_SET_PDEATHSIG</div><div>+</div><div>+#include <stdio.h></div><div>+#include <unistd.h></div><div>+#include <sys/signal.h></div><div>+</div><div>+int</div><div>+main(void)</div><div>+{</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>int pdeathsig;</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>long rc;</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>rc = syscall(__NR_prctl, PR_SET_PDEATHSIG, SIGINT);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>printf("prctl(PR_SET_PDEATHSIG, SIGINT)   = %s\n", sprintrc(rc));</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>rc = syscall(__NR_prctl, PR_GET_PDEATHSIG, &pdeathsig);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>printf("prctl(PR_GET_PDEATHSIG, [SIGINT]) = %s\n", sprintrc(rc));</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>puts("+++ exited with 0 +++");</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>return 0;</div><div>+}</div><div>+</div><div>+#else</div><div>+</div><div>+SKIP_MAIN_UNDEFINED("HAVE_PRCTL && PR_GET_PDEATHSIG && PR_SET_PDEATHSIG")</div><div>+</div><div>+#endif</div><div>diff --git a/tests/prctl-pdeathsig.test b/tests/prctl-pdeathsig.test</div><div>new file mode 100755</div><div>index 0000000..5e0be13</div><div>--- /dev/null</div><div>+++ b/tests/prctl-pdeathsig.test</div><div>@@ -0,0 +1,6 @@</div><div>+#!/bin/sh</div><div>+</div><div>+# Check prctl PR_GET_PDEATHSIG PR_SET_PDEATHSIG decoding.</div><div>+</div><div>+. "${srcdir=.}/init.sh"</div><div>+run_strace_match_diff -a34 -e trace=prctl</div><div>diff --git a/tests/prctl-tsc.c b/tests/prctl-tsc.c</div><div>new file mode 100644</div><div>index 0000000..ea8bf61</div><div>--- /dev/null</div><div>+++ b/tests/prctl-tsc.c</div><div>@@ -0,0 +1,60 @@</div><div>+/*</div><div>+ * Copyright (c) 2016 JingPiao Chen <chenjingpiao@foxmail.com></div><div>+ * All rights reserved.</div><div>+ *</div><div>+ * Redistribution and use in source and binary forms, with or without</div><div>+ * modification, are permitted provided that the following conditions</div><div>+ * are met:</div><div>+ * 1. Redistributions of source code must retain the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer.</div><div>+ * 2. Redistributions in binary form must reproduce the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer in the</div><div>+ *    documentation and/or other materials provided with the distribution.</div><div>+ * 3. The name of the author may not be used to endorse or promote products</div><div>+ *    derived from this software without specific prior written permission.</div><div>+ *</div><div>+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR</div><div>+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</div><div>+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.</div><div>+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,</div><div>+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT</div><div>+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</div><div>+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</div><div>+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</div><div>+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF</div><div>+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</div><div>+ */</div><div>+</div><div>+#include "tests.h"</div><div>+#include <asm/unistd.h></div><div>+</div><div>+#ifdef HAVE_PRCTL</div><div>+# include <sys/prctl.h></div><div>+#endif</div><div>+</div><div>+#if defined HAVE_PRCTL && defined PR_GET_TSC && defined PR_SET_TSC</div><div>+</div><div>+#include <stdio.h></div><div>+#include <unistd.h></div><div>+</div><div>+int</div><div>+main(void)</div><div>+{</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>int tsc;</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>long rc;</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>rc = syscall(__NR_prctl, PR_SET_TSC, PR_TSC_SIGSEGV);</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>printf("prctl(PR_SET_TSC, PR_TSC_SIGSEGV)   = %s\n", sprintrc(rc));</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>rc = syscall(__NR_prctl, PR_GET_TSC, &tsc);</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>printf("prctl(PR_GET_TSC, [PR_TSC_SIGSEGV]) = %s\n", sprintrc(rc));</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>puts("+++ exited with 0 +++");</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>return 0;</div><div>+}</div><div>+</div><div>+#else</div><div>+</div><div>+SKIP_MAIN_UNDEFINED("HAVE_PRCTL && PR_GET_TSC && PR_SET_TSC")</div><div>+</div><div>+#endif</div><div>diff --git a/tests/prctl-tsc.test b/tests/prctl-tsc.test</div><div>new file mode 100755</div><div>index 0000000..c6fe65f</div><div>--- /dev/null</div><div>+++ b/tests/prctl-tsc.test</div><div>@@ -0,0 +1,6 @@</div><div>+#!/bin/sh</div><div>+</div><div>+# Check prctl PR_GET_TSC PR_SET_TSC decoding.</div><div>+</div><div>+. "${srcdir=.}/init.sh"</div><div>+run_strace_match_diff -a36 -e trace=prctl</div><div>-- </div><div>2.7.4</div></div><div><br></div>