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 | |
parent | e42e5352d1d1e8a262178f606a5df3d0d988f78a (diff) | |
download | gdb-31d913c7e4e84edf88b4324c3a9a8fb31c8206ec.zip gdb-31d913c7e4e84edf88b4324c3a9a8fb31c8206ec.tar.gz gdb-31d913c7e4e84edf88b4324c3a9a8fb31c8206ec.tar.bz2 |
[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')
-rw-r--r-- | gdb/testsuite/ChangeLog | 30 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/foll-exec-mode.c | 13 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/foll-exec-mode.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/foll-exec.c | 26 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/foll-exec.exp | 24 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/foll-vfork-exit.c | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/foll-vfork.c | 22 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/foll-vfork.exp | 8 | ||||
-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 |
12 files changed, 130 insertions, 39 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index ab74e6e..046f112 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,33 @@ +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. + 2016-02-01 Doug Evans <dje@google.com> * gdb.base/skip.exp: Clean up multiple references to same test name. diff --git a/gdb/testsuite/gdb.base/foll-exec-mode.c b/gdb/testsuite/gdb.base/foll-exec-mode.c index 1a482a5..67686d7 100644 --- a/gdb/testsuite/gdb.base/foll-exec-mode.c +++ b/gdb/testsuite/gdb.base/foll-exec-mode.c @@ -19,17 +19,26 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> +#include <limits.h> int global_i = 100; -int main (void) +int main (int argc, char ** argv) { int local_j = global_i + 1; int local_k = local_j + 1; + char prog[PATH_MAX]; + int len; + + strcpy (prog, argv[0]); + len = strlen (prog); + /* Replace "foll-exec-mode" with "execd-prog". */ + memcpy (prog + len - 14, "execd-prog", 10); + prog[len - 4] = 0; printf ("foll-exec is about to execlp(execd-prog)...\n"); - execlp (BASEDIR "/execd-prog", /* Set breakpoint here. */ + execlp (prog, /* Set breakpoint here. */ "/execd-prog", "execlp arg1 from foll-exec", (char *) 0); diff --git a/gdb/testsuite/gdb.base/foll-exec-mode.exp b/gdb/testsuite/gdb.base/foll-exec-mode.exp index 41d788b..aa7b4143 100644 --- a/gdb/testsuite/gdb.base/foll-exec-mode.exp +++ b/gdb/testsuite/gdb.base/foll-exec-mode.exp @@ -46,8 +46,6 @@ set srcfile2 ${testfile2}.c set binfile2 [standard_output_file ${testfile2}] set compile_options debug -set dirname [relative_filename [pwd] [file dirname $binfile]] -lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\"" # build the first test case if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable $compile_options] != "" } { diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c index 639698c..1ae171f 100644 --- a/gdb/testsuite/gdb.base/foll-exec.c +++ b/gdb/testsuite/gdb.base/foll-exec.c @@ -20,36 +20,48 @@ #include <unistd.h> #include <string.h> +#include <limits.h> + int global_i = 100; -int main (void) +int main (int argc, char ** argv) { int local_j = global_i + 1; int local_k = local_j + 1; + char prog[PATH_MAX]; + int len; printf ("foll-exec is about to execlp(execd-prog)...\n"); - execlp (BASEDIR "/execd-prog", - BASEDIR "/execd-prog", + strcpy (prog, argv[0]); + len = strlen (prog); + /* Replace "foll-exec" with "execd-prog". */ + memcpy (prog + len - 9, "execd-prog", 10); + prog[len + 1] = 0; + + execlp (prog, /* tbreak-execlp */ + prog, "execlp arg1 from foll-exec", (char *) 0); printf ("foll-exec is about to execl(execd-prog)...\n"); - execl (BASEDIR "/execd-prog", /* tbreak-execl */ - BASEDIR "/execd-prog", + execl (prog, /* tbreak-execl */ + prog, "execl arg1 from foll-exec", "execl arg2 from foll-exec", (char *) 0); { static char * argv[] = { - (char *) BASEDIR "/execd-prog", + (char *) "", (char *) "execv arg1 from foll-exec", (char *) 0}; + argv[0] = prog; + printf ("foll-exec is about to execv(execd-prog)...\n"); - execv (BASEDIR "/execd-prog", argv); /* tbreak-execv */ + execv (prog, argv); /* tbreak-execv */ } } diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp index 7d86d01..8859f9f 100644 --- a/gdb/testsuite/gdb.base/foll-exec.exp +++ b/gdb/testsuite/gdb.base/foll-exec.exp @@ -29,8 +29,6 @@ set srcfile2 ${testfile2}.c set binfile2 [standard_output_file ${testfile2}] set compile_options debug -set dirname [relative_filename [pwd] [file dirname $binfile]] -lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\"" # build the first test case if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable $compile_options] != "" } { @@ -80,19 +78,17 @@ proc do_exec_tests {} { fail "Couldn't run ${testfile}" return } + # Execute the code setting up variable PROG. + set tbreak_line [gdb_get_line_number " tbreak-execlp " $srcfile] + gdb_test "tbreak ${tbreak_line}" + gdb_continue_to_breakpoint "line tbreak-execlp" ".*execlp \\(.*" # Verify that we can see various global and local variables # in this program, and that they have expected values. Some # of these variables are also declared in the program we'll # exec in a moment. # - send_gdb "next 3\n" - gdb_expect { - -re "execlp \\(.*$gdb_prompt $"\ - {pass "step to exec call"} - -re "$gdb_prompt $" {fail "step to exec call"} - timeout {fail "(timeout) step to exec call"} - } + send_gdb "print global_i\n" gdb_expect { -re ".* = 100.*$gdb_prompt $"\ @@ -238,11 +234,15 @@ proc do_exec_tests {} { fail "Couldn't run ${testfile} (3rd try)" return } + # Execute the code setting up variable PROG. + set tbreak_line [gdb_get_line_number " tbreak-execlp " $srcfile] + gdb_test "tbreak ${tbreak_line}" + gdb_continue_to_breakpoint "line tbreak-execlp" ".*execlp \\(.*" # Verify that we can follow through follow an execl() # call. (We must jump around earlier exec* calls.) # - set tbreak_line [gdb_get_line_number "tbreak-execl" $srcfile] + set tbreak_line [gdb_get_line_number " tbreak-execl " $srcfile] send_gdb "tbreak ${tbreak_line}\n" gdb_expect { -re "Temporary breakpoint .*file .*${srcfile}, line ${tbreak_line}.*$gdb_prompt $"\ @@ -299,6 +299,10 @@ proc do_exec_tests {} { fail "Couldn't run ${testfile} (4th try)" return } + # Execute the code setting up variable PROG. + set tbreak_line [gdb_get_line_number " tbreak-execlp " $srcfile] + gdb_test "tbreak ${tbreak_line}" + gdb_continue_to_breakpoint "line tbreak-execlp" ".*execlp \\(.*" # Verify that we can follow through follow an execv() # call. (We must jump around earlier exec* calls.) diff --git a/gdb/testsuite/gdb.base/foll-vfork-exit.c b/gdb/testsuite/gdb.base/foll-vfork-exit.c index 6f168e2..c431ded 100644 --- a/gdb/testsuite/gdb.base/foll-vfork-exit.c +++ b/gdb/testsuite/gdb.base/foll-vfork-exit.c @@ -23,7 +23,10 @@ main () { int pid; - pid = vfork (); + /* A statement before vfork to make sure a breakpoint on main isn't + set on vfork below. */ + pid = 1; + pid = vfork (); /* VFORK */ if (pid == 0) { printf ("I'm the child!\n"); diff --git a/gdb/testsuite/gdb.base/foll-vfork.c b/gdb/testsuite/gdb.base/foll-vfork.c index 24b2a53..5949d45 100644 --- a/gdb/testsuite/gdb.base/foll-vfork.c +++ b/gdb/testsuite/gdb.base/foll-vfork.c @@ -18,14 +18,30 @@ #include <stdio.h> #include <unistd.h> -int main (void) +#include <limits.h> +#include <string.h> + +int +main (int argc, char ** argv) { int pid; - pid = vfork (); + /* A statement before vfork to make sure a breakpoint on main isn't + set on vfork below. */ + pid = 1 + argc; + pid = vfork (); /* VFORK */ if (pid == 0) { + char prog[PATH_MAX]; + int len; + + strcpy (prog, argv[0]); + len = strlen (prog); + /* Replace "foll-vfork" with "vforked-prog". */ + memcpy (prog + len - 10, "vforked-prog", 12); + prog[len + 2] = 0; + printf ("I'm the child!\n"); - execlp (BASEDIR "/vforked-prog", BASEDIR "/vforked-prog", (char *)0); + execlp (prog, prog, (char *) 0); perror ("exec failed"); _exit (1); } diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp index bf9b893..481dcb7 100644 --- a/gdb/testsuite/gdb.base/foll-vfork.exp +++ b/gdb/testsuite/gdb.base/foll-vfork.exp @@ -28,8 +28,6 @@ if {![istarget "*-linux*"]} then { standard_testfile set compile_options debug -set dirname [relative_filename [pwd] [file dirname $binfile]] -lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\"" if {[build_executable $testfile.exp $testfile $srcfile $compile_options] == -1} { untested "failed to compile $testfile" @@ -53,7 +51,7 @@ set timeout [expr "$timeout + 10"] # error, behave as "return", so we don't try to continue testing with # a borked session. proc setup_gdb {} { - global testfile + global testfile srcfile clean_restart $testfile @@ -64,6 +62,10 @@ proc setup_gdb {} { if ![runto_main] { return -code return } + + set tbreak_line [gdb_get_line_number " VFORK " $srcfile] + gdb_test "tbreak ${tbreak_line}" + gdb_continue_to_breakpoint ".*" } proc check_vfork_catchpoints {} { diff --git a/gdb/testsuite/gdb.multi/bkpt-multi-exec.c b/gdb/testsuite/gdb.multi/bkpt-multi-exec.c index 94c9668..eb002fb 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 b7662df..e522413 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 864e264..168b484 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 5e9b59a..88e5a62 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 } |