fix some "exec" tests

A few tests run an inferior that execs some other program.  The name
of this exec'd program is compiled in.  These tests assume the current
test suite directory layout, but fail in parallel mode.

This patch fixes these tests by letting the .exp files pass in the
directory names at compile time.

2013-11-04  Tom Tromey  <tromey@redhat.com>

	* gdb.base/foll-exec.c (main): Use BASEDIR.
	* gdb.base/foll-exec.exp: Define BASEDIR during compilation.
	* gdb.base/foll-vfork.c (main): Use BASEDIR.
	* gdb.base/foll-vfork.exp: Define BASEDIR during compilation.
	* gdb.multi/bkpt-multi-exec.c (main): Use BASEDIR.
	* gdb.multi/bkpt-multi-exec.exp: Define BASEDIR during compilation.
This commit is contained in:
Tom Tromey 2013-10-18 14:00:44 -06:00
parent 24890efdab
commit 3fef966c5f
7 changed files with 36 additions and 15 deletions

View File

@ -1,3 +1,12 @@
2013-11-04 Tom Tromey <tromey@redhat.com>
* gdb.base/foll-exec.c (main): Use BASEDIR.
* gdb.base/foll-exec.exp: Define BASEDIR during compilation.
* gdb.base/foll-vfork.c (main): Use BASEDIR.
* gdb.base/foll-vfork.exp: Define BASEDIR during compilation.
* gdb.multi/bkpt-multi-exec.c (main): Use BASEDIR.
* gdb.multi/bkpt-multi-exec.exp: Define BASEDIR during compilation.
2013-11-04 Tom Tromey <tromey@redhat.com>
* gdb.base/argv0-symlink.exp: Compute executable's directory

View File

@ -17,27 +17,27 @@ main ()
printf ("foll-exec is about to execlp(execd-prog)...\n");
execlp ("gdb.base/execd-prog",
"gdb.base/execd-prog",
execlp (BASEDIR "/execd-prog",
BASEDIR "/execd-prog",
"execlp arg1 from foll-exec",
(char *)0);
printf ("foll-exec is about to execl(execd-prog)...\n");
execl ("gdb.base/execd-prog",
"gdb.base/execd-prog",
execl (BASEDIR "/execd-prog",
BASEDIR "/execd-prog",
"execl arg1 from foll-exec",
"execl arg2 from foll-exec",
(char *)0);
{
static char * argv[] = {
(char *)"gdb.base/execd-prog",
(char *)BASEDIR "/execd-prog",
(char *)"execv arg1 from foll-exec",
(char *)0};
printf ("foll-exec is about to execv(execd-prog)...\n");
execv ("gdb.base/execd-prog", argv);
execv (BASEDIR "/execd-prog", argv);
}
}

View File

@ -29,13 +29,17 @@ set testfile2 "execd-prog"
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 {debug}] != "" } {
if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable $compile_options] != "" } {
untested foll-exec.exp
return -1
}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_options] != "" } {
untested foll-exec.exp
return -1
}

View File

@ -29,7 +29,7 @@ main ()
pid = vfork ();
if (pid == 0) {
printf ("I'm the child!\n");
execlp ("gdb.base/vforked-prog", "gdb.base/vforked-prog", (char *)0);
execlp (BASEDIR "/vforked-prog", BASEDIR "/vforked-prog", (char *)0);
perror ("exec failed");
_exit (1);
}

View File

@ -47,7 +47,11 @@ if [istarget "hppa*-hp-hpux10.20"] then {
standard_testfile
if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
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"
return -1
}
@ -55,7 +59,7 @@ if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
set testfile2 "vforked-prog"
set srcfile2 ${testfile2}.c
if {[build_executable $testfile.exp $testfile2 $srcfile2 {debug}] == -1} {
if {[build_executable $testfile.exp $testfile2 $srcfile2 $compile_options] == -1} {
untested "failed to compile $testfile2"
return -1
}

View File

@ -7,7 +7,7 @@ int main (void)
{
printf ("foll-exec is about to execl(crashme)...\n");
execl ("gdb.multi/crashme",
"gdb.multi/crashme",
execl (BASEDIR "/crashme",
BASEDIR "/crashme",
(char *)0);
}

View File

@ -33,11 +33,15 @@ set exec2 "crashme"
set srcfile2 ${exec2}.c
set binfile2 [standard_output_file ${exec2}]
if { [build_executable ${testfile}.exp ${exec1} "${srcfile1}" {debug nowarnings}] == -1 } {
set compile_options {debug nowarnings}
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
}
if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}" {debug nowarnings}] == -1 } {
if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}" $compile_options] == -1 } {
return -1
}