diff options
author | Ian Lance Taylor <ian@airs.com> | 1995-11-15 17:21:26 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1995-11-15 17:21:26 +0000 |
commit | febc1fc3e3bb090a3effdc90cd78f10e53be7855 (patch) | |
tree | e3e9210c24d0ac479793e43653de73f9b304790a /binutils | |
parent | 29386972b9fd604316d2d6630fd85370dd6994a2 (diff) | |
download | gdb-febc1fc3e3bb090a3effdc90cd78f10e53be7855.zip gdb-febc1fc3e3bb090a3effdc90cd78f10e53be7855.tar.gz gdb-febc1fc3e3bb090a3effdc90cd78f10e53be7855.tar.bz2 |
* binutils-all/objcopy.exp: If assembly fails, call unresolved.
Test running objcopy and strip on a final executable.
* binutils-all/testprog.c: New file.
* config/default.exp (STRIP, STRIPFLAGS): Define.
(binutils_compile): New procedure.
* lib/utils-lib.exp (default_binutils_compile): New procedure.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/testsuite/ChangeLog | 14 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/.Sanitize | 1 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objcopy.exp | 150 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/testprog.c | 28 |
4 files changed, 190 insertions, 3 deletions
diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index 44d0fc5..f089f63 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,3 +1,17 @@ +Wed Nov 15 12:19:28 1995 Ian Lance Taylor <ian@cygnus.com> + + * binutils-all/objcopy.exp: If assembly fails, call unresolved. + Test running objcopy and strip on a final executable. + * binutils-all/testprog.c: New file. + * config/default.exp (STRIP, STRIPFLAGS): Define. + (binutils_compile): New procedure. + * lib/utils-lib.exp (default_binutils_compile): New procedure. + +Fri Nov 3 13:22:33 1995 Ian Lance Taylor <ian@cygnus.com> + + * lib/utils-lib.exp (default_binutils_run): Don't use verbose + -log, reverting part of Oct 2 change. + Wed Nov 1 15:09:57 1995 Manfred Hollstein KS/EF4A 60/1F/110 #40283 <manfred@lts.sel.alcatel.de> * binutils-all/objcopy.exp: Add setup_xfails for diff --git a/binutils/testsuite/binutils-all/.Sanitize b/binutils/testsuite/binutils-all/.Sanitize index ec92ab7..9e9c2d1 100644 --- a/binutils/testsuite/binutils-all/.Sanitize +++ b/binutils/testsuite/binutils-all/.Sanitize @@ -30,6 +30,7 @@ nm.exp objcopy.exp objdump.exp size.exp +testprog.c Things-to-lose: diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index 3838dcd..5ee2a36 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -26,8 +26,8 @@ if {[which $OBJCOPY] == 0} then { send_user "Version [binutil_version $OBJCOPY]" - if {![binutils_assemble $AS $srcdir$subdir/bintest.s tmpdir/bintest.o]} then { + unresolved "objcopy (simple copy)" return } @@ -51,7 +51,7 @@ if ![string match "" $got] then { setup_xfail "sh-*-coff" "sh-*-hms" setup_xfail "arm-*-pe" setup_xfail "m68*-*-hpux*" "m68*-*-sunos*" "m68*-*-coff" "m68*-*-vxworks*" - setup_xfail "m68*-ericsson-ose" "m68k*-motorola-sysv3*" + setup_xfail "m68*-ericsson-ose" "m68k*-motorola-sysv*" setup_xfail "i*86-*-linuxaout*" "i*86-*-aout*" setup_xfail "i*86-*-sysv*" "i*86-*-isc*" "i*86-*-sco*" "i*86-*-coff" setup_xfail "i*86-*-aix*" "i*86-*-go32*" @@ -61,7 +61,7 @@ if ![string match "" $got] then { setup_xfail "h8500-*-hms" "h8500-*-coff" setup_xfail "hppa*-*-*" clear_xfail "hppa*-*-*elf*" - setup_xfail "m88*-*-coff" "m88*-motorola-sysv3*" + setup_xfail "m88*-*-coff" "m88*-motorola-sysv*" setup_xfail "z8*-*-coff" if [string match "" $exec_output] then { @@ -255,3 +255,147 @@ if {$low == "" || $origstart == ""} then { } } } + +# Test stripping an object. + +proc strip_test { } { + global CC + global STRIP + global STRIPFLAGS + global NM + global NMFLAGS + global srcdir + global subdir + + set test "strip" + + if { [which $CC] == 0 } { + untested $test + return + } + + if ![binutils_compile $CC "-g -c" $srcdir/$subdir/testprog.c tmpdir/testprog.o] { + unresolved $test + return + } + + set exec_output [binutils_run $STRIP "$STRIPFLAGS tmpdir/testprog.o"] + if ![string match "" $exec_output] { + fail $test + return + } + + set exec_output [binutils_run $NM "-a $NMFLAGS tmpdir/testprog.o"] + if ![string match "No symbols in *" $exec_output] { + fail $test + return + } + + pass $test +} + +strip_test + +# Build a final executable. + +proc copy_setup { } { + global CC + global srcdir + global subdir + + if ![isnative] { + return 1 + } + + if { [which $CC] == 0 } { + return 2 + } + + if ![binutils_compile $CC "-g" $srcdir/$subdir/testprog.c tmpdir/testprog] { + return 3 + } + + set exec_output [binutils_run tmpdir/testprog ""] + if ![string match "ok" $exec_output] { + return 3 + } + + return 0 +} + +# Test copying an executable. + +proc copy_executable { prog flags test1 test2 } { + + set exec_output [binutils_run $prog "$flags tmpdir/testprog tmpdir/copyprog"] + if ![string match "" $exec_output] { + fail $test1 + fail $test2 + return + } + + set exec_output [binutils_run "cmp" "tmpdir/testprog tmpdir/copyprog"] + + if [string match "" $exec_output] then { + pass $test1 + } else { + send_log "$exec_output\n" + verbose "$exec_output" + # This will fail for many reasons. For example, it will most + # likely fail if the system linker is used. Therefore, we do + # not insist that it pass. If you are using an assembler and + # linker based on the same BFD as objcopy, it is worth + # investigating to see why this failure occurs. + setup_xfail "*-*-*" + fail $test1 + } + + set exec_output [binutils_run tmpdir/copyprog ""] + if ![string match "ok" $exec_output] { + fail $test2 + } else { + pass $test2 + } +} + +# Test stripping an executable + +proc strip_executable { prog flags test } { + + set exec_output [binutils_run $prog "$flags tmpdir/copyprog"] + if ![string match "" $exec_output] { + fail $test + return + } + + set exec_output [binutils_run tmpdir/copyprog ""] + if ![string match "ok" $exec_output] { + fail $test + } else { + pass $test + } +} + +set test1 "simple objcopy of executable" +set test2 "run objcopy of executable" +set test3 "run stripped executable" + +switch [copy_setup] { + "1" { + # do nothing + } + "2" { + untested $test1 + untested $test2 + untested $test3 + } + "3" { + unresolved $test1 + unresolved $test2 + unresolved $test3 + } + "0" { + copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" "$test2" + strip_executable "$STRIP" "$STRIPFLAGS" "$test3" + } +} diff --git a/binutils/testsuite/binutils-all/testprog.c b/binutils/testsuite/binutils-all/testprog.c new file mode 100644 index 0000000..210656b --- /dev/null +++ b/binutils/testsuite/binutils-all/testprog.c @@ -0,0 +1,28 @@ +/* This program is used to test objcopy and strip. */ + +int common; +int global = 1; +static int local = 2; +static char string[] = "string"; + +int +fn () +{ + return 3; +} + +int +main () +{ + if (common != 0 + || global != 1 + || local != 2 + || strcmp (string, "string") != 0) + { + printf ("failed\n"); + exit (1); + } + + printf ("ok\n"); + exit (0); +} |