1libmudflap-init c
2dg-init
3
4global srcdir subdir
5
6foreach flags [list {} {-static} {-O2} {-O3}] {
7    set l1 [libmudflap_target_compile "$srcdir/$subdir/externs-1.c" "externs-1.o" object {additional_flags=-fmudflap}]
8    set test "externs-1 compilation ${flags}"
9    if [string match "*mudflap cannot track unknown size extern *d*" $l1] { pass $test } { fail $test }
10
11    set l2 [libmudflap_target_compile "$srcdir/$subdir/externs-2.c" "externs-2.o" object {additional_flags=-fmudflap}]
12    set test "externs-2 compilation ${flags}"
13    if [string match "" $l2]  { pass $test } { fail $test }
14
15    set l3 [libmudflap_target_compile "externs-1.o externs-2.o" "externs-12.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap}]
16    set test "externs-12 linkage ${flags}"
17    if [string match "" $l3]  { pass $test } { fail $test }
18
19    set l4 [libmudflap_target_compile "externs-2.o externs-1.o" "externs-21.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap}]
20    set test "externs-21 linkage ${flags}"
21    if [string match "" $l3]  { pass $test } { fail $test }
22
23    setenv MUDFLAP_OPTIONS "-viol-segv"
24
25    remote_spawn host "./externs-12.exe"
26    set l5 [remote_wait host 10]
27    set test "externs-12 execution ${flags}"
28    if {[lindex $l5 0] == 0}  { pass $test } { fail $test }
29
30    remote_spawn host "./externs-21.exe"
31    set l6 [remote_wait host 10]
32    set test "externs-21 execution ${flags}"
33    if {[lindex $l6 0] == 0}  { pass $test } { fail $test }
34
35    foreach f [glob -nocomplain "externs-*"] {
36       remote_file build delete $f
37    }
38}
39
40dg-finish
41