diff options
author | Yao Qi <yao.qi@linaro.org> | 2016-02-04 15:46:37 +0000 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2016-02-04 15:46:37 +0000 |
commit | 31d913c7e4e84edf88b4324c3a9a8fb31c8206ec (patch) | |
tree | 8392dee4304d43954d85d3285c4003a23e4f4d38 /gdb/testsuite/gdb.multi | |
parent | e42e5352d1d1e8a262178f606a5df3d0d988f78a (diff) | |
download | binutils-gdb-31d913c7e4e84edf88b4324c3a9a8fb31c8206ec.tar.gz |
[testsuite] Remove BASEDIR
BASEDIR was added by https://sourceware.org/ml/gdb-patches/2013-10/msg00587.html
in order to handle the different directory layout in serial testing
and parallel testing. BASEDIR is "gdb.base" in serial testing and is
"outputs/gdb.base/TESTNAME" in parallel testing. However, it doesn't
work if the GDBserver is in remote target, like this,
$ make check RUNTESTFLAGS='--target_board=remote-gdbserver-on-localhost foll-vfork.exp foll-exec.exp'
FAIL: gdb.base/foll-exec.exp: continue to first exec catchpoint (the program exited)
FAIL: gdb.base/foll-vfork.exp: exec: vfork and exec child follow, to main bp: continue to bp (the program exited)
FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: finish (the program exited)
FAIL: gdb.base/foll-vfork.exp: exec: vfork relations in info inferiors: continue to bp (the program exited)
these tests fail because the executable can't be found. With target
board native-gdbserver, the program is spawned this way,
spawn ../gdbserver/gdbserver --once :2347 /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.base/foll-vfork
so BASEDIR is correct. However, with target board
remote-gdbserver-on-localhost, the program is spawned
spawn /usr/bin/ssh -l yao localhost /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/../gdbserver/gdbserver --once :2346 /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.base/foll-vfork
so BASEDIR (either "gdb.base" or "outputs/gdb.base/TESTNAME") makes no
sense.
I had a fix that pass absolute directory to BASEDIR, but it assumes
that directory structure is the same on build and target, and it
doesn't work in remote host case. The current fix in this patch is
to get the directory from argv[0]. In any case, the program to be
exec'ed is at the same directory with the main program.
Note that these tests do "next N" to let program stop at the desired
line, but it is fragile, because GDB for different targets may skip
function prologue slightly differently, so I replace some of them by
"tbreak on LINE NUMBER and continue".
gdb/testsuite:
2016-02-04 Yao Qi <yao.qi@linaro.org>
* gdb.base/foll-exec-mode.c: Include limits.h.
(main): Add parameters argc and argv. Get directory from
argv[0].
* gdb.base/foll-exec-mode.exp: Don't pass -DBASEDIR in
compilation.
* gdb.base/foll-exec.c: Include limits.h.
(main): Add parameters argc and argv.
Get directory from argv[0].
* gdb.base/foll-exec.exp: Don't pass -DBASEDIR in compilation.
Adjust tests on the number of lines as source code changed.
* gdb.base/foll-vfork-exit.c: Include limits.h.
(main): Add one line of statement before vfork.
* gdb.base/foll-vfork.c: Include limits.h and string.h.
(main): Add parameters argc and argv. Get directory from
argv[0].
* gdb.base/foll-vfork.exp: Don't pass -DBASEDIR in compilation.
(setup_gdb): Set tbreak to skip some source lines.
* gdb.multi/bkpt-multi-exec.c: Include limits.h.
(main): Add parameters argc and argv. Get directory from
argv[0].
* gdb.multi/bkpt-multi-exec.exp: Don't pass -DBASEDIR in
compilation.
* gdb.multi/multi-arch-exec.c: Include limits.h and string.h.
(main): Add parameters argc and argv. Get directory from
argv[0].
* gdb.multi/multi-arch-exec.exp: Don't pass -DBASEDIR in
compilation.
Diffstat (limited to 'gdb/testsuite/gdb.multi')
-rw-r--r-- | gdb/testsuite/gdb.multi/bkpt-multi-exec.c | 16 | ||||
-rw-r--r-- | gdb/testsuite/gdb.multi/bkpt-multi-exec.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.multi/multi-arch-exec.c | 17 | ||||
-rw-r--r-- | gdb/testsuite/gdb.multi/multi-arch-exec.exp | 4 |
4 files changed, 28 insertions, 11 deletions
diff --git a/gdb/testsuite/gdb.multi/bkpt-multi-exec.c b/gdb/testsuite/gdb.multi/bkpt-multi-exec.c index 94c96688d1b..eb002fb2545 100644 --- a/gdb/testsuite/gdb.multi/bkpt-multi-exec.c +++ b/gdb/testsuite/gdb.multi/bkpt-multi-exec.c @@ -2,12 +2,22 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> +#include <limits.h> -int main (void) +int main (int argc, char ** argv) { + char prog[PATH_MAX]; + int len; + + strcpy (prog, argv[0]); + len = strlen (prog); + /* Replace "bkpt-multi-exec" with "crashme". */ + memcpy (prog + len - 15, "crashme", 7); + prog[len - 8] = 0; + printf ("foll-exec is about to execl(crashme)...\n"); - execl (BASEDIR "/crashme", - BASEDIR "/crashme", + execl (prog, + prog, (char *)0); } diff --git a/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp b/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp index b7662df99cf..e5224136608 100644 --- a/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp +++ b/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp @@ -34,8 +34,6 @@ set srcfile2 ${exec2}.c set binfile2 [standard_output_file ${exec2}] set compile_options {debug} -set dirname [relative_filename [pwd] [file dirname $binfile1]] -lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\"" if { [build_executable ${testfile}.exp ${exec1} "${srcfile1}" $compile_options] == -1 } { return -1 diff --git a/gdb/testsuite/gdb.multi/multi-arch-exec.c b/gdb/testsuite/gdb.multi/multi-arch-exec.c index 864e264e873..168b4846dc3 100644 --- a/gdb/testsuite/gdb.multi/multi-arch-exec.c +++ b/gdb/testsuite/gdb.multi/multi-arch-exec.c @@ -18,12 +18,23 @@ #include <stdlib.h> #include <stdio.h> #include <unistd.h> +#include <limits.h> +#include <string.h> int -main () +main (int argc, char ** argv) { - execl (BASEDIR "/multi-arch-exec-hello", - BASEDIR "/multi-arch-exec-hello", + char prog[PATH_MAX]; + int len; + + strcpy (prog, argv[0]); + len = strlen (prog); + /* Replace "multi-arch-exec" with "multi-arch-exec-hello". */ + memcpy (prog + len - 15, "multi-arch-exec-hello", 21); + prog[len + 6] = 0; + + execl (prog, + prog, (char *) NULL); perror ("execl failed"); exit (1); diff --git a/gdb/testsuite/gdb.multi/multi-arch-exec.exp b/gdb/testsuite/gdb.multi/multi-arch-exec.exp index 5e9b59abb1a..88e5a621f3e 100644 --- a/gdb/testsuite/gdb.multi/multi-arch-exec.exp +++ b/gdb/testsuite/gdb.multi/multi-arch-exec.exp @@ -52,11 +52,9 @@ if [istarget "s390*-*-*"] { set march2 "-m32" } -set dirname [relative_filename [pwd] [file dirname $binfile2]] if { [prepare_for_testing ${testfile}.exp ${exec1} "${srcfile1}" \ [list debug \ - additional_flags=${march1} \ - additional_flags=-DBASEDIR=\"$dirname\"]] } { + additional_flags=${march1}]] } { return -1 } |