File: target_set.exp

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (80 lines) | stat: -rw-r--r-- 2,004 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Test for target_set tapset

set test target_set

if {![installtest_p]} { untested $test; continue }

set file $srcdir/$subdir/target_set.stp
set time 12345
set stap_cmd  "( ( /bin/sleep $time ) ; ( /bin/sleep $time ) ; ( /bin/sleep $time ) )"
set stap_cmd_sleep_count 3
set stap_cmd_child_level 3

proc failtest {reason} {
	global test
	catch close; catch wait;
	fail "$test - $reason"
}

proc expect_target_set_string {} {
	expect {
		"^target set:\r\n" { }
		-re {^WARNING: Child process exited.+\r\n} { exp_continue }
		timeout { failtest "timeout (expect_target_set_string)"
			return -code return }
		eof { failtest "eof (expect_target_set_string)"
			return -code return }
	}
}

proc expect_target_set_pids generations {
	global test
	global stp_pid
	for {set i 0} {$i < $generations} {incr i} {
		expect {
			-re {^([0-9]+) begat ([0-9]+)\r\n} { set pid_array($expect_out(1,string)) $expect_out(2,string) }
			-re {^WARNING: Child process exited.+\r\n} { exp_continue }
			timeout { failtest "timeout (expect_target_set_pids)"
				return -code return }
			eof { failtest "eof (expect_target_set_pids)"
				return -code return }
		}
	}
	set pid_it $stp_pid
	while {[info exists pid_array($pid_it)]} {
		if {[exec pgrep -P $pid_it] != $pid_array($pid_it)} {
			failtest "(expect_target_set_pids)"
			return -code return
		}
		set pid_it $pid_array($pid_it)
	}
	if {$generations > 1} {
		kill -INT $pid_it
	}
}

spawn stap $file $time -c "$stap_cmd"

expect {
	-timeout 180
	-re "semantic error:" { failtest "semantic error (main1)"; return }
	-re {^(\d+)\r\n} { set stp_pid $expect_out(1,string) }
	timeout { failtest "timeout (main1)"; return }
	eof { failtest "eof (main1)"; return }
}

expect_target_set_pids 1
for {set i 0} {$i < $stap_cmd_sleep_count} {incr i} {
	expect_target_set_string
	expect_target_set_pids $stap_cmd_child_level
}
expect_target_set_string
expect_target_set_pids 0

expect {
	eof {}
	timeout { failtest "timeout (main2)"; return }
}

catch close; catch wait;
pass $test