#!/usr/bin/expect
load_lib "dejagnu.exp"

# Uncomment these for debugging help
#strace $tracelevel
# exp_internal -f dbg.log 1

# Execute everything in the test subdir so all the output files go there.
set last_dir [ pwd ]
cd $subdir

set local_tests [ glob *test ]

foreach exe_name $local_tests {
	verbose "Executing $exe_name"
	# Get the size of the module being tested.
	set sizes [exe_size $exe_name ]
	if {[lindex $sizes 0] == "-1"} {
	    perror "Couldn't get the object file size" 0
	}

	# Extract and log the text and data section sizes
	set textsize [lindex $sizes 0]
	set datasize [lindex $sizes 1]
	verbose "Text section size of proctor is 0x$textsize"
	verbose "Data section size of proctor is 0x$datasize"
	
	# Execute the test case, and analyse the output
	if { [host_execute $exe_name] != "" } {
	    perror "unit had an execution error" 0
	} 
}

# All done, back to the top level test directory
cd $last_dir

