File: server.exp

package info (click to toggle)
systemtap 1.7-1%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 18,448 kB
  • sloc: ansic: 43,401; cpp: 42,120; exp: 12,293; sh: 8,703; xml: 7,522; perl: 2,088; tcl: 954; python: 912; makefile: 625; ruby: 419; awk: 94; asm: 73; sed: 16
file content (103 lines) | stat: -rw-r--r-- 2,715 bytes parent folder | download
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
set test "Server Tests"
# Don't attempt these tests if the client/server are not available
if {! [setup_server]} then {
    untested "Server Tests"
    return
}

proc cleanup {} {
    global tmpdir
    catch {exec rm -f foo}
    catch {exec rm -fr $tmpdir}
    shutdown_server
}

# Whether the server can communicate with the client is tested in client.exp.
# Test that the the server can handle particular situations of interest.

#-------------------------------------------------------
# Building, returning and using the uprobes.ko module.
set subtest "uprobes"
if {! [uprobes_p]} then {
    untested "$test $subtest tests"
} else {
    # First compile a test application.
    catch {exec gcc -g -o foo $srcdir/systemtap.base/jennie.c} err
    if {$err == "" && [file exists foo]} {
	pass "$test $subtest compile foo"
    } else {
	fail "$test $subtest compile foo"
    }
    set foo [exec pwd]/foo

    # Make sure that uprobes.ko is not loaded
    catch {exec /sbin/rmmod uprobes}

    # Now use the server to compile the uprobes.stp script
    set failed 1
    set tmpdir ""
    set cmd [concat stap -p4 $srcdir/$subdir/uprobes.stp $use_server -k -c $foo]
    send_log "executing: $cmd\n"
    eval spawn $cmd
    expect {
	-timeout 150
	-re {.*Keeping temporary directory \"(.*)\"\r\n} {
	    set tmpdir "$expect_out(1,string)"
	    set failed 0
	}
	-re {^.*\r\n} { exp_continue }
	timeout { 
	    exec kill -INT -[exp_pid]
	    wait
	}
    }
    catch close
    if {$failed == 0} {
	pass "$test $subtest -p4"
    } else {
	fail "$test $subtest -p4"
    }

    # Make sure that the uprobes.ko module was returned.
    if {"$tmpdir" == ""} {
	untested "$test $subtest uprobes returned"
    } else {
	if {[file exists $tmpdir/server/stap000000/uprobes/uprobes.ko]} {
	    pass "$test $subtest uprobes returned"
	} else {
	    fail "$test $subtest uprobes returned"
	}
    }

    if {! [installtest_p]} {
	untested "$test $subtest -p5";
	cleanup
	return
    }

    # Now do it again, but follow through to phase 5
    # Make sure that uprobes.ko is not loaded
    catch {exec /sbin/rmmod uprobes}

    # Now use the server to compile and run the uprobes.stp script
    set failed 1
    set cmd {stap $srcdir/$subdir/uprobes.stp $use_server -c "$foo 1 2 3 4"}
    send_log "executing: $cmd\n"
    eval spawn $cmd
    set ok 0
    expect {
	-re {^process[^\r\n]+foo[^\r\n]+main[^\r\n]+arg[cv]=0x[0-9a-f]+\ +arg[cv]=0x[0-9a-f]+\r\n} { incr ok; exp_continue }
	-re {^process[^\r\n]+foo[^\r\n]+main[^\r\n]+return=0x0\r\n} { incr ok; exp_continue }
	-timeout 30
	timeout { }
	eof { }
    }
    catch close
    if {$ok == 10} {
	pass "$test $subtest -p5"
    } else {
	fail "$test $subtest -p5 ($ok)"
    }
}

cleanup