File: sdt.exp

package info (click to toggle)
systemtap 3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,860 kB
  • ctags: 12,513
  • sloc: cpp: 58,610; ansic: 58,189; exp: 37,322; sh: 10,633; xml: 7,771; perl: 2,252; python: 2,066; tcl: 1,305; makefile: 969; lisp: 105; java: 100; awk: 94; asm: 91; sed: 16
file content (138 lines) | stat: -rw-r--r-- 4,271 bytes parent folder | download | duplicates (8)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
set test "sdt"
set result_string10 {_
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10}
set result_string12 {
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10 11 12}

set extra_flags {{additional_flags=-O2}
    {additional_flags=-O3}
    {additional_flags=-std=c89}
    {additional_flags=-std=c99}
    {additional_flags=-std=gnu99}
    {c++ additional_flags=-std=c++98 additional_flags=-x additional_flags=c++}
    {c++ additional_flags=-std=gnu++98 additional_flags=-x additional_flags=c++}
    {c++ additional_flags=-std=c++0x additional_flags=-x additional_flags=c++}
    {c++ additional_flags=-std=gnu++0x additional_flags=-x additional_flags=c++}
}
set extra_mssgs {-O2 -O3 c89 c99 gnu99 c++98 gnu++98 c++0x gnu++0x}
set type_pedantics_idx {1 1 2 2 2 2 2 2 2} 
set type_pedantics {{} additional_flags=-pedantic} ; # don't compile -O2 -O3 with -pedantic
set type_pedantic_mssgs {{} -pedantic}

set pbtype_flags {{""} {additional_flags=-DSTAP_SDT_V2}}
set pbtype_mssgs {{uprobe} {V2_uprobe}}

proc sdt_stap_run { TEST_NAME TEST_FILE FAIL args } {
    foreach runtime [get_runtime_list] {
	set full_test_name $TEST_NAME
	if {$runtime != ""} {
	    lappend full_test_name "($runtime)"
	    set cmd [concat stap --runtime=$runtime $TEST_FILE $args]
	} elseif {[uprobes_p]} {
	    set cmd [concat stap $TEST_FILE $args]
	} else {
	    untested $full_test_name
	    continue
	}
	send_log "executing: $cmd\n"
	catch {eval exec $cmd} res

	set skip 0
	set n 0
	set expected [split $::result_string "\n"]
	foreach line [split $res "\n"] {
	    if {![string equal $line [lindex $expected $n]]} {
		$FAIL "$full_test_name"
		send_log "line [expr $n + 1]: expected \"[lindex $expected $n]\"\n"
		send_log "Got \"$line\"\n"
		set skip 1
		break
	    }
	    incr n
	}
	if {$skip != 0} {
	    continue
	}
	if {[expr $n == [llength $expected]]} {
	    pass "$full_test_name"
	} else {
	    $FAIL "$full_test_name"
	    send_log "too few lines of output, got $n, expected [llength $expected]\n"
	}
    }
}

# Iterate pbtype_flags
for {set p 0} {$p < [llength $pbtype_flags]} {incr p} {
set pbtype_flag [lindex $pbtype_flags $p]
set pbtype_mssg [lindex $pbtype_mssgs $p]

# Iterate extra_flags, trying each with C and C++
for {set i 0} {$i < [llength $extra_flags]} {incr i} {
set extra_flag [lindex $extra_flags $i]
set extra_mssg [lindex $extra_mssgs $i]
set testprog "sdt.c.exe.$i"

for {set j 0} {$j < [lindex $type_pedantics_idx $i]} {incr j} {
set type_pedantic_mssg [lindex $type_pedantic_mssgs $j]

set test_flags "additional_flags=-g"
set test_flags "$test_flags [sdt_includes]"
set test_flags "$test_flags additional_flags=-Wall"
set test_flags "$test_flags additional_flags=-Wextra"
set test_flags "$test_flags additional_flags=-Werror $pbtype_flag"

set saveidx 0

set res [target_compile $srcdir/$subdir/$test.c $testprog executable "$test_flags $extra_flag [lindex $type_pedantics $j]"]
if { $res != "" } {
    verbose "target_compile failed: $res" 2
    # -std=gnu++0x and -std=c++0x are not universally accepted
    if {[string first "unrecognized command line option" $res] == -1} {
      fail "compiling $test.c $extra_mssg $type_pedantic_mssg $pbtype_mssg"
    } else {
      untested "compiling $test.c $extra_mssg $type_pedantic_mssg $pbtype_mssg"
    }
    untested "$test $extra_mssg $type_pedantic_mssg $pbtype_mssg"
    continue
} else {
    pass "compiling $test.c $extra_mssg $type_pedantic_mssg $pbtype_mssg"
}

if {[installtest_p]} {
    if {[regexp "^(ppc64|s390x)$" $::tcl_platform(machine)] \
	    && [regexp "^(-O)" $extra_mssg]} {
	# register name and constant is ambiguous in ppc/s390 asm syntax
	# thus constant folding can throw the result off
	set FAIL xfail
    } else {
	set FAIL fail
    }
    set ::result_string $result_string10
    if { $pbtype_mssg == "uprobe" } {
	append ::result_string $result_string12
    }
    sdt_stap_run "$test $extra_mssg $type_pedantic_mssg $pbtype_mssg" \
	-w $FAIL $srcdir/$subdir/$test.stp $testprog -c ./$testprog
} else {
    untested "$test $extra_mssg $type_pedantic_mssg $pbtype_mssg"
}
catch {exec rm -f $testprog}


} ; # type_pedantics_idx

} ; # for {set i 0} {$i < [llength $extra_flags]}

} ; # for {set i 0} {$i < [llength $pbtype_flags]}