diff options
author | Thomas Fitzsimmons <fitzsim@redhat.com> | 2002-04-24 20:53:30 +0000 |
---|---|---|
committer | Thomas Fitzsimmons <fitzsim@redhat.com> | 2002-04-24 20:53:30 +0000 |
commit | eaa75b70e31aed8ba2823c7b37ff92230dd8c451 (patch) | |
tree | 255a744fbdffc3197c3f971ed1edae29c71a6134 /newlib/testsuite/lib | |
parent | b9f9f699372fae9f3b7926fa165d07fe68a949fb (diff) | |
download | cygnal-eaa75b70e31aed8ba2823c7b37ff92230dd8c451.tar.gz cygnal-eaa75b70e31aed8ba2823c7b37ff92230dd8c451.tar.bz2 cygnal-eaa75b70e31aed8ba2823c7b37ff92230dd8c451.zip |
* Makefile.am (check-DEJAGNU): New target.
(site.exp): Likewise.
* acinclude.m4 (NEWLIB_CONFIGURE): Replace AC_CANONICAL_HOST
with AC_CANONICAL_SYSTEM. Remove AC_CANONICAL_BUILD.
* libc/locale/locale.c (_setlocale_r): Add UTF-8 support.
* libc/stdlib/mbtowc_r.c (_mbtowc_r): Likewise.
* libc/stdlib/wctomb_r.c (_wctomb_r): Likewise.
* testsuite: New directory.
* testsuite/config: Likewise.
* testsuite/lib: Likewise.
* testsuite/newlib.locale: Likewise.
* testsuite/newlib.string: Likewise.
* testsuite/config/default.exp: New file.
* testsuite/lib/checkoutput.exp: New file.
* testsuite/lib/newlib.exp: New file.
* testsuite/lib/passfail.exp: New file.
* testsuite/newlib.locale/UTF-8.c: New file.
* testsuite/newlib.locale/UTF-8.exp: New file.
* testsuite/newlib.locale/locale.exp: New file.
* testsuite/newlib.string/string.exp: New file.
* testsuite/newlib.string/tstring.c: New file.
Diffstat (limited to 'newlib/testsuite/lib')
-rw-r--r-- | newlib/testsuite/lib/checkoutput.exp | 40 | ||||
-rw-r--r-- | newlib/testsuite/lib/newlib.exp | 110 | ||||
-rw-r--r-- | newlib/testsuite/lib/passfail.exp | 39 |
3 files changed, 189 insertions, 0 deletions
diff --git a/newlib/testsuite/lib/checkoutput.exp b/newlib/testsuite/lib/checkoutput.exp new file mode 100644 index 000000000..5793868fd --- /dev/null +++ b/newlib/testsuite/lib/checkoutput.exp @@ -0,0 +1,40 @@ +# Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. +# +# Permission to use, copy, modify, and distribute this software +# is freely granted, provided that this notice is preserved. +# + +# newlib_check_output takes the basename of the test source file, and +# a list of pairs of the form "testname" "expectedoutput" +# "testname" "expectedoutput"... 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" + } else { + pass "Compiled $srcfile.\n" + } + + set result [newlib_load $test_driver ""] + set status [lindex $result 0] + set output [lindex $result 1] + + set output_lines [split $output "\n"] + + foreach { testname expectedval } $expectlist { + if [string match "$expectedval" "[lindex $output_lines 0]"] then { + pass $testname + } else { + fail $testname + } + set output_lines [lrange $output_lines 1 end] + } +} diff --git a/newlib/testsuite/lib/newlib.exp b/newlib/testsuite/lib/newlib.exp new file mode 100644 index 000000000..e94534f6b --- /dev/null +++ b/newlib/testsuite/lib/newlib.exp @@ -0,0 +1,110 @@ +# Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. +# +# Permission to use, copy, modify, and distribute this software +# is freely granted, provided that this notice is preserved. +# + +proc newlib_version { } { + global tool_version + + verbose "In newlib version...\n" + + return $tool_version +} + +set newlib_initialized 0 + +proc newlib_init { args } { + global gluefile wrap_flags + global newlib_initialized + global target_info + global CFLAGS_FOR_TARGET + # These values are initialized in the local site.exp file + global srcdir objdir + global build_triplet host_triplet + # newlib_cflags comes from acinclude.m4, through the site.exp file + global newlib_cflags + global old_ld_library_path + + verbose "In newlib_init...\n" + + if { $newlib_initialized == 1 } { return; } + + set CFLAGS_FOR_TARGET $newlib_cflags + + set_currtarget_info "wrap_compile_flags" "$newlib_cflags" + + if {[target_info needs_status_wrapper] != "" && \ + [target_info needs_status_wrapper] != "0" && \ + ![info exists gluefile]} { + set gluefile ${objdir}/testglue.o; + set result [build_wrapper $gluefile]; + if { $result != "" } { + set gluefile [lindex $result 0]; + set wrap_flags [lindex $result 1]; + } else { + unset gluefile + } + } + + if [string match $build_triplet $host_triplet] then { + if [string match "i686-pc-linux-gnu" $build_triplet] then { + set old_ld_library_path [getenv LD_LIBRARY_PATH] + setenv LD_LIBRARY_PATH "$objdir/.libs" + } + } +} + +proc newlib_target_compile { source dest type options } { + global gluefile wrap_flags + global srcdir objdir + global build_triplet + global host_triplet + + verbose "In newlib_target_compile...\n" + + if {[target_info needs_status_wrapper] != "" && \ + [target_info needs_status_wrapper] != "0" && \ + [info exists gluefile] } { + lappend options "libs=$gluefile" + # This method of finding libgloss_target_dir may not work for some targets + set libgloss_target_dir [lindex [split $host_triplet "-"] 0] + lappend options "ldflags=$wrap_flags -B$objdir/../libgloss/$libgloss_target_dir \ + -L$objdir/../libgloss/$libgloss_target_dir \ + -L$srcdir/../../libgloss/$libgloss_target_dir \ + -L$objdir" + } + + if [string match $build_triplet $host_triplet] then { + if [string match "i686-pc-linux-gnu" $build_triplet] then { + lappend options "libs=$objdir/crt0.o -lc" + lappend options "ldflags=-nostdlib -L$objdir/.libs -lgcc" + } + } + + return [target_compile $source $dest $type $options] +} + +proc newlib_finish { } { + global old_ld_library_path + global build_triplet host_triplet + + verbose "In newlib_finish...\n" + + if [string match $build_triplet $host_triplet] then { + if [string match "i686-pc-linux-gnu" $build_triplet] then { + setenv LD_LIBRARY_PATH "$old_ld_library_path" + } + } +} + +proc newlib_exit { } { + global gluefile; + + verbose "In newlib_exit...\n" + + if [info exists gluefile] { + file_on_build delete $gluefile; + unset gluefile; + } +} diff --git a/newlib/testsuite/lib/passfail.exp b/newlib/testsuite/lib/passfail.exp new file mode 100644 index 000000000..8a44d274d --- /dev/null +++ b/newlib/testsuite/lib/passfail.exp @@ -0,0 +1,39 @@ +# Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. +# +# Permission to use, copy, modify, and distribute this software +# is freely granted, provided that this notice is preserved. +# + +# newlib_pass_fail compiles and runs all the source files in the test +# directory that are not included in the check_output_tests list. +# check_output_tests lists the sources' basenames. + +proc newlib_pass_fail { check_output_tests } { + global srcdir objdir subdir runtests + + foreach testcase [glob -nocomplain $srcdir/$subdir/*.c] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $testcase] then { + continue + } + + # Exclude tests which require their output to be checked + if {[lsearch $check_output_tests "[file tail $testcase]"] != -1} then { + continue + } + + set test_driver "$objdir/testsuite/[file tail [file rootname $testcase].x]" + + set comp_output [newlib_target_compile "$testcase" "$test_driver" "executable" ""] + + if { $comp_output != "" } { + fail "Failed to compile $testcase.\n" + fail "$testcase" + } else { + pass "Compiled $testcase.\n" + set result [newlib_load $test_driver ""] + set status [lindex $result 0] + $status "$testcase" + } + } +} |