public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pph] New script to reproduce failures from a .log file (issue4601050)
@ 2011-06-09 18:40 Diego Novillo
  2011-06-09 21:27 ` Lawrence Crowl
  0 siblings, 1 reply; 4+ messages in thread
From: Diego Novillo @ 2011-06-09 18:40 UTC (permalink / raw)
  To: reply, gchare, crowl, gcc-patches

This small script searches for the spawn line corresponding to a given
grep pattern inside a dejagnu log file.  If it finds the spawn line,
it executes it with any other arguments provided on the command line.

It's generally useful for cutting and pasting failed test cases.  I did
not find anything close to it in gcc/contrib, so I will be adding it
to trunk shortly.

Gab, Lawrence, this ought to simplify reproducing pph failures from
g++.log.  Feel free to add more functionality to it, or use it to
find writer and reader pairs in the log file and execute them separately.


Diego.


	* repro_fail: New.

diff --git a/contrib/repro_fail b/contrib/repro_fail
new file mode 100755
index 0000000..d5bce04
--- /dev/null
+++ b/contrib/repro_fail
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Script to reproduce a test failure from a dejagnu .log file
+#
+# Contributed by Diego Novillo <dnovillo@google.com>
+#
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC 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 3, or (at your option)
+# any later version.
+#
+# GCC 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 GCC; see the file COPYING.  If not, write to
+# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+if [ $# -lt 2 ] ; then
+    echo "usage: $0 pattern file.log [additional-args]"
+    echo
+    echo "Finds the 'spawn' line matching PATTERN in FILE.LOG and executes"
+    echo "the command with any arguments in ADDITIONAL-ARGS."
+    echo
+    exit 1
+fi
+
+set -e
+pattern=$1
+logf=$2
+shift 2
+args="$@"
+line=$(grep "^spawn .*$pattern" $logf | sed -e "s:^spawn ::")
+
+if [ "$line" = "" ] ; then
+    echo "Could not find a spawn command for pattern $1"
+    exit 1
+fi
+
+set -x +e
+$line $args
+exit $?

--
This patch is available for review at http://codereview.appspot.com/4601050

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

* Re: [pph] New script to reproduce failures from a .log file (issue4601050)
  2011-06-09 18:40 [pph] New script to reproduce failures from a .log file (issue4601050) Diego Novillo
@ 2011-06-09 21:27 ` Lawrence Crowl
  2011-06-09 22:08   ` Diego Novillo
  2011-06-10  6:36   ` Alexandre Oliva
  0 siblings, 2 replies; 4+ messages in thread
From: Lawrence Crowl @ 2011-06-09 21:27 UTC (permalink / raw)
  To: Diego Novillo; +Cc: reply, gchare, gcc-patches

On 6/9/11, Diego Novillo <dnovillo@google.com> wrote:
> This small script searches for the spawn line corresponding to a given
> grep pattern inside a dejagnu log file.  If it finds the spawn line,
> it executes it with any other arguments provided on the command line.
>
> It's generally useful for cutting and pasting failed test cases.  I did
> not find anything close to it in gcc/contrib, so I will be adding it
> to trunk shortly.
>
> Gab, Lawrence, this ought to simplify reproducing pph failures from
> g++.log.  Feel free to add more functionality to it, or use it to
> find writer and reader pairs in the log file and execute them separately.
>
>
> Diego.
>
>
> 	* repro_fail: New.
>
> diff --git a/contrib/repro_fail b/contrib/repro_fail
> new file mode 100755
> index 0000000..d5bce04
> --- /dev/null
> +++ b/contrib/repro_fail
> @@ -0,0 +1,49 @@
> +#!/bin/bash
> +#
> +# Script to reproduce a test failure from a dejagnu .log file
> +#
> +# Contributed by Diego Novillo <dnovillo@google.com>
> +#
> +# Copyright (C) 2011 Free Software Foundation, Inc.
> +#
> +# This file is part of GCC.
> +#
> +# GCC 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 3, or (at your option)
> +# any later version.
> +#
> +# GCC 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 GCC; see the file COPYING.  If not, write to
> +# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
> +# Boston, MA 02110-1301, USA.
> +
> +if [ $# -lt 2 ] ; then
> +    echo "usage: $0 pattern file.log [additional-args]"
> +    echo
> +    echo "Finds the 'spawn' line matching PATTERN in FILE.LOG and executes"
> +    echo "the command with any arguments in ADDITIONAL-ARGS."
> +    echo
> +    exit 1
> +fi
> +
> +set -e
> +pattern=$1
> +logf=$2
> +shift 2
> +args="$@"
> +line=$(grep "^spawn .*$pattern" $logf | sed -e "s:^spawn ::")

line=$(sed -e "/^spawn .*$pattern/ ! d ; s/^spawn //" $logf)

Has one fewer process and one fewer pipe.  Sed is your friend.

I think this code fails when multiple lines match the pattern.
Pipe through head?

> +
> +if [ "$line" = "" ] ; then
> +    echo "Could not find a spawn command for pattern $1"
> +    exit 1
> +fi
> +
> +set -x +e
> +$line $args
> +exit $?
>
> --
> This patch is available for review at http://codereview.appspot.com/4601050
>


-- 
Lawrence Crowl

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

* Re: [pph] New script to reproduce failures from a .log file (issue4601050)
  2011-06-09 21:27 ` Lawrence Crowl
@ 2011-06-09 22:08   ` Diego Novillo
  2011-06-10  6:36   ` Alexandre Oliva
  1 sibling, 0 replies; 4+ messages in thread
From: Diego Novillo @ 2011-06-09 22:08 UTC (permalink / raw)
  To: Lawrence Crowl; +Cc: reply, Gabriel Charette, gcc-patches

On Thu, Jun 9, 2011 at 13:48, Lawrence Crowl <crowl@google.com> wrote:

>
> line=$(sed -e "/^spawn .*$pattern/ ! d ; s/^spawn //" $logf)
>
> Has one fewer process and one fewer pipe.  Sed is your friend.

sed and I have a complicated relationship.  But, sure :)

> I think this code fails when multiple lines match the pattern.
> Pipe through head?

Yup.  It does.

I'm sure there will be other things, it's in contrib/ now.  I'll wait
until we've used it and expanded it a bit more and move it to trunk.


Diego.

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

* Re: [pph] New script to reproduce failures from a .log file (issue4601050)
  2011-06-09 21:27 ` Lawrence Crowl
  2011-06-09 22:08   ` Diego Novillo
@ 2011-06-10  6:36   ` Alexandre Oliva
  1 sibling, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2011-06-10  6:36 UTC (permalink / raw)
  To: Lawrence Crowl; +Cc: Diego Novillo, reply, gchare, gcc-patches

On Jun  9, 2011, Lawrence Crowl <crowl@google.com> wrote:

> On 6/9/11, Diego Novillo <dnovillo@google.com> wrote:
>> +args="$@"

I'd keep args in "$@" and use "$@" instead of $args, so as to avoid
quoting issues.

>> +line=$(grep "^spawn .*$pattern" $logf | sed -e "s:^spawn ::")

> line=$(sed -e "/^spawn .*$pattern/ ! d ; s/^spawn //" $logf)

> Has one fewer process and one fewer pipe.  Sed is your friend.

I'd have written sed -n "s/^spawn \(.*$pattern\)/\1/p", but I'm not sure
it's more efficient.

It would be wise to first quote slashes in the pattern:

pattern=`echo "$pattern" | sed 's:/:\\/:g'`

>> +if [ "$line" = "" ] ; then

[ -z "$line" ]

Thanks, Diego,

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

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

end of thread, other threads:[~2011-06-10  4:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-09 18:40 [pph] New script to reproduce failures from a .log file (issue4601050) Diego Novillo
2011-06-09 21:27 ` Lawrence Crowl
2011-06-09 22:08   ` Diego Novillo
2011-06-10  6:36   ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).