blob: 20827edfc3b623a60211f2dec009962da57d0d9c (
plain)
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
81
82
83
84
85
86
|
if {![installtest_p]} {untested "MAXMEMORY"; return}
set script {
global k
probe begin {
print("systemtap starting probe\n")
k["foo"] = 0
}
probe kernel.function("vfs_read"), kernel.function("vfs_write") {
k["foo"]++
}
probe end {
print("systemtap ending probe\n")
}
}
# stap_run_maxmemory TEST_NAME EXPECT_ERROR
# TEST_NAME is the name of the current test
# EXPECT_ERROR lets us know to expect an error or not
#
# Additional arguments are passed to stap as-is.
proc stap_run_maxmemory { TEST_NAME EXPECT_ERROR args } {
set cmd [concat {stap -v} $args]
eval spawn $cmd
expect {
-timeout 150
-re {^Pass\ [1234]: [^\r]+real\ ms\.\r\n} {exp_continue}
-re {^Pass\ ([34]): using cached [^\r]+\r\n} {exp_continue}
-re {^Pass 5: starting run.\r\n} {exp_continue}
-re {^Error inserting module[^\r]+\r\n} {
if {$EXPECT_ERROR} {
pass "$TEST_NAME received expected insert module error"
} else {
fail "$TEST_NAME unexpected insert module error"
}
}
-re {ERROR: [^\r]+ allocation failed\r\n} {
if {$EXPECT_ERROR} {
pass "$TEST_NAME received expected allocation error"
} else {
fail "$TEST_NAME unexpected allocation error"
}
}
-re "^systemtap starting probe\r\n" {
exec kill -INT -[exp_pid]
expect {
-timeout 10
-re {^systemtap ending probe\r\n} {
if {$EXPECT_ERROR} {
fail "$TEST_NAME didn't receive expected allocation error"
} else {
pass "$TEST_NAME didn't receive allocation error"
}
}
-re {ERROR: .+ allocation failed\r\n} {
if {$EXPECT_ERROR} {
pass "$TEST_NAME received expected allocation error"
} else {
fail "$TEST_NAME received an unexpected allocation error"
}
}
}
}
-re "semantic error:" { fail "$TEST_NAME compilation" }
timeout { fail "$TEST_NAME startup (timeout)";
exec kill -INT -[exp_pid] }
eof { fail "$TEST_NAME startup (eof)" }
}
catch close
wait
}
# MAXMEMORY1 tests to make sure normal operation doesn't receive a
# max memory error
set test "MAXMEMORY1"
stap_run_maxmemory $test 0 -u -e $script
# MAXMEMORY2 is the same script, but we're adjusting STP_MAXMEMORY to
# a low value so that we *will* get an allocation error or an insert
# module error.
set test "MAXMEMORY2"
stap_run_maxmemory $test 1 -u -DSTP_MAXMEMORY=200 -e $script
|