[PATCH v3 3/3] This patch adds two test cases for the -z and -Z options.

burkhard.kohl at intel.com burkhard.kohl at intel.com
Thu Apr 25 14:23:19 UTC 2019


From: Burkhard Kohl <burkhard.kohl at intel.com>

Signed-off-by: Burkhard Kohl <burkhard.kohl at intel.com>
Co-Authored-by: Paul Chaignon <paul.chaignon at gmail.com>
---
 tests/.gitignore   |  2 ++
 tests/Makefile.am  |  2 ++
 tests/gen_tests.in |  2 ++
 tests/strace-Z.c   | 40 ++++++++++++++++++++++++++++++++++++++++
 tests/strace-z.c   | 40 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 86 insertions(+)
 create mode 100644 tests/strace-Z.c
 create mode 100644 tests/strace-z.c

diff --git a/tests/.gitignore b/tests/.gitignore
index 5a601641..25ad96b9 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -554,6 +554,8 @@ stat64
 statfs
 statfs64
 statx
+strace-z
+strace-Z
 swap
 sxetmask
 symlink
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9e99aff2..633a12e2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -157,6 +157,8 @@ check_PROGRAMS = $(PURE_EXECUTABLES) \
 	sleep \
 	stack-fcall \
 	stack-fcall-mangled \
+	strace-z \
+	strace-Z \
 	threads-execve \
 	unblock_reset_raise \
 	unix-pair-send-recv \
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index 314608eb..a8eb794e 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -461,6 +461,8 @@ stat64	-a32 -v -P stat.sample -P /dev/full
 statfs	-a17
 statfs64	-a23
 statx	-a32 -v -P stat.sample -P /dev/full
+strace-z    -a12 -e trace=chdir -P .. -z
+strace-Z    -a18 -e trace=chdir -P /dev/nil -Z
 swap	-a23 -e trace=swapon,swapoff
 sxetmask	-a11 -e trace=sgetmask,ssetmask
 symlink	-a34
diff --git a/tests/strace-Z.c b/tests/strace-Z.c
new file mode 100644
index 00000000..12d7fedc
--- /dev/null
+++ b/tests/strace-Z.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2019 Intel Corporation
+ * Copyright (c) 2019 Paul Chaignon <paul.chaignon at gmail.com>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "tests.h"
+#include <asm/unistd.h>
+
+#ifdef __NR_chdir
+
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+	static const char sample_valid[] = "..";
+	long rc = syscall(__NR_chdir, sample_valid);
+	if (rc == -1)
+		printf("chdir(\"%s\") = %s\n",
+			sample_valid, sprintrc(rc));
+
+	static const char sample_invalid[] = "/dev/nil";
+	rc = syscall(__NR_chdir, sample_invalid);
+	if (rc == -1)
+		printf("chdir(\"%s\") = %s\n",
+			sample_invalid, sprintrc(rc));
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_chdir")
+
+#endif
diff --git a/tests/strace-z.c b/tests/strace-z.c
new file mode 100644
index 00000000..b9478d9f
--- /dev/null
+++ b/tests/strace-z.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2019 Intel Corporation
+ * Copyright (c) 2019 Paul Chaignon <paul.chaignon at gmail.com>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "tests.h"
+#include <asm/unistd.h>
+
+#ifdef __NR_chdir
+
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+	static const char sample_valid[] = "..";
+	long rc = syscall(__NR_chdir, sample_valid);
+	if (rc != -1)
+		printf("chdir(\"%s\") = %s\n",
+			sample_valid, sprintrc(rc));
+
+	static const char sample_invalid[] = "/dev/nil";
+	rc = syscall(__NR_chdir, sample_invalid);
+	if (rc != -1)
+		printf("chdir(\"%s\") = %s\n",
+			sample_invalid, sprintrc(rc));
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_chdir")
+
+#endif
--
2.17.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928



More information about the Strace-devel mailing list