Browse Source

tests: check -D option

* tests/strace-D.test: New test.
* tests/strace-D.expected: New file.
* tests/Makefile.am (MISC_TESTS): Add strace-D.test.
(EXTRA_DIST): Add strace-D.expected.
Dmitry V. Levin 1 month ago
parent
commit
739b39c611
3 changed files with 60 additions and 0 deletions
  1. 2
    0
      tests/Makefile.am
  2. 1
    0
      tests/strace-D.expected
  3. 57
    0
      tests/strace-D.test

+ 2
- 0
tests/Makefile.am View File

@@ -363,6 +363,7 @@ MISC_TESTS = \
363 363
 	status-none-threads.test \
364 364
 	status-unfinished-threads.test \
365 365
 	strace-C.test \
366
+	strace-D.test \
366 367
 	strace-E.test \
367 368
 	strace-S.test \
368 369
 	strace-T.test \
@@ -455,6 +456,7 @@ EXTRA_DIST = \
455 456
 	stack-fcall.h \
456 457
 	status-detached.expected \
457 458
 	strace-C.expected \
459
+	strace-D.expected \
458 460
 	strace-E.expected \
459 461
 	strace-T.expected \
460 462
 	strace-ff.expected \

+ 1
- 0
tests/strace-D.expected View File

@@ -0,0 +1 @@
1
++++ exited with 0 +++

+ 57
- 0
tests/strace-D.test View File

@@ -0,0 +1,57 @@
1
+#!/bin/sh
2
+#
3
+# Check -D option.
4
+#
5
+# Copyright (c) 2019 Dmitry V. Levin <ldv@altlinux.org>
6
+# All rights reserved.
7
+#
8
+# SPDX-License-Identifier: GPL-2.0-or-later
9
+
10
+. "${srcdir=.}/init.sh"
11
+
12
+check_prog sed
13
+
14
+get_parent_pid()
15
+{
16
+	sed '/^PPid:[[:space:]]*/!d;s///'
17
+}
18
+
19
+get_tracer_pid()
20
+{
21
+	sed '/^TracerPid:[[:space:]]*/!d;s///'
22
+}
23
+
24
+status_file=/proc/self/status
25
+[ -f "$status_file" ] ||
26
+	framework_skip_ "$status_file is not available"
27
+
28
+set -- sed -n -E '/^(P|Tracer)Pid:/p' "$status_file"
29
+"$@" > "$LOG" ||
30
+	framework_skip_ "$* does not work"
31
+
32
+# not traced: PPid > 0, TracerPid == 0
33
+[ "$(get_parent_pid < "$LOG")" -gt 0 ] &&
34
+[ "$(get_tracer_pid < "$LOG")" -eq 0 ] ||
35
+	dump_log_and_fail_with "$*: unexpected output"
36
+
37
+# !-D: PPid > 0, TracerPid > 0, PPid == TracerPid
38
+run_strace -a14 -q -enone "$@" > "$OUT"
39
+[ "$(get_parent_pid < "$OUT")" -gt 0 ] &&
40
+[ "$(get_tracer_pid < "$OUT")" -gt 0 ] &&
41
+[ "$(get_parent_pid < "$OUT")" = "$(get_tracer_pid < "$OUT")" ] || {
42
+	cat < "$OUT" > "$LOG"
43
+	dump_log_and_fail_with "$STRACE $args: unexpected output"
44
+}
45
+match_diff
46
+
47
+# -D: PPid > 0, TracerPid > 0, PPid != TracerPid
48
+run_strace -a14 -D -q -enone "$@" > "$OUT"
49
+[ "$(get_parent_pid < "$OUT")" -gt 0 ] &&
50
+[ "$(get_tracer_pid < "$OUT")" -gt 0 ] &&
51
+[ "$(get_parent_pid < "$OUT")" != "$(get_tracer_pid < "$OUT")" ] || {
52
+	cat < "$OUT" > "$LOG"
53
+	dump_log_and_fail_with "$STRACE $args: unexpected output"
54
+}
55
+match_diff
56
+
57
+exit 0

Loading…
Cancel
Save