summaryrefslogtreecommitdiff
path: root/tests/dup.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dup.c')
-rw-r--r--tests/dup.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/tests/dup.c b/tests/dup.c
index df0251f9d..c9c0f50aa 100644
--- a/tests/dup.c
+++ b/tests/dup.c
@@ -23,6 +23,22 @@
# define SKIP_IF_PROC_IS_UNAVAILABLE
#endif
+#ifndef TRACE_FDS
+# define TRACE_FDS 0
+#endif
+#ifndef PATH_TRACING
+# define PATH_TRACING 0
+#endif
+#ifndef TRACE_FD_0
+# define TRACE_FD_0 (!TRACE_FDS && !PATH_TRACING)
+#endif
+#ifndef TRACE_OTHER_FDS
+# define TRACE_OTHER_FDS (!TRACE_FDS && !PATH_TRACING)
+#endif
+#ifndef TRACE_FD_9
+# define TRACE_FD_9 (!TRACE_FDS && !PATH_TRACING)
+#endif
+
static const char *errstr;
static long
@@ -42,22 +58,29 @@ main(void)
SKIP_IF_PROC_IS_UNAVAILABLE;
k_dup(-1);
-#ifndef PATH_TRACING
+#if !PATH_TRACING && !TRACE_FDS
printf("dup(-1) = %s\n", errstr);
#endif
int d1 = k_dup(0);
-#ifndef PATH_TRACING
+#if TRACE_FD_0
printf("dup(0" FD0_PATH ") = %d" FD0_PATH "\n", d1);
#endif
int d2 = k_dup(d1);
-#ifndef PATH_TRACING
+#if TRACE_OTHER_FDS
printf("dup(%d" FD0_PATH ") = %d" FD0_PATH "\n", d1, d2);
#endif
d2 = k_dup(9);
+#if PATH_TRACING || TRACE_FD_9
printf("dup(9" FD9_PATH ") = %d" FD9_PATH "\n", d2);
+#endif
+
+ d1 = k_dup(d2);
+#if PATH_TRACING || TRACE_OTHER_FDS
+ printf("dup(%d" FD9_PATH ") = %d" FD9_PATH "\n", d2, d1);
+#endif
puts("+++ exited with 0 +++");
return 0;