PATCH: Support testing installed library
Mark Mitchell
mark@codesourcery.com
Fri May 27 23:53:00 GMT 2005
This patch makes it possible to run the newlib testsuite on an
installed newlib, rather than out of the newlib build directory.
The key changes are:
1. Use $tmpdir as the directory in which things are built, rather than
$objdir/testsuite. Then, have the Makefile create site.exp setting
tmpdir to $objdir/testsuite. This is the same technique used in
GCC and other tools; when testing an installed newlib, there's no
$objdir, or $objdir/testsuite, but there is $tmpdir.
2. Fall back to the original libgloss_link_flags code when testing an
installed newlib, rather than using the newlib code, which depends
on being in the build directory.
To be clear, there are no user-visible changes for someone who is used
to running "make check" in the build directory; the behavior is
exactly as before, including the location of files built by the
testsuite.
Tested with an arm-none-eabi newlib, testing both out of the build directory
and out of the installed directory.
OK to apply?
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2005-05-27 Mark Mitchell <mark@codesourcery.com>
* testsuite/lib/checkoutput.exp (newlib_check_output): Put
executables in $tmpdir.
* testsuite/lib/flags.exp (libgloss_link_flags): Use the original
libgloss version if not running in the build directory.
* testsuite/lib/newlib.exp (newlib_init): Put testglue.o in
$tmpdir.
* testsuite/lib/passfail.exp (newlib_pass_fail): Put executables
in $tmpdir.
Index: Makefile.am
===================================================================
RCS file: /cvs/src/src/newlib/Makefile.am,v
retrieving revision 1.33
diff -c -5 -p -r1.33 Makefile.am
*** Makefile.am 27 Jan 2005 19:13:54 -0000 1.33
--- Makefile.am 27 May 2005 23:47:56 -0000
*************** site.exp: Makefile
*** 340,349 ****
--- 340,350 ----
@echo '# edit the last section' >> $@-t
@echo 'set tool $(DEJATOOL)' >> $@-t
@echo 'set tool_version $(VERSION)' >> $@-t
@echo 'set srcdir $(srcdir)/testsuite' >> $@-t
@echo 'set objdir' `pwd` >> $@-t
+ @echo 'set tmpdir' `pwd`/testsuite >> $@-t
@echo 'set multibuildtop ./$(MULTIBUILDTOP)' >> $@-t
@echo 'set host_alias $(build_alias)' >> $@-t
@echo 'set host_triplet $(build_triplet)' >> $@-t
@echo 'set target_alias $(host_alias)' >> $@-t
@echo 'set target_triplet $(host_triplet)' >> $@-t
Index: testsuite/lib/checkoutput.exp
===================================================================
RCS file: /cvs/src/src/newlib/testsuite/lib/checkoutput.exp,v
retrieving revision 1.2
diff -c -5 -p -r1.2 checkoutput.exp
*** testsuite/lib/checkoutput.exp 15 May 2002 23:48:46 -0000 1.2
--- testsuite/lib/checkoutput.exp 27 May 2005 23:47:57 -0000
***************
*** 7,20 ****
# newlib_check_output takes the basename of the test source file, and
# a list of TCL regular expressions representing the expected output.
# It assumes one line of output per test.
proc newlib_check_output { srcfile expectlist } {
! global objdir subdir srcdir
set srcfullname "$srcdir/$subdir/$srcfile"
! set test_driver "$objdir/testsuite/[file tail [file rootname $srcfullname].x]"
set comp_output [newlib_target_compile "$srcfullname" "$test_driver" "executable" ""]
if { $comp_output != "" } {
fail "Failed to compile $srcfile.\n"
--- 7,20 ----
# newlib_check_output takes the basename of the test source file, and
# a list of TCL regular expressions representing the expected output.
# It assumes one line of output per test.
proc newlib_check_output { srcfile expectlist } {
! global subdir srcdir tmpdir
set srcfullname "$srcdir/$subdir/$srcfile"
! set test_driver "$tmpdir/[file tail [file rootname $srcfullname].x]"
set comp_output [newlib_target_compile "$srcfullname" "$test_driver" "executable" ""]
if { $comp_output != "" } {
fail "Failed to compile $srcfile.\n"
Index: testsuite/lib/flags.exp
===================================================================
RCS file: /cvs/src/src/newlib/testsuite/lib/flags.exp,v
retrieving revision 1.1
diff -c -5 -p -r1.1 flags.exp
*** testsuite/lib/flags.exp 1 May 2002 17:06:25 -0000 1.1
--- testsuite/lib/flags.exp 27 May 2005 23:47:57 -0000
***************
*** 10,25 ****
--- 10,33 ----
# These versions of the procedures generate link and include flags
# by searching for the needed files in the current build and source
# directories, rather than in the build and source paths of the
# compiler being used.
+ if {![llength [info procs saved_libgloss_link_flags]]} {
+ rename libgloss_link_flags saved_libgloss_link_flags
+ }
+
proc libgloss_link_flags { args } {
global target_cpu
# These values come from the local site.exp.
global srcdir objdir
global multibuildtop
+ if {![info exists multibuildtop]} {
+ return [saved_libgloss_link_flags $args]
+ }
+
verbose "In newlib version of libgloss_link_flags...\n"
if [isnative] {
return ""
}
Index: testsuite/lib/newlib.exp
===================================================================
RCS file: /cvs/src/src/newlib/testsuite/lib/newlib.exp,v
retrieving revision 1.6
diff -c -5 -p -r1.6 newlib.exp
*** testsuite/lib/newlib.exp 18 Oct 2002 18:18:49 -0000 1.6
--- testsuite/lib/newlib.exp 27 May 2005 23:47:57 -0000
*************** set newlib_initialized 0
*** 21,42 ****
proc newlib_init { args } {
global gluefile wrap_flags
global newlib_initialized
global target_info
# These values are initialized in the local site.exp file.
! global srcdir objdir
global host_triplet target_triplet
global old_ld_library_path
verbose "In newlib_init...\n"
if { $newlib_initialized == 1 } { return; }
if {[target_info needs_status_wrapper] != "" && \
[target_info needs_status_wrapper] != "0" && \
![info exists gluefile]} {
! set gluefile ${objdir}/testsuite/testglue.o;
set result [build_wrapper $gluefile];
if { $result != "" } {
set gluefile [lindex $result 0];
set wrap_flags [lindex $result 1];
} else {
--- 21,42 ----
proc newlib_init { args } {
global gluefile wrap_flags
global newlib_initialized
global target_info
# These values are initialized in the local site.exp file.
! global srcdir objdir tmpdir
global host_triplet target_triplet
global old_ld_library_path
verbose "In newlib_init...\n"
if { $newlib_initialized == 1 } { return; }
if {[target_info needs_status_wrapper] != "" && \
[target_info needs_status_wrapper] != "0" && \
![info exists gluefile]} {
! set gluefile ${tmpdir}/testglue.o;
set result [build_wrapper $gluefile];
if { $result != "" } {
set gluefile [lindex $result 0];
set wrap_flags [lindex $result 1];
} else {
Index: testsuite/lib/passfail.exp
===================================================================
RCS file: /cvs/src/src/newlib/testsuite/lib/passfail.exp,v
retrieving revision 1.3
diff -c -5 -p -r1.3 passfail.exp
*** testsuite/lib/passfail.exp 14 Nov 2002 23:04:05 -0000 1.3
--- testsuite/lib/passfail.exp 27 May 2005 23:47:57 -0000
*************** proc newlib_pass_fail_all { flag exclude
*** 30,44 ****
# newlib_pass_fail takes the basename of a test source file, which it
# compiles and runs.
proc newlib_pass_fail { srcfile } {
! global srcdir objdir subdir
set fullsrcfile "$srcdir/$subdir/$srcfile"
! set test_driver "$objdir/testsuite/[file rootname $srcfile].x"
set comp_output [newlib_target_compile "$fullsrcfile" "$test_driver" "executable" ""]
if { $comp_output != "" } {
fail "Failed to compile $fullsrcfile.\n"
--- 30,44 ----
# newlib_pass_fail takes the basename of a test source file, which it
# compiles and runs.
proc newlib_pass_fail { srcfile } {
! global srcdir tmpdir subdir
set fullsrcfile "$srcdir/$subdir/$srcfile"
! set test_driver "$tmpdir/[file rootname $srcfile].x"
set comp_output [newlib_target_compile "$fullsrcfile" "$test_driver" "executable" ""]
if { $comp_output != "" } {
fail "Failed to compile $fullsrcfile.\n"
More information about the Newlib
mailing list