1 # a hairy pattern to recognize
text
2 set text "\[- A-Za-z0-9\.\;\"\_\:\'\`\(\)\!\#\=\+\?\&\*]"
5 if { [which $SIZE
] == 0 } {
6 perror
"Can't find $SIZE."
9 #
Get the size of the various section in an object file
10 proc exe_size
{object
} {
13 # Make sure size
exists
14 if { [which $SIZE
] == 0 } {
15 return [list
"-1" "Can't find $SIZE."]
17 verbose
"Using $SIZE for \"size\" program." 2
19 set status [catch
"exec $SIZE -V" output]
20 if {[regexp
"GNU size" $output] == 0} {
21 perror
"Need GNU size from the binutils" 0
22 return [list
"-1" "Need GNU size."]
25 #
Get the object size. We pass
-x
, to force hex output
26 verbose
"Getting the object file size for $object" 2
27 set status [catch
"exec $SIZE -x $object" output]
28 verbose
-log "Size of $object is\n$output" 2
30 # Remove the header line from the size output. This currently only
32 regsub
"text.*filename\[\r\n\]*" $output "" output
34 # look
for the size of the .
text section
35 regexp
"\[\r\n\]*0x\[0-9a-fA-F\]*" $output text
36 regsub
"\[\r\n\]*0x\[0-9a-fA-F\]*\[ \t\]*" $output "" output
38 # look
for the size of the .data section
39 regexp
"0x\[0-9a-fA-F\]*\[ \t\]*" $output data
40 regsub
"0x\[0-9a-fA-F\]*\[ \t\]*" $output "" output
42 #
Values returns as hex
43 return [list $
text $data
]
46 # Run the host
's native compiler, not the cross one. Filter out the
47 # warnings and other extraneous stuff.
49 # A "" (empty) string if everything worked, or the
50 # output if there was a problem.
51 proc host_compile {compline} {
56 # execute the compiler
57 verbose "Compiling for the host using: $CC $INCLUDES $LIBS $compline" 2
58 set status [catch "exec $CC $INCLUDES $LIBS $compline" comp_output];
59 verbose "Compiler returned $comp_output" 2
61 # prune common warnings and other stuff we can safely ignore
62 set comp_output [prune_warnings $comp_output];
64 # Trim multiple CR/LF pairs out to keep things consistant
65 regsub "^\[\r\n\]+" $comp_output "" comp_output;
67 # if we got a compiler error, log it
68 if { [lindex $status 0] != 0 } {
69 verbose -log "compiler exited with status [lindex $status 0]";
71 if { [lindex $status 1] != "" } {
72 verbose -log "output is:\n[lindex $status 1]" 2;
75 # return the filtered output
79 # Execute the executable file, and anaylyse the output for the
80 # test state keywords.
82 # A "" (empty) string if everything worked, or an error message
83 # if there was a problem.
84 proc host_execute {args} {
87 set timeoutmsg "Timed out: Never got started, "
93 expect_before buffer_full { perror "Buffer full" }
95 if { [llength $args] == 0} {
98 set executable [string trimleft [lindex [split $args " "] 0] "\{"]
99 set params [string trimleft [lindex [split $args " "] 1] "\{"]
100 set params [string trimright $params "\}"]
103 verbose "The executable is $executable" 2
104 if ![file exists ${executable}] {
105 perror "The executable, \"$executable\" is missing" 0
106 return "No source file found"
109 # spawn the executable and look for the DejaGnu output messages from the
111 # spawn -noecho -open [open "|./${executable}" "r"]
112 spawn -noecho "./${executable}" ${params}
114 -re "\[0-9\]\[0-9\]:..:..:${text}\r\n" {
115 regsub "\[\n\r\t\]*NOTE: $text\r\n" $expect_out(0,string) "" output
120 -re "NOTE:${text}*" {
121 regsub "\[\n\r\t\]*NOTE: $text\r\n" $expect_out(0,string) "" output
126 -re "PASSED:${text}*" {
127 regsub "\[\n\r\t\]*PASSED: $text\r\n" $expect_out(0,string) "" output
132 -re "FAILED:${text}*" {
133 regsub "\[\n\r\t\]*FAILED: $text\r\n" $expect_out(0,string) "" output
138 -re "UNTESTED:${text}*" {
139 regsub "\[\n\r\t\]*TESTED: $text\r\n" $expect_out(0,string) "" output
144 -re "UNRESOLVED:${text}*" {
145 regsub "\[\n\r\t\]*UNRESOLVED: $text\r\n" $expect_out(0,string) "" output
154 # unresolved "${executable} died prematurely"
156 # return "${executable} died prematurely"
159 warning "Timed out executing test case"
160 if { $timetol <= 2 } {
165 return "Timed out executing test case"
170 # force a close of the executable to be safe.