Am Donnerstag, 9. April 2015, 00:29:05 schrieb Ander Juaristi:
> Hi,
>
> I usually find useful to run Wget through gdb while running the tests, so
> that I can see in real time how Wget performs internally under the test.
> Here's what I do:
>
> 1. In WgetTests.pm, make WGETPATH point to gdb:
>
> our $WGETPATH = '/usr/bin/gdb';
>
> 2. Pick some test and change the cmdline:
>
> my $cmdline = $WgetTest::WGETPATH . " ~/path/to/my/wget";
>
> 3. Run the test normally:
>
> $ ./Test-iri-disabled.px
> (gdb) break url_parse
>
> 4. Figure out which port is the Perl HTTP server listening on:
>
> $ netstat -lp | grep perl | awk '{ print $4 }' | cut -d: -f2
>
> 5. Run Wget, and let it pass the test, while stopping at breakpoints,
> viewing variables, etc:
>
> (gdb) run --no-iri -nH -r http://localhost:<port>
>
> And I feel smart and happy this way :D
>
> But I wonder if there's a not-so-hackish way of wrapping Wget into gdb when
> running the tests. I mean, is there a feature in the tests themselves that
> allows this? Would be a great feature.
Hi Ander,
attached is a (experimental) patch that allows you to
$ cd tests
$ GDB_TESTS=1 ./Test--spider.px
If you successfully test it, you might also add GDB_TESTS to the python test
suite and send a git-format patch to the list for reviewing.
Regards, Tim
diff --git a/tests/WgetTests.pm b/tests/WgetTests.pm
index 5dd5214..445f8e3 100644
--- a/tests/WgetTests.pm
+++ b/tests/WgetTests.pm
@@ -114,10 +114,20 @@ sub run
($cmdline =~ m{^/.*}msx) ? $cmdline : "$self->{_workdir}/$cmdline";
my $valgrind = $ENV{VALGRIND_TESTS};
- if (!defined $valgrind || $valgrind eq q{} || $valgrind == 0)
+ if (!defined $valgrind)
{
+ $valgrind = 0;
+ }
+
+ my $gdb = $ENV{GDB_TESTS};
+ if (!defined $gdb)
+ {
+ $gdb = 0;
+ }
- # Valgrind not requested - leave $cmdline as it is
+ if ($gdb == 1)
+ {
+ $cmdline = 'gdb --args ' . $cmdline;
}
elsif ($valgrind == 1)
{
@@ -125,7 +135,7 @@ sub run
'valgrind --suppressions=../../valgrind-suppressions --error-exitcode=301 --leak-check=yes --track-origins=yes '
. $cmdline;
}
- else
+ elsif ($valgrind ne q{} && $valgrind != 0)
{
$cmdline = "$valgrind $cmdline";
}