diff options
Diffstat (limited to 'ld/testsuite/ld.cdtest')
-rw-r--r-- | ld/testsuite/ld.cdtest/cdtest-foo.cc | 8 | ||||
-rw-r--r-- | ld/testsuite/ld.cdtest/cdtest-foo.h | 4 | ||||
-rw-r--r-- | ld/testsuite/ld.cdtest/cdtest-main.cc | 27 | ||||
-rw-r--r-- | ld/testsuite/ld.cdtest/cdtest.exp | 118 |
4 files changed, 80 insertions, 77 deletions
diff --git a/ld/testsuite/ld.cdtest/cdtest-foo.cc b/ld/testsuite/ld.cdtest/cdtest-foo.cc index 40be44b..615e33c 100644 --- a/ld/testsuite/ld.cdtest/cdtest-foo.cc +++ b/ld/testsuite/ld.cdtest/cdtest-foo.cc @@ -1,5 +1,5 @@ // Class Foo -//#pragma implementation +#pragma implementation // We don't use header files, since we only want to see, whether the @@ -18,8 +18,6 @@ extern "C" { #include "cdtest-foo.h" -const Foo::len = FOO_MSG_LEN; - int Foo::foos = 0; void Foo::init_foo () @@ -56,7 +54,7 @@ Foo::Foo (const Foo& foo) { i = ++foos; #ifdef WITH_ADDR - printf ("Initializing Foo(%d) \"%s\" at %08x with Foo(%d) %08x\n", + printf ("Initializing Foo(%d) \"%s\" at %08x with Foo(%d) %08x\n", i, foo.message, this, foo.i, &foo); #else printf ("Initializing Foo(%d) \"%s\" with Foo(%d)\n",i, foo.message, foo.i); @@ -68,7 +66,7 @@ Foo::Foo (const Foo& foo) Foo& Foo::operator= (const Foo& foo) { #ifdef WITH_ADDR - printf ("Copying Foo(%d) \"%s\" at %08x to Foo(%d) %08x\n", + printf ("Copying Foo(%d) \"%s\" at %08x to Foo(%d) %08x\n", foo.i, foo.message, &foo, i, this); #else printf ("Copying Foo(%d) \"%s\" to Foo(%d)\n", foo.i, foo.message, i); diff --git a/ld/testsuite/ld.cdtest/cdtest-foo.h b/ld/testsuite/ld.cdtest/cdtest-foo.h index 35b3a5c..0ba2d37 100644 --- a/ld/testsuite/ld.cdtest/cdtest-foo.h +++ b/ld/testsuite/ld.cdtest/cdtest-foo.h @@ -11,8 +11,8 @@ class Foo { static int foos; int i; - static const int len; - char message[FOO_MSG_LEN]; + const len = FOO_MSG_LEN; + char message[len]; public: static void init_foo (); static int nb_foos() { return foos; } diff --git a/ld/testsuite/ld.cdtest/cdtest-main.cc b/ld/testsuite/ld.cdtest/cdtest-main.cc index ac4b038..4b99b5c 100644 --- a/ld/testsuite/ld.cdtest/cdtest-main.cc +++ b/ld/testsuite/ld.cdtest/cdtest-main.cc @@ -1,12 +1,14 @@ // main program for Class Foo +extern "C" { +// Some <assert.h> implementations (e.g. SUNOS 4.1) are broken, +// in that they require <stdio.h>. But, if gcc/g++ is installed +// correctly, you should get gcc's assert.h. +// If the compile fails, it means the wrong include files are in use! +#include <assert.h> +}; #include "cdtest-foo.h" -// If we're using "../gcc/xgcc -B../gcc/", we may not have fixed C++ -// header files to work with. So we can't use assert.h here. -extern "C" void exit (int); -#define assert(X) if (!(X)) exit(1) - extern "C" void __init_start(); extern Foo f(void); @@ -14,24 +16,25 @@ extern void g(void); /* This function should *not* be called by the environment. There is no way in C++ to ``run something after the initializers but before main()''. - The library that depends on this (NIHCL) is broken. -- John Gilmore + The library that depends on this (NIHCL) is broken. -- John Gilmore We leave this here to test that future changes to the compiler do not re-introduce this losing ``feature''. */ -void +void __init_start() { Foo::init_foo(); } -static Foo static_foo( "static_foo"); +static Foo static_foo( "static_foo"); -main() -{ +main() +{ assert (Foo::nb_foos() == 2); Foo automatic_foo( "automatic_foo"); Foo bla_foo = f(); assert (Foo::nb_foos() == 4); g(); assert (Foo::nb_foos() == 4); - // `automatic_foo' and `bla_foo' are destructed here -} + // `automatic_foo' and `bla_foo' are destructed here +} + diff --git a/ld/testsuite/ld.cdtest/cdtest.exp b/ld/testsuite/ld.cdtest/cdtest.exp index 43acad4..e605c61 100644 --- a/ld/testsuite/ld.cdtest/cdtest.exp +++ b/ld/testsuite/ld.cdtest/cdtest.exp @@ -1,6 +1,5 @@ -# # Expect script for LD cdtest Tests -# Copyright (C) 1993 Free Software Foundation +# Copyright (C) 1993,1994 Free Software Foundation # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,71 +16,74 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ # # Written by Jeffrey Wheat (cassidy@cygnus.com) +# Rewritten by Ian Lance Taylor (ian@cygnus.com) # -# -# Bugs: -# + Assumes native toolchain, not cross. -# + Doesn't detect compilation failures (including lack of C++ compiler) -# cleanly. -# + Shouldn't use fixed names in /tmp for temp files -- either use names -# in current directory, or generate unique names. -# - -if $tracelevel then { - strace $tracelevel -} +# Make sure that constructors are handled correctly. -set tmpdir /tmp -set ld $objdir/ld.new +# This test requires running the executable generated by ld. +if ![isnative] {return} -set objects "$tmpdir/cdtest-main.o $tmpdir/cdtest-bar.o $tmpdir/cdtest-foo.o" +if ![file isdirectory tmpdir] {catch "exec mkdir tmpdir" status} -# compile the dependant objects - -verbose "### Compiling dependant objects\n" - -ld_compile "$CXX $CXXFLAGS" $srcdir/$subdir/cdtest-foo.cc $tmpdir/cdtest-foo.o -ld_compile "$CXX $CXXFLAGS" $srcdir/$subdir/cdtest-bar.cc $tmpdir/cdtest-bar.o -ld_compile "$CXX $CXXFLAGS" $srcdir/$subdir/cdtest-main.cc $tmpdir/cdtest-main.o +if ![ld_compile "$CXX $CXXFLAGS -fgnu-linker" $srcdir$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o] { + return +} +if ![ld_compile "$CXX $CXXFLAGS -fgnu-linker" $srcdir$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o] { + return +} +if ![ld_compile "$CXX $CXXFLAGS -fgnu-linker" $srcdir$subdir/cdtest-main.cc tmpdir/cdtest-main.o] { + return +} -# -# main test loop -# -foreach test [glob -nocomplain $srcdir/$subdir/*.dat] { - global target - global status - global result - - set target "$srcdir/$subdir/[file tail [file rootname $test]]" - set tmptarget "$tmpdir/[file tail [file rootname $test]]" - - verbose "### Running test $target\n" - - # link the target with objects and libraries - ld_link $ld $tmptarget $objects - - # load (execute) the target - if ![file exists $tmptarget] then { - unresolved "$tmptarget doesn't exist." +if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] { + fail cdtest +} else { + send_log "tmpdir/cdtest >tmpdir/cdtest.out\n" + verbose "tmpdir/cdtest >tmpdir/cdtest.out" + catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output + if ![string match "" $exec_output] then { + send_log "$exec_output\n" + verbose "$exec_output" 1 + fail cdtest } else { - catch "exec $tmptarget > $tmptarget.out" exec_output - - # diff the expected and actual outputs - if [file exists $tmptarget.out] then { - catch "simple_diff $target.dat $tmptarget.out" status + send_log "diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat\n" + verbose "diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat" + catch "exec diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat" exec_output + if [string match "" $exec_output] then { + pass cdtest } else { - fail "$tmptarget.out doesn't exist. error was $status" + send_log "$exec_output\n" + verbose "$exec_output" 1 + fail cdtest } } - # remove generated targets - verbose "Exec exec rm -f $tmptarget.o $tmptarget.out $tmptarget $tmptarget.grt" - catch "exec rm -f $tmptarget.o $tmptarget.out $tmptarget.grt $tmptarget" result } - -# remove dependant objects -verbose "Exec rm -f $objects" -catch "exec rm -f $objects" result -ld_exit - +if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] { + fail "cdtest with -Ur" +} else { + if ![ld_link $ld tmpdir/cdtest tmpdir/cdtest.o] { + fail "cdtest with -Ur" + } else { + send_log "tmpdir/cdtest >tmpdir/cdtest.out\n" + verbose "tmpdir/cdtest >tmpdir/cdtest.out" + catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output + if ![string match "" $exec_output] then { + send_log "$exec_output\n" + verbose "$exec_output" 1 + fail "cdtest with -Ur" + } else { + send_log "diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat\n" + verbose "diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat" + catch "exec diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat" exec_output + if [string match "" $exec_output] then { + pass "cdtest with -Ur" + } else { + send_log "$exec_output\n" + verbose "$exec_output" 1 + fail "cdtest with -Ur" + } + } + } +} |