Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Ping: Re: testcase for "absolute source" patch
@ 2004-10-02  4:08 Baurjan Ismagulov
  2004-10-12 14:07 ` Michael Chastain
  0 siblings, 1 reply; 3+ messages in thread
From: Baurjan Ismagulov @ 2004-10-02  4:08 UTC (permalink / raw)
  To: gdb-patches

Hello Michael,

Ping?

With kind regards,
Baurjan.

----- Forwarded message from Baurjan Ismagulov -----

Date: Sat, 25 Sep 2004 23:16:09 +0200
From: Baurjan Ismagulov
To: gdb-patches@sources.redhat.com
Subject: Re: testcase for "absolute source" patch

Hello Michael,

here is the new version.

On Tue, Aug 31, 2004 at 11:02:02AM -0400, Michael Chastain wrote:
> . ChangeLog entry

	* gdb.base/openp.c: New testcase.
	* gdb.base/openp.exp: New testcase checking for source, binary
	and compilation directory handling.


> . error checking on calls to remote_exec
> . gdb_suppress_entire_file is rotten and obsolete.
> . the convention for gdb_start and gdb_exit is to assume that the
>   previous test script left a gdb running and to call gdb_exit
>   first, followed by gdb_start.
> . in test_src, drop the semicolons here:
> . don't bother to do "remote_exec host rm $srcfile"

Done.


> . in test_bin, don't move the file back and forth -- just copy
>   the file and then leave the copy in place.  disk space is cheap,
>   and "mv $binfile $bin_dir ... $mv $bin_dir/$binname $binfile"
>   is vulnerable to cascade failures when you call test_bin 13
>   times in a row and one of them might de-synchronize.
>   same with test_src.
> 
>   Or am i missing something and it will screw up some tests if
>   you let the prime copies of $srcfile and $binfile exist
>   all the time?

All tests verify whether gdb finds (doesn't find) the files as expected.
To achieve that, we place them in some specific locations, such as
compilation directory, $PATH, gdb source path ("directory" command),
etc. The files from previous tests could cause false failures for the
tests where gdb is supposed not to find the file (all tests with '-'),
or false passes for the tests where gdb could find the wrong file (e.g.,
in the compilation directory rather than in the source path).

Actually, I hadn't moved the files around as I first started writing the
test; I just had been removing the files before a test if it was
necessary. However, the tests were depending on the state left from the
previous one, thus making the process of modifying and adding new tests
very difficult: to add the 14th test, you have to trace the first 13
ones. That is why I decided to delete all files after each test, thus
making the tests independent of each other. It might seem difficult to
debug at the first glance, but it is easily trackable from the log once
you know that each test expects to find the directory hierarchy in some
"standard" state (created til the line 206, just before the first
test_bin) and has to leave it in the same state. This greatly simplifies
both debugging and maintenance.


With kind regards,
Baurjan.

#   Copyright (C) 2004 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  

# This file was written by Baurjan Ismagulov <ibr@ata.cs.hun.edu.tr>.
# $Id: openp.exp,v 1.7 2004/09/25 21:14:05 ibr Exp $

# This file tests whether gdb finds the files properly given the
# following file names:
# 1. basename:   file
# 2. absolute:   /dir/file
# 3. relative:   dir/file
# 4. in current: ./file
# 5. in upper:   ../file

# Resolve possibe /./ and /../ within the given path. We are paranoid
# about cases like "mkdir -p a/../b" (although GNU coreutils and Solaris
# 8 seem to handle this particular case).
# XXX: Can this be replaced with tcl path manipulation routines?
proc canonize_path {dir} {
    set old_dir [pwd]
    cd $dir
    set new_dir [pwd]
    cd $old_dir
    return $new_dir
}

# Compile $src to $bin in $cdir.
# XXX: build == host.
proc cdir_compile {cdir src bin} {
    if [catch {set old_dir [pwd]} msg] {
	perror $msg
	return -1
    }
    if [catch {cd $cdir} msg] {
	perror $msg
	return -1
    }
    if {[gdb_compile $src $bin executable debug] != ""} {
	perror "Testcase compile failed."
	return -1
    }
    if [catch {cd $old_dir} msg] {
	perror $msg
	return -1
    }
    return 0
}

# Move the binary to $bin_dir, add $path_dir to PATH, gdb_test in the
# $gdb_wd directory.
# XXX: build == host.
proc test_bin {gdb_wd bin_dir path_dir gdb_test_cmd gdb_resp txt} {
    global binname
    global binfile
    global env
    if {$bin_dir != ""} {
	if {[lindex [remote_exec host "mv $binfile $bin_dir"] 0] != 0} {
	    unresolved "Failed to move $binfile to $bin_dir."
	    return -1
	}
    }
    if {$path_dir != "" && [info exists env(PATH)]} {
	if [catch {set old_path $env(PATH)} msg] {
	    perror $msg
	    return -1
	}
	# XXX: Directory separator in PATH?
	if [catch {set env(PATH) $env(PATH):$path_dir} msg] {
	    perror $msg
	    return -1
	}
    }
    if [catch {set old_dir [pwd]} msg] {
	perror $msg
	return -1
    }
    if [catch {cd $gdb_wd} msg] {
	perror $msg
	return -1
    }
    gdb_start
    gdb_test $gdb_test_cmd $gdb_resp $txt
    gdb_exit
    if [catch {cd $old_dir} msg] {
	perror $msg
	return -1
    }
    if [info exists old_path] {
	if [catch {set env(PATH) $old_path} msg] {
	    perror $msg
	    return -1
	}
    }
    if {$bin_dir != ""} {
	if {[lindex [remote_exec host "mv $bin_dir/$binname $binfile"] 0] != 0} {
	    unresolved "Failed to move $bin_dir/$binname to $binfile."
	    return -1
	}
    }
    return 0
}

# Compile in $comp_dir, move the source to $srcfile_dir, perform $cmd1
# and $cmd2, gdb_test in gdb_wd.
# XXX: build == host.
proc test_src {comp_dir comp_srcfile comp_binfile srcfile_dir
	       gdb_wd cmd1 cmd2 gdb_test_cmd gdb_resp txt} {
    global srcname
    global srcfile

    if [catch {set old_dir [pwd]} msg] {
	perror $msg
	return -1
    }
    if {[cdir_compile $comp_dir $comp_srcfile $comp_binfile] != 0} {
	unresolved "Failed to compile $comp_srcfile to $comp_binfile in $comp_dir."
	return -1
    }
    if {$srcfile_dir != ""} {
	if {[lindex [remote_exec host "mv $srcfile $srcfile_dir"] 0] != 0} {
	    unresolved "Failed to move $srcfile to $srcfile_dir."
	    return -1
	}
    }
    if [catch {cd $gdb_wd} msg] {
	perror $msg
	return -1
    }
    gdb_start
    if {$cmd1 != ""} {
	gdb_test $cmd1 ""
    }
    if {$cmd2 != ""} {
	gdb_test $cmd2 ""
    }
    gdb_test $gdb_test_cmd $gdb_resp $txt
    gdb_exit
    if [catch {cd $old_dir} msg] {
	perror $msg
	return -1
    }
    if {$srcfile_dir != ""} {
	if {[lindex [remote_exec host "mv $srcfile_dir/$srcname $srcfile"] 0] != 0} {
	    unresolved "Failed to move $srcfile_dir/$srcname to $srcfile."
	    return -1
	}
    }
    return 0
}


if {[is_remote host]} {
    unresolved "This test script does not work on a remote host."
    return -1
}

if $tracelevel then {
    strace $tracelevel
}

set prms_id 0
set bug_id 0

set testname "openp"
set srcname $testname.c
set binname $testname.bin
set testtmpdir [canonize_path $objdir/$subdir]/$testname
set srcfile $testtmpdir/subdir/src/$srcname
set binfile $testtmpdir/subdir/bin/$binname

set src_txt {1.int main\(\){return 0;}.*}

if {[lindex [remote_exec host "mkdir -p \
$testtmpdir/subdir/src/subdir \
$testtmpdir/subdir/bin/subdir \
$testtmpdir/subdir/cwd/bin \
$testtmpdir/subdir/cwd/src \
$testtmpdir/subdir/dir$testtmpdir/subdir/src/subdir \
$testtmpdir/subdir/dir$testtmpdir/subdir/bin \
$testtmpdir/subdir/dir/src"] 0] != 0} {
    unresolved "Failed to create the directories under $testtmpdir/subdir."
    return -1
}
if {[lindex [remote_exec host "cp $srcdir/$subdir/$testname.c $srcfile"] 0] != 0} {
    unresolved "Failed to copy $srcdir/$subdir/$testname.c to $srcfile."
    return -1
}
if {[cdir_compile $testtmpdir $srcfile $binfile] != 0} {
    unresolved "Failed to compile $srcfile to $binfile in $testtmpdir."
    return -1
}
gdb_exit


# b1+
test_bin $testtmpdir/subdir/bin \
    "" \
    "" \
    "file $binname" \
    "Reading symbols from $binfile\\.\\.\\.done\\..*" \
    "openp b1+ (existing binary, basename)"

# b1-
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir/bin \
    "file $binname" \
    "Reading symbols from $binfile\\.\\.\\..*done\\..*" \
    "openp b1- (non-existent binary, basename, find in PATH)"

# b2+
test_bin $testtmpdir/subdir/cwd \
    "" \
    "" \
    "file $binfile" \
    "Reading symbols from $binfile\\.\\.\\.done\\..*" \
    "openp b2+ (existing binary, absolute name)"

# b2-a
# XXX: Should we match locale-specific messages?
test_bin $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/dir$testtmpdir/subdir/bin \
    $testtmpdir/subdir/dir \
    "file $binfile" \
    "$binfile: .*" \
    "openp b2-a (non-existent binary, absolute name, don't look in <PATH_dir>/absolute)"

# b2-
# XXX: Should we match locale-specific messages?
test_bin $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/dir \
    "file $binfile" \
    "$binfile: .*" \
    "openp b2- (non-existent binary, absolute name, don't look for <PATH_dir>/basename)"

# b3+
test_bin $testtmpdir/subdir \
    "" \
    "" \
    "file bin/$binname" \
    "Reading symbols from $binfile\\.\\.\\.done\\..*" \
    "openp b3+ (existing binary, relative name)"

# b3-r
# XXX: locale
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir \
    "file bin/$binname" \
    "bin/$binname: .*" \
    "openp b3-r (non-existent binary, relative name, don't look in <PATH_dir>/relative)"

# b3-
# XXX: locale
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir/bin \
    "file bin/$binname" \
    "bin/$binname: .*" \
    "openp b3- (non-existent binary, relative name, don't look in <PATH_dir>/basename)"

# b4+
test_bin $testtmpdir/subdir/bin \
    "" \
    "" \
    "file ./$binname" \
    "Reading symbols from $binfile\\.\\.\\.done\\..*" \
    "openp b4+ (existing binary, in the current dir)"

# b4-
# XXX: locale
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir/bin \
    "file ./$binname" \
    "\\./$binname: .*" \
    "openp b4- (non-existent binary, in the current dir, don't look in PATH)"

# b5+
test_bin $testtmpdir/subdir/bin/subdir \
    "" \
    "" \
    "file ../$binname" \
    "Reading symbols from $binfile\\.\\.\\.done\\..*" \
    "openp b5+ (existing binary, in the upper dir)"

# b5-r
# XXX: locale
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir/bin/subdir \
    "file ../$binname" \
    "\\.\\./$binname: .*" \
    "openp b5-r (non-existent binary, in the upper dir name, don't look in <PATH_dir>/relative)"

# b5-
# XXX: locale
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir/bin \
    "file ../$binname" \
    "\\.\\./$binname: .*" \
    "openp b5- (non-existent binary, in the upper dir name, don't look in <PATH_dir>/basename)"


# s1+
test_src $testtmpdir/subdir/src $srcname $binfile \
    "" \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s1+ (existing source, basename)"

# s1-.
test_src $testtmpdir/subdir/src $srcname $binfile \
    $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s1-. (non-existent source, basename, find in \$cwd/basename)"

# s1-da
test_src $testtmpdir/subdir/src $srcname $binfile \
    $testtmpdir/subdir/dir$testtmpdir/subdir/src \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s1-da (non-existent source, basename, find in <dir>/\$cdir/basename)"

# s1-d
test_src $testtmpdir/subdir/src $srcname $binfile \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s1-d (non-existent source, basename, find in <dir>/basename)"

# s2+
test_src $testtmpdir $srcfile $binfile \
    "" \
    $testtmpdir/subdir/cwd \
    "file $binfile" ""\
    "l main" \
    $src_txt \
    "openp s2+ (existing source, absolute name)"

# s2-.
test_src $testtmpdir $srcfile $binfile \
    $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s2-. (non-existent source, absolute name, find in \$cwd/basename)"

# s2-da
test_src $testtmpdir $srcfile $binfile \
    $testtmpdir/subdir/dir$testtmpdir/subdir/src \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s2-da (non-existent source, absolute name, find in <dir>/absolute)"

# s2-d
test_src $testtmpdir $srcfile $binfile \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s2-d (non-existent source, absolute name, find in <dir>/basename)"

# s3+
test_src $testtmpdir/subdir src/$srcname $binfile \
    "" \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s3+ (existing source, relative name)"

# s3-.r
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir/cwd/src \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s3-.r (non-existent source, relative name, find in \$cwd/relative)"

# s3-c
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s3-c (non-existent source, relative name, find in \$cdir/basename)"

# s3-.
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s3-. (non-existent source, relative name, find in \$cwd/basename)"

# s3-da
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir/dir$testtmpdir/subdir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s3-da (non-existent source, relative name, find in <dir>/\$cdir/relative)"

# s3-dr
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir/dir/src \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s3-dr (non-existent source, relative name, find in <dir>/relative)"

# s3-d
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s3-d (non-existent source, relative name, find in <dir>/basename)"

# s4+
test_src $testtmpdir/subdir/src ./$srcname $binfile \
    "" \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s4+ (existing source, in the current dir)"

# s4-.
test_src $testtmpdir/subdir/src ./$srcname $binfile \
    $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s4-. (non-existent source, in the current dir, find in \$cwd/basename)"

# s4-da
test_src $testtmpdir/subdir/src ./$srcname $binfile \
    $testtmpdir/subdir/dir$testtmpdir/subdir/src \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s4-da (non-existent source, in the current dir, find in <dir>/\$cdir/basename)"

# s4-d
test_src $testtmpdir/subdir/src ./$srcname $binfile \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s4-d (non-existent source, in the current dir, find in <dir>/basename)"

# s5+
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    "" \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s5+ (existing source, in the upper dir)"

# s5-.r
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s5-.r (non-existent source, in the upper dir, find in \$cwd/relative)"

# s5-c
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir/src/subdir \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s5-c (non-existent source, in the upper dir, find in \$cdir/basename)"

# s5-.
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s5-. (non-existent source, in the upper dir, find in \$cdir/basename)"

# s5-da
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir/dir$testtmpdir/subdir/src/subdir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s5-da (non-existent source, in the upper dir, find in <dir>/\$cdir/relative)"

# s5-dr
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s5-dr (non-existent source, in the upper dir, find in <dir>/relative)"

# s5-d
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s5-d (non-existent source, in the upper dir, find in <dir>/basename)"

int main(){return 0;}


----- End forwarded message -----


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Ping: Re: testcase for "absolute source" patch
  2004-10-02  4:08 Ping: Re: testcase for "absolute source" patch Baurjan Ismagulov
@ 2004-10-12 14:07 ` Michael Chastain
  2004-10-15 14:51   ` Baurzhan Ismagulov
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Chastain @ 2004-10-12 14:07 UTC (permalink / raw)
  To: ibr, gdb-patches

Hi Baurjan,

> All tests verify whether gdb finds (doesn't find) the files as expected.
> To achieve that, we place them in some specific locations, such as
> compilation directory, $PATH, gdb source path ("directory" command),
> etc. The files from previous tests could cause false failures for the
> tests where gdb is supposed not to find the file (all tests with '-'),
> or false passes for the tests where gdb could find the wrong file (e.g.,
> in the compilation directory rather than in the source path).
>
> ... I decided to delete all files after each test, thus
> making the tests independent of each other.
> 
> ... each test expects to find the directory hierarchy in some
> "standard" state (created til the line 206, just before the first
> test_bin) and has to leave it in the same state.

These would make good comments to add to the test script.  Indeed,
whenever the approval guy doesn't get something and the contributor
has to explain it, that explanation is a good candidate for a comment
in the source code.

Okay, I am looking at gdb.log and there is not enough trace information
about what directory is being tested.  Can you add something like this
to test_bin and test_src:

  proc test_bin () {
    ...
    if [catch {cd $gdb_wd} msg] {
      ...
    }
    pass "test_bin cd $gdb_wd"
    ...
  }

That is not really a test; it's more of a marker for people who are
reading gdb.log to figure out the tests.

Also the ChangeLong entry should have your name and the date on it.

Now for the substantive part ...

I'm getting four FAIL results with gdb HEAD:

  gdb.base/openp.exp: openp s1-da (non-existent source, basename, find in <dir>/$cdir/basename)
  gdb.base/openp.exp: openp s3-da (non-existent source, relative name, find in <dir>/$cdir/relative)
  gdb.base/openp.exp: openp s4-da (non-existent source, in the current dir, find in <dir>/$cdir/basename)
  gdb.base/openp.exp: openp s5-da (non-existent source, in the upper dir, find in <dir>/$cdir/relative)

Are these bugs in gdb or problems with the test script?

I looked at the first one, s1-da, and it looks like a problem with
the test script.  The test program is compiled with the bare basename
"openp.c".  But there is no copy of openp.c in $gdb_wd, and $cmd1
is a gdb "dir" command for another directory where there is no openp.c.
It looks like $gdb_resp for this test should not be "$src_txt",
but something more like "1\topenp.c: No such file or directory\\..*".
Or am I mis-reading something?

Michael

===

	* gdb.base/openp.c: New testcase.
	* gdb.base/openp.exp: New testcase checking for source, binary
	and compilation directory handling.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Ping: Re: testcase for "absolute source" patch
  2004-10-12 14:07 ` Michael Chastain
@ 2004-10-15 14:51   ` Baurzhan Ismagulov
  0 siblings, 0 replies; 3+ messages in thread
From: Baurzhan Ismagulov @ 2004-10-15 14:51 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2060 bytes --]

Hello Michael,

On Tue, Oct 12, 2004 at 09:37:07AM -0400, Michael Chastain wrote:
> These would make good comments to add to the test script.
...
> Okay, I am looking at gdb.log and there is not enough trace information
> about what directory is being tested.

Added.


> I'm getting four FAIL results with gdb HEAD:
> 
>   gdb.base/openp.exp: openp s1-da (non-existent source, basename, find in <dir>/$cdir/basename)
>   gdb.base/openp.exp: openp s3-da (non-existent source, relative name, find in <dir>/$cdir/relative)
>   gdb.base/openp.exp: openp s4-da (non-existent source, in the current dir, find in <dir>/$cdir/basename)
>   gdb.base/openp.exp: openp s5-da (non-existent source, in the upper dir, find in <dir>/$cdir/relative)
> 
> Are these bugs in gdb or problems with the test script?

These are cases I was not sure about and asked for help in
http://sources.redhat.com/ml/gdb-patches/2004-08/msg00539.html . At the
moment, gdb performs the following sequence while looking for a source
file in case s1-da (compiled in $cdir as basename, <dir> in source path
(i.e., "directory <dir>" has been previously executed), we are in $cwd):

1. try basename;

2. try <dir>/basename;

3. fail.

The question is, should gdb try <dir>/$cdir/basename after step 2? This
is not implemented right now, but could help people compiling the
sources as basename in each directory (i.e., they call make recursively
and do "gcc foo.c" without a path) and having the compilation tree under
some directory on the gdb host (which, I think, was the idea behind the
"directory" command).

As the file opening mechanism gets more and more complex, we should have
a clear policy what we do and what we don't. That is why I wanted to
hear others' opinions. If you say "no, we shouldn't append $cdir after
<dir>", then I convert these FAILs into PASSes.


With kind regards,
Baurjan.


2004-10-15  Baurjan Ismagulov  <ibr@ata.cs.hun.edu.tr>

	* gdb.base/openp.c: New testcase.
	* gdb.base/openp.exp: New testcase checking for source, binary
	and compilation directory handling.

[-- Attachment #2: openp.exp --]
[-- Type: text/plain, Size: 16707 bytes --]

#   Copyright (C) 2004 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  

# This file was written by Baurjan Ismagulov <ibr@ata.cs.hun.edu.tr>.
# $Id: openp.exp,v 1.8 2004/10/15 13:58:28 ibr Exp $

# This file tests whether gdb finds the files properly given the
# following file names:
# 1. basename:   file
# 2. absolute:   /dir/file
# 3. relative:   dir/file
# 4. in current: ./file
# 5. in upper:   ../file

# This is checked for binaries as well as for sources. To do that, we
# place them in some specific locations, such as compilation directory,
# $PATH, gdb source path ("directory" command), etc. As the files from
# the previous tests could interfere with the test currently running
# (sometimes we expect gdb to find a file, sometimes -- not), we define
# a certain state of files and directories as canonical, move the files
# around before each test, and move them back thereafter.


# Resolve possibe /./ and /../ within the given path. We are paranoid
# about cases like "mkdir -p a/../b" (although GNU coreutils and Solaris
# 8 seem to handle this particular case).
# XXX: Can this be replaced with tcl path manipulation routines?
proc canonize_path {dir} {
    set old_dir [pwd]
    cd $dir
    set new_dir [pwd]
    cd $old_dir
    return $new_dir
}

# Compile $src to $bin in $cdir.
# XXX: build == host.
proc cdir_compile {cdir src bin} {
    if [catch {set old_dir [pwd]} msg] {
	perror $msg
	return -1
    }
    if [catch {cd $cdir} msg] {
	perror $msg
	return -1
    }
    if {[gdb_compile $src $bin executable debug] != ""} {
	perror "Testcase compile failed."
	return -1
    }
    if [catch {cd $old_dir} msg] {
	perror $msg
	return -1
    }
    return 0
}

# Move the binary to $bin_dir, add $path_dir to PATH, gdb_test in the
# $gdb_wd directory.
# XXX: build == host.
proc test_bin {gdb_wd bin_dir path_dir gdb_test_cmd gdb_resp txt} {
    global binname
    global binfile
    global env
    if {$bin_dir != ""} {
	if {[lindex [remote_exec host "mv $binfile $bin_dir"] 0] != 0} {
	    unresolved "Failed to move $binfile to $bin_dir."
	    return -1
	}
	set our_bin $bin_dir/$binname
    } else {
	set our_bin $binfile
    }
    if {$path_dir != "" && [info exists env(PATH)]} {
	if [catch {set old_path $env(PATH)} msg] {
	    perror $msg
	    return -1
	}
	# XXX: Directory separator in PATH?
	if [catch {set env(PATH) $env(PATH):$path_dir} msg] {
	    perror $msg
	    return -1
	}
    }
    if [catch {set old_dir [pwd]} msg] {
	perror $msg
	return -1
    }
    if [catch {cd $gdb_wd} msg] {
	perror $msg
	return -1
    }
    pass "test_bin: We are in $gdb_wd, our binary is $our_bin, and we've added \"$path_dir\" to PATH."
    gdb_start
    gdb_test $gdb_test_cmd $gdb_resp $txt
    gdb_exit
    if [catch {cd $old_dir} msg] {
	perror $msg
	return -1
    }
    if [info exists old_path] {
	if [catch {set env(PATH) $old_path} msg] {
	    perror $msg
	    return -1
	}
    }
    if {$bin_dir != ""} {
	if {[lindex [remote_exec host "mv $bin_dir/$binname $binfile"] 0] != 0} {
	    unresolved "Failed to move $bin_dir/$binname to $binfile."
	    return -1
	}
    }
    return 0
}

# Compile in $comp_dir, move the source to $srcfile_dir, perform $cmd1
# and $cmd2, gdb_test in $gdb_wd.
# XXX: build == host.
proc test_src {comp_dir comp_srcfile comp_binfile srcfile_dir
	       gdb_wd cmd1 cmd2 gdb_test_cmd gdb_resp txt} {
    global srcname
    global srcfile

    if [catch {set old_dir [pwd]} msg] {
	perror $msg
	return -1
    }
    if {[cdir_compile $comp_dir $comp_srcfile $comp_binfile] != 0} {
	unresolved "Failed to compile $comp_srcfile to $comp_binfile in $comp_dir."
	return -1
    }
    if {$srcfile_dir != ""} {
	if {[lindex [remote_exec host "mv $srcfile $srcfile_dir"] 0] != 0} {
	    unresolved "Failed to move $srcfile to $srcfile_dir."
	    return -1
	}
	set our_src $srcfile_dir/$srcname
    } else {
	set our_src $srcfile
    }
    if [catch {cd $gdb_wd} msg] {
	perror $msg
	return -1
    }
    pass "test_src: We are in $gdb_wd, our source is $our_src and was compiled under $comp_dir as $comp_srcfile."
    gdb_start
    if {$cmd1 != ""} {
	gdb_test $cmd1 ""
    }
    if {$cmd2 != ""} {
	gdb_test $cmd2 ""
    }
    gdb_test $gdb_test_cmd $gdb_resp $txt
    gdb_exit
    if [catch {cd $old_dir} msg] {
	perror $msg
	return -1
    }
    if {$srcfile_dir != ""} {
	if {[lindex [remote_exec host "mv $srcfile_dir/$srcname $srcfile"] 0] != 0} {
	    unresolved "Failed to move $srcfile_dir/$srcname to $srcfile."
	    return -1
	}
    }
    return 0
}


if {[is_remote host]} {
    unresolved "This test script does not work on a remote host."
    return -1
}

if $tracelevel then {
    strace $tracelevel
}

set prms_id 0
set bug_id 0

set testname "openp"
set srcname $testname.c
set binname $testname.bin
set testtmpdir [canonize_path $objdir/$subdir]/$testname
set srcfile $testtmpdir/subdir/src/$srcname
set binfile $testtmpdir/subdir/bin/$binname

set src_txt {1.int main\(\){return 0;}.*}

if {[lindex [remote_exec host "mkdir -p \
$testtmpdir/subdir/src/subdir \
$testtmpdir/subdir/bin/subdir \
$testtmpdir/subdir/cwd/bin \
$testtmpdir/subdir/cwd/src \
$testtmpdir/subdir/dir$testtmpdir/subdir/src/subdir \
$testtmpdir/subdir/dir$testtmpdir/subdir/bin \
$testtmpdir/subdir/dir/src"] 0] != 0} {
    unresolved "Failed to create the directories under $testtmpdir/subdir."
    return -1
}
if {[lindex [remote_exec host "cp $srcdir/$subdir/$testname.c $srcfile"] 0] != 0} {
    unresolved "Failed to copy $srcdir/$subdir/$testname.c to $srcfile."
    return -1
}
if {[cdir_compile $testtmpdir $srcfile $binfile] != 0} {
    unresolved "Failed to compile $srcfile to $binfile in $testtmpdir."
    return -1
}
gdb_exit

# At this point our canonical environment is ready. The binary is in
# $binfile. It can be moved by some test if necessary, but must be moved
# back after the test; leaving it where it was during the test may cause
# false passes or failures in the next tests. Since we test where gdb
# should find or not find a given file, we should have exactly one
# binary for the binary tests, otherwise we cannot be sure which one was
# found by gdb.

# Likewise, the source is in $srcfile, and we should have exactly one
# source for the source tests. The binaries are compiled by every test
# and deleted afterwards.


# b1+
test_bin $testtmpdir/subdir/bin \
    "" \
    "" \
    "file $binname" \
    "Reading symbols from $binfile\\.\\.\\.done\\..*" \
    "openp b1+ (existing binary, basename)"

# b1-
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir/bin \
    "file $binname" \
    "Reading symbols from $binfile\\.\\.\\..*done\\..*" \
    "openp b1- (non-existent binary, basename, find in PATH)"

# b2+
test_bin $testtmpdir/subdir/cwd \
    "" \
    "" \
    "file $binfile" \
    "Reading symbols from $binfile\\.\\.\\.done\\..*" \
    "openp b2+ (existing binary, absolute name)"

# b2-a
# XXX: Should we match locale-specific messages?
test_bin $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/dir$testtmpdir/subdir/bin \
    $testtmpdir/subdir/dir \
    "file $binfile" \
    "$binfile: .*" \
    "openp b2-a (non-existent binary, absolute name, don't look in <PATH_dir>/absolute)"

# b2-
# XXX: Should we match locale-specific messages?
test_bin $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/dir \
    "file $binfile" \
    "$binfile: .*" \
    "openp b2- (non-existent binary, absolute name, don't look for <PATH_dir>/basename)"

# b3+
test_bin $testtmpdir/subdir \
    "" \
    "" \
    "file bin/$binname" \
    "Reading symbols from $binfile\\.\\.\\.done\\..*" \
    "openp b3+ (existing binary, relative name)"

# b3-r
# XXX: locale
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir \
    "file bin/$binname" \
    "bin/$binname: .*" \
    "openp b3-r (non-existent binary, relative name, don't look in <PATH_dir>/relative)"

# b3-
# XXX: locale
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir/bin \
    "file bin/$binname" \
    "bin/$binname: .*" \
    "openp b3- (non-existent binary, relative name, don't look in <PATH_dir>/basename)"

# b4+
test_bin $testtmpdir/subdir/bin \
    "" \
    "" \
    "file ./$binname" \
    "Reading symbols from $binfile\\.\\.\\.done\\..*" \
    "openp b4+ (existing binary, in the current dir)"

# b4-
# XXX: locale
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir/bin \
    "file ./$binname" \
    "\\./$binname: .*" \
    "openp b4- (non-existent binary, in the current dir, don't look in PATH)"

# b5+
test_bin $testtmpdir/subdir/bin/subdir \
    "" \
    "" \
    "file ../$binname" \
    "Reading symbols from $binfile\\.\\.\\.done\\..*" \
    "openp b5+ (existing binary, in the upper dir)"

# b5-r
# XXX: locale
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir/bin/subdir \
    "file ../$binname" \
    "\\.\\./$binname: .*" \
    "openp b5-r (non-existent binary, in the upper dir name, don't look in <PATH_dir>/relative)"

# b5-
# XXX: locale
test_bin $testtmpdir/subdir/cwd \
    "" \
    $testtmpdir/subdir/bin \
    "file ../$binname" \
    "\\.\\./$binname: .*" \
    "openp b5- (non-existent binary, in the upper dir name, don't look in <PATH_dir>/basename)"


# s1+
test_src $testtmpdir/subdir/src $srcname $binfile \
    "" \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s1+ (existing source, basename)"

# s1-.
test_src $testtmpdir/subdir/src $srcname $binfile \
    $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s1-. (non-existent source, basename, find in \$cwd/basename)"

# s1-da
test_src $testtmpdir/subdir/src $srcname $binfile \
    $testtmpdir/subdir/dir$testtmpdir/subdir/src \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s1-da (non-existent source, basename, find in <dir>/\$cdir/basename)"

# s1-d
test_src $testtmpdir/subdir/src $srcname $binfile \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s1-d (non-existent source, basename, find in <dir>/basename)"

# s2+
test_src $testtmpdir $srcfile $binfile \
    "" \
    $testtmpdir/subdir/cwd \
    "file $binfile" ""\
    "l main" \
    $src_txt \
    "openp s2+ (existing source, absolute name)"

# s2-.
test_src $testtmpdir $srcfile $binfile \
    $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s2-. (non-existent source, absolute name, find in \$cwd/basename)"

# s2-da
test_src $testtmpdir $srcfile $binfile \
    $testtmpdir/subdir/dir$testtmpdir/subdir/src \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s2-da (non-existent source, absolute name, find in <dir>/absolute)"

# s2-d
test_src $testtmpdir $srcfile $binfile \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s2-d (non-existent source, absolute name, find in <dir>/basename)"

# s3+
test_src $testtmpdir/subdir src/$srcname $binfile \
    "" \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s3+ (existing source, relative name)"

# s3-.r
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir/cwd/src \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s3-.r (non-existent source, relative name, find in \$cwd/relative)"

# s3-c
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s3-c (non-existent source, relative name, find in \$cdir/basename)"

# s3-.
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s3-. (non-existent source, relative name, find in \$cwd/basename)"

# s3-da
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir/dir$testtmpdir/subdir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s3-da (non-existent source, relative name, find in <dir>/\$cdir/relative)"

# s3-dr
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir/dir/src \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s3-dr (non-existent source, relative name, find in <dir>/relative)"

# s3-d
test_src $testtmpdir/subdir src/$srcname $binfile \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s3-d (non-existent source, relative name, find in <dir>/basename)"

# s4+
test_src $testtmpdir/subdir/src ./$srcname $binfile \
    "" \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s4+ (existing source, in the current dir)"

# s4-.
test_src $testtmpdir/subdir/src ./$srcname $binfile \
    $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s4-. (non-existent source, in the current dir, find in \$cwd/basename)"

# s4-da
test_src $testtmpdir/subdir/src ./$srcname $binfile \
    $testtmpdir/subdir/dir$testtmpdir/subdir/src \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s4-da (non-existent source, in the current dir, find in <dir>/\$cdir/basename)"

# s4-d
test_src $testtmpdir/subdir/src ./$srcname $binfile \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s4-d (non-existent source, in the current dir, find in <dir>/basename)"

# s5+
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    "" \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s5+ (existing source, in the upper dir)"

# s5-.r
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s5-.r (non-existent source, in the upper dir, find in \$cwd/relative)"

# s5-c
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir/src/subdir \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s5-c (non-existent source, in the upper dir, find in \$cdir/basename)"

# s5-.
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir/cwd \
    $testtmpdir/subdir/cwd \
    "file $binfile" "" \
    "l main" \
    $src_txt \
    "openp s5-. (non-existent source, in the upper dir, find in \$cdir/basename)"

# s5-da
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir/dir$testtmpdir/subdir/src/subdir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s5-da (non-existent source, in the upper dir, find in <dir>/\$cdir/relative)"

# s5-dr
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s5-dr (non-existent source, in the upper dir, find in <dir>/relative)"

# s5-d
test_src $testtmpdir/subdir/src/subdir ../$srcname $binfile \
    $testtmpdir/subdir/dir \
    $testtmpdir/subdir/cwd \
    "dir $testtmpdir/subdir/dir" "file $binfile" \
    "l main" \
    $src_txt \
    "openp s5-d (non-existent source, in the upper dir, find in <dir>/basename)"

[-- Attachment #3: openp.c --]
[-- Type: text/x-csrc, Size: 22 bytes --]

int main(){return 0;}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-10-15 14:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-02  4:08 Ping: Re: testcase for "absolute source" patch Baurjan Ismagulov
2004-10-12 14:07 ` Michael Chastain
2004-10-15 14:51   ` Baurzhan Ismagulov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox