From d8b52c3ac997dff046e1536d692f55cd470f72d8 Mon Sep 17 00:00:00 2001
From: ChenJingPiao <chenjingp...@foxmail.com>
Date: Thu, 27 Oct 2016 12:25:33 +0800
Subject: [PATCH] tests: check decoding of gettid syscall.
* tests/gettid.c: New file.
* tests/gettid.test: Likewise.
* tests/.gitignore: Add gettid.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add gettid.test.
---
tests/.gitignore | 1 +
tests/Makefile.am | 3 +++
tests/gettid.c | 43 +++++++++++++++++++++++++++++++++++++++++++
tests/gettid.test | 7 +++++++
4 files changed, 54 insertions(+)
create mode 100644 tests/gettid.c
create mode 100755 tests/gettid.test
diff --git a/tests/.gitignore b/tests/.gitignore
index 5b33416..e81819c 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -97,6 +97,7 @@ getrlimit
getrusage
getsid
getsockname
+gettid
getuid
getuid32
getxxid
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0c24969..f7caa32 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -156,6 +156,7 @@ check_PROGRAMS = \
getrusage \
getsid \
getsockname \
+ gettid \
getuid \
getuid32 \
getxxid \
@@ -384,6 +385,7 @@ attach_f_p_LDADD = -lrt -lpthread $(LDADD)
clock_xettime_LDADD = -lrt $(LDADD)
count_f_LDADD = -lpthread $(LDADD)
filter_unavailable_LDADD = -lpthread $(LDADD)
+gettid_LDADD = -lpthread $(LDADD)
fstat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
fstatat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
ftruncate64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
@@ -501,6 +503,7 @@ DECODER_TESTS = \
getrusage.test \
getsid.test \
getsockname.test \
+ gettid.test \
getuid.test \
getuid32.test \
getxxid.test \
diff --git a/tests/gettid.c b/tests/gettid.c
new file mode 100644
index 0000000..ffcacb8
--- /dev/null
+++ b/tests/gettid.c
@@ -0,0 +1,43 @@
+#include "tests.h"
+#include <asm/unistd.h>
+
+#ifdef __NR_gettid
+
+#include <stdio.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <errno.h>
+
+void*
+thread(void *arg)
+{
+ long rc;
+
+ rc = syscall(__NR_gettid);
+ printf("%-5ld gettid() = %ld\n", rc, rc);
+ pthread_exit(0);
+}
+
+int
+main(void)
+{
+ pthread_t tid;
+ pthread_attr_t attr;
+
+ if (pthread_attr_init(&attr) != 0)
+ perror_msg_and_fail("pthread_attr_init");
+
+ if (pthread_create(&tid, &attr, thread, NULL) != 0)
+ perror_msg_and_fail("pthread_create");
+
+ if (pthread_join(tid, NULL) != 0)
+ perror_msg_and_fail("pthread_join");
+
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED(__NR_gettid)
+
+#endif
diff --git a/tests/gettid.test b/tests/gettid.test
new file mode 100755
index 0000000..49a8a9f
--- /dev/null
+++ b/tests/gettid.test
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# Check gettid syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_strace_match_diff -a15 -f -qq -e trace=gettid -e signal=none
--
2.7.4
------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel