summaryrefslogtreecommitdiffstats
path: root/testsuite/lib/systemtap.exp
blob: 5c644d257f8e9bd5c93e7baaaed44cfdf1615ed0 (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
load_lib site.exp

proc installtest_p {} {
    global TOOL_OPTIONS
    if {[info exists TOOL_OPTIONS] && ($TOOL_OPTIONS == "install")} {
        return 1
    } else { return 0 }
}

proc print_systemtap_version {} {
    set version [exec /bin/uname -r]
    set location "/boot/vmlinux-$version"
    if {! [file exists $location]} {
	# try the debuginfo location
	set location "/usr/lib/debug/lib/modules/$version/vmlinux"
	if {! [file exists $location]} { set location "" }
    }

    print "kernel location: $location"
    print "kernel version: $version"

    set location [exec /usr/bin/which stap]
    regexp {version [^)]*} [exec stap -V 2>@ stdout] version

    print "systemtap location: $location"
    print "systemtap version: $version"
}


proc setup_systemtap_environment {} {
    global srcdir prefix env

    # need an absolute SRCDIR for the top-level src/ tree
    if {[string index $srcdir 0] != "/"} then {
        set env(SRCDIR) [exec pwd]/$srcdir/..
    } else {
        set env(SRCDIR) $srcdir/..
    }

    if [installtest_p] {
        set env(LD_LIBRARY_PATH) $prefix/lib/systemtap
        set env(SYSTEMTAP_TAPSET) $prefix/share/systemtap/tapset
        set env(SYSTEMTAP_RUNTIME) $prefix/share/systemtap/runtime
        set env(PATH) $prefix/bin:$env(PATH)
    } else {
        set env(LD_LIBRARY_PATH) ../lib-elfutils:../lib-elfutils/systemtap
        set env(SYSTEMTAP_TAPSET) $env(SRCDIR)/tapset
        set env(SYSTEMTAP_RUNTIME) $env(SRCDIR)/runtime
        set env(PATH) ..:$env(PATH)
    }

    # Use a local systemtap directory and cache
    set env(SYSTEMTAP_DIR) [exec pwd]/.systemtap
}


setup_systemtap_environment
print_systemtap_version

proc systemtap_init {args} {}
proc systemtap_version {} {}
proc systemtap_exit {} {}


proc stap_run_batch {args} {
    verbose -log "starting $args"
    spawn $args
    expect { 
        -re {[^\r]*\r} { verbose -log $expect_out(0,string); exp_continue } 
        eof { }
        timeout { exp_continue } 
    }
    set results [wait]
    verbose -log "wait results: $results"
    return [lindex $results 3]
}