| 1 |
set test "sdt" |
| 2 |
set result_string10 {_ |
| 3 |
1 |
| 4 |
1 2 |
| 5 |
1 2 3 |
| 6 |
1 2 3 4 |
| 7 |
1 2 3 4 5 |
| 8 |
1 2 3 4 5 6 |
| 9 |
1 2 3 4 5 6 7 |
| 10 |
1 2 3 4 5 6 7 8 |
| 11 |
1 2 3 4 5 6 7 8 9 |
| 12 |
1 2 3 4 5 6 7 8 9 10} |
| 13 |
set result_string12 { |
| 14 |
1 2 3 4 5 6 7 8 9 10 11 |
| 15 |
1 2 3 4 5 6 7 8 9 10 11 12} |
| 16 |
|
| 17 |
set extra_flags {{additional_flags=-O2} |
| 18 |
{additional_flags=-O3} |
| 19 |
{additional_flags=-std=c89} |
| 20 |
{additional_flags=-std=c99} |
| 21 |
{additional_flags=-std=gnu99} |
| 22 |
{c++ additional_flags=-std=c++98 additional_flags=-x additional_flags=c++} |
| 23 |
{c++ additional_flags=-std=gnu++98 additional_flags=-x additional_flags=c++} |
| 24 |
{c++ additional_flags=-std=c++0x additional_flags=-x additional_flags=c++} |
| 25 |
{c++ additional_flags=-std=gnu++0x additional_flags=-x additional_flags=c++} |
| 26 |
} |
| 27 |
set extra_mssgs {-O2 -O3 c89 c99 gnu99 c++98 gnu++98 c++0x gnu++0x} |
| 28 |
set type_pedantics_idx {1 1 2 2 2 2 2 2 2} |
| 29 |
set type_pedantics {{} additional_flags=-pedantic} ; # don't compile -O2 -O3 with -pedantic |
| 30 |
set type_pedantic_mssgs {{} -pedantic} |
| 31 |
|
| 32 |
set pbtype_flags {{""} {additional_flags=-DSTAP_SDT_V2}} |
| 33 |
set pbtype_mssgs {{uprobe} {V2_uprobe}} |
| 34 |
|
| 35 |
proc sdt_stap_run { TEST_NAME TEST_FILE FAIL args } { |
| 36 |
foreach runtime [get_runtime_list] { |
| 37 |
set full_test_name $TEST_NAME |
| 38 |
if {$runtime != ""} { |
| 39 |
lappend full_test_name "($runtime)" |
| 40 |
set cmd [concat stap --runtime=$runtime $TEST_FILE $args] |
| 41 |
} elseif {[uprobes_p]} { |
| 42 |
set cmd [concat stap $TEST_FILE $args] |
| 43 |
} else { |
| 44 |
untested $full_test_name |
| 45 |
continue |
| 46 |
} |
| 47 |
send_log "executing: $cmd\n" |
| 48 |
catch {eval exec $cmd} res |
| 49 |
|
| 50 |
set skip 0 |
| 51 |
set n 0 |
| 52 |
set expected [split $::result_string "\n"] |
| 53 |
foreach line [split $res "\n"] { |
| 54 |
if {![string equal $line [lindex $expected $n]]} { |
| 55 |
$FAIL "$full_test_name" |
| 56 |
send_log "line [expr $n + 1]: expected \"[lindex $expected $n]\"\n" |
| 57 |
send_log "Got \"$line\"\n" |
| 58 |
set skip 1 |
| 59 |
break |
| 60 |
} |
| 61 |
incr n |
| 62 |
} |
| 63 |
if {$skip != 0} { |
| 64 |
continue |
| 65 |
} |
| 66 |
if {[expr $n == [llength $expected]]} { |
| 67 |
pass "$full_test_name" |
| 68 |
} else { |
| 69 |
$FAIL "$full_test_name" |
| 70 |
send_log "too few lines of output, got $n, expected [llength $expected]\n" |
| 71 |
} |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
# Iterate pbtype_flags |
| 76 |
for {set p 0} {$p < [llength $pbtype_flags]} {incr p} { |
| 77 |
set pbtype_flag [lindex $pbtype_flags $p] |
| 78 |
set pbtype_mssg [lindex $pbtype_mssgs $p] |
| 79 |
|
| 80 |
# Iterate extra_flags, trying each with C and C++ |
| 81 |
for {set i 0} {$i < [llength $extra_flags]} {incr i} { |
| 82 |
set extra_flag [lindex $extra_flags $i] |
| 83 |
set extra_mssg [lindex $extra_mssgs $i] |
| 84 |
set testprog "sdt.c.exe.$i" |
| 85 |
|
| 86 |
for {set j 0} {$j < [lindex $type_pedantics_idx $i]} {incr j} { |
| 87 |
set type_pedantic_mssg [lindex $type_pedantic_mssgs $j] |
| 88 |
|
| 89 |
set test_flags "additional_flags=-g" |
| 90 |
set test_flags "$test_flags [sdt_includes]" |
| 91 |
set test_flags "$test_flags additional_flags=-Wall" |
| 92 |
set test_flags "$test_flags additional_flags=-Wextra" |
| 93 |
set test_flags "$test_flags additional_flags=-Werror $pbtype_flag" |
| 94 |
|
| 95 |
set saveidx 0 |
| 96 |
|
| 97 |
set res [target_compile $srcdir/$subdir/$test.c $testprog executable "$test_flags $extra_flag [lindex $type_pedantics $j]"] |
| 98 |
if { $res != "" } { |
| 99 |
verbose "target_compile failed: $res" 2 |
| 100 |
# -std=gnu++0x and -std=c++0x are not universally accepted |
| 101 |
if {[string first "unrecognized command line option" $res] == -1} { |
| 102 |
fail "compiling $test.c $extra_mssg $type_pedantic_mssg $pbtype_mssg" |
| 103 |
} else { |
| 104 |
untested "compiling $test.c $extra_mssg $type_pedantic_mssg $pbtype_mssg" |
| 105 |
} |
| 106 |
untested "$test $extra_mssg $type_pedantic_mssg $pbtype_mssg" |
| 107 |
continue |
| 108 |
} else { |
| 109 |
pass "compiling $test.c $extra_mssg $type_pedantic_mssg $pbtype_mssg" |
| 110 |
} |
| 111 |
|
| 112 |
if {[installtest_p]} { |
| 113 |
if {[regexp "^(ppc64|s390x)$" $::tcl_platform(machine)] \ |
| 114 |
&& [regexp "^(-O)" $extra_mssg]} { |
| 115 |
# register name and constant is ambiguous in ppc/s390 asm syntax |
| 116 |
# thus constant folding can throw the result off |
| 117 |
set FAIL xfail |
| 118 |
} else { |
| 119 |
set FAIL fail |
| 120 |
} |
| 121 |
set ::result_string $result_string10 |
| 122 |
if { $pbtype_mssg == "uprobe" } { |
| 123 |
append ::result_string $result_string12 |
| 124 |
} |
| 125 |
sdt_stap_run "$test $extra_mssg $type_pedantic_mssg $pbtype_mssg" \ |
| 126 |
-w $FAIL $srcdir/$subdir/$test.stp $testprog -c ./$testprog |
| 127 |
} else { |
| 128 |
untested "$test $extra_mssg $type_pedantic_mssg $pbtype_mssg" |
| 129 |
} |
| 130 |
catch {exec rm -f $testprog} |
| 131 |
|
| 132 |
|
| 133 |
} ; # type_pedantics_idx |
| 134 |
|
| 135 |
} ; # for {set i 0} {$i < [llength $extra_flags]} |
| 136 |
|
| 137 |
} ; # for {set i 0} {$i < [llength $pbtype_flags]} |
| 138 |
|