summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.samples/args.exp
blob: 394ca9edbaef7a26562062bf2c65e8fb784a0b7d (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
set test "args"
if {![installtest_p]} { untested $test; return }

set stappath [exec which stap]
set staprunpath [exec which staprun]

if [file exists $staprunpath] {
    pass "$test search for staprun ($staprunpath)"
} else {
    fail "$test search for staprun"
    return
}

set modname "args_[pid]"
spawn stap -k -p4 -m $modname $srcdir/$subdir/args.stp
set tmpdir NO_SUCH_FILE
expect {
    -timeout 120
    -re {Keeping temporary directory "([/a-zA-Z0-9_]*)"} { pass "$test compile";
					set tmpdir $expect_out(1,string) }
    timeout { fail "$test compile (timeout)" }
    eof { }
}
catch {close}; wait
if [file exists $tmpdir] {
    pass "$test search for tmpdir ($tmpdir)"
} else {
    fail "$test search for tmpdir"
    return
}

set modpath "$tmpdir/$modname.ko"
if [file exists $modpath] {
    pass "$test search for probe module ($modpath)"
} else {
    fail "$test search for probe module"
    return
}

spawn sudo $staprunpath -d [pid] $modpath foo=hello bar=999
set ok 0
expect {
    -timeout 120
    -re {foo=hello bar=999} { incr ok }
    timeout { }
    eof { }
}
catch {close}; wait
if {$ok == 1} {
    pass "$test run 1"
} else {
    fail "$test run 1"
}

spawn sudo $staprunpath -d [pid] $modpath foo=goodbye bar=0
set ok 0
expect {
    -timeout 120
    -re {foo=goodbye bar=0} { incr ok }
    timeout { }
    eof { }
}
catch {close}; wait
if {$ok == 1} {
    pass "$test run 2"
} else {
    fail "$test run 2"
}



exec /bin/rm -rf $tmpdir