public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix test always passing in python/py-linetable.exp
@ 2014-11-26 18:35 Simon Marchi
  2014-11-26 21:08 ` Sergio Durigan Junior
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2014-11-26 18:35 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

The following test is found in python/py-linetable.exp:

gdb_test "python print sorted(fset)" \
    "\[20L, 21L, 22L, 24L, 25L, 28L, 29L, 30L, 32L, 33L, 37L, 39L, 40L, 42L, 44L, 45L, 46L\].*" \
    "Test frozen set contains line numbers"

I noticed that it passed when using Python 3, even though it should fail
because of the missing parentheses for the call print.

There needs to be more escaping of the square brackets. Currently, it is
interpreted as "any one character from this big list of characters,
followed by .*". When adding the required amount of backslashes, the
test starts failing as it should.

Moreover, both in Python 2.7 and Python 3.3 the numbers don't have the L
suffix, so now the test fails because of that. Anybody knows why they
were there in the first place? I just tested with Python 2.4 and there
are no Ls.

gdb/testsuite/ChangeLog:

	* gdb.python/py-linetable.exp: Properly escape sorted(fset)
	test expected output. Add parentheses for the call to print.
	Remove L suffix from integers.

Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
---
 gdb/testsuite/gdb.python/py-linetable.exp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
index 351f380..5d9b262 100644
--- a/gdb/testsuite/gdb.python/py-linetable.exp
+++ b/gdb/testsuite/gdb.python/py-linetable.exp
@@ -60,8 +60,8 @@ gdb_test "python print (lt.line(1))" "None" \
 # Test gdb.Linetable.sourcelines ()
 gdb_py_test_silent_cmd "python fset = lt.source_lines()" \
     "Get all source lines into a frozen set" 0
-gdb_test "python print sorted(fset)" \
-    "\[20L, 21L, 22L, 24L, 25L, 28L, 29L, 30L, 32L, 33L, 37L, 39L, 40L, 42L, 44L, 45L, 46L\].*" \
+gdb_test "python print (sorted(fset))" \
+    "\\\[20, 21, 22, 24, 25, 28, 29, 30, 32, 33, 37, 39, 40, 42, 44, 45, 46\\\].*" \
     "Test frozen set contains line numbers"
 
 # Test gdb.Linetable.has_line ()
-- 
2.1.3

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

* Re: [PATCH] Fix test always passing in python/py-linetable.exp
  2014-11-26 18:35 [PATCH] Fix test always passing in python/py-linetable.exp Simon Marchi
@ 2014-11-26 21:08 ` Sergio Durigan Junior
  2014-11-27  8:29   ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Sergio Durigan Junior @ 2014-11-26 21:08 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches, Phil Muldoon

On Wednesday, November 26 2014, Simon Marchi wrote:

> The following test is found in python/py-linetable.exp:
>
> gdb_test "python print sorted(fset)" \
>     "\[20L, 21L, 22L, 24L, 25L, 28L, 29L, 30L, 32L, 33L, 37L, 39L, 40L, 42L, 44L, 45L, 46L\].*" \
>     "Test frozen set contains line numbers"
>
> I noticed that it passed when using Python 3, even though it should fail
> because of the missing parentheses for the call print.
>
> There needs to be more escaping of the square brackets. Currently, it is
> interpreted as "any one character from this big list of characters,
> followed by .*". When adding the required amount of backslashes, the
> test starts failing as it should.

Hi Simon,

This fix makes sense to me.  Escaping brackets are always a source of
confusion in TCL.  Thanks for doing that.

> Moreover, both in Python 2.7 and Python 3.3 the numbers don't have the L
> suffix, so now the test fails because of that. Anybody knows why they
> were there in the first place? I just tested with Python 2.4 and there
> are no Ls.

Yeah, I don't know.  My wild guess it that it was a thinko because of
the test just above it:

gdb_test "python list_lines()" \
    "L20 A $hex.*L21 A $hex.*L22 A $hex.*L24 A $hex.*L25 A $hex.*L40 A $hex.*L42 A $hex.*L44 A $hex.*L42 A $hex.*L46 A $hex.*" \
    "test linetable iterator addr"

Phil?

> gdb/testsuite/ChangeLog:
>
> 	* gdb.python/py-linetable.exp: Properly escape sorted(fset)
> 	test expected output. Add parentheses for the call to print.
> 	Remove L suffix from integers.

Two spaces after periods.

>
> Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
> ---
>  gdb/testsuite/gdb.python/py-linetable.exp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
> index 351f380..5d9b262 100644
> --- a/gdb/testsuite/gdb.python/py-linetable.exp
> +++ b/gdb/testsuite/gdb.python/py-linetable.exp
> @@ -60,8 +60,8 @@ gdb_test "python print (lt.line(1))" "None" \
>  # Test gdb.Linetable.sourcelines ()
>  gdb_py_test_silent_cmd "python fset = lt.source_lines()" \
>      "Get all source lines into a frozen set" 0
> -gdb_test "python print sorted(fset)" \
> -    "\[20L, 21L, 22L, 24L, 25L, 28L, 29L, 30L, 32L, 33L, 37L, 39L, 40L, 42L, 44L, 45L, 46L\].*" \
> +gdb_test "python print (sorted(fset))" \
> +    "\\\[20, 21, 22, 24, 25, 28, 29, 30, 32, 33, 37, 39, 40, 42, 44, 45, 46\\\].*" \
>      "Test frozen set contains line numbers"
>  
>  # Test gdb.Linetable.has_line ()
> -- 
> 2.1.3

Other than that, LGTM (not an approval).

Cheers,

-- 
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/

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

* Re: [PATCH] Fix test always passing in python/py-linetable.exp
  2014-11-26 21:08 ` Sergio Durigan Junior
@ 2014-11-27  8:29   ` Joel Brobecker
  2014-11-27 14:28     ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2014-11-27  8:29 UTC (permalink / raw)
  To: Sergio Durigan Junior; +Cc: Simon Marchi, gdb-patches, Phil Muldoon

> This fix makes sense to me.  Escaping brackets are always a source of
> confusion in TCL.  Thanks for doing that.
> 
> > Moreover, both in Python 2.7 and Python 3.3 the numbers don't have the L
> > suffix, so now the test fails because of that. Anybody knows why they
> > were there in the first place? I just tested with Python 2.4 and there
> > are no Ls.
> 
> Yeah, I don't know.  My wild guess it that it was a thinko because of
> the test just above it:
> 
> gdb_test "python list_lines()" \
>     "L20 A $hex.*L21 A $hex.*L22 A $hex.*L24 A $hex.*L25 A $hex.*L40 A $hex.*L42 A $hex.*L44 A $hex.*L42 A $hex.*L46 A $hex.*" \
>     "test linetable iterator addr"
> 
> Phil?
> 
> > gdb/testsuite/ChangeLog:
> >
> > 	* gdb.python/py-linetable.exp: Properly escape sorted(fset)
> > 	test expected output. Add parentheses for the call to print.
> > 	Remove L suffix from integers.
> 
> Two spaces after periods.

Thanks, Sergio, for your review.

I agree that the escaping is OK.

Regarding the issue of the extra 'L' at the end, I think I understand
what happened: The initial patch was using PyLong_FromUnsignedLongLong
to create the line number which, as it name indicates, returns a
Python Long, hence the 'L'. but then, probably prompted by review,
Phil changed it to use gdb_py_object_from_longest which only uses
a long if the value does not fit in an 'int'. But because of the missing
escaping, the change in output was never noticed, and so the test
never got adjusted.

The patch is approved after applying Sergio's comments.

Thanks!
-- 
Joel

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

* Re: [PATCH] Fix test always passing in python/py-linetable.exp
  2014-11-27  8:29   ` Joel Brobecker
@ 2014-11-27 14:28     ` Simon Marchi
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2014-11-27 14:28 UTC (permalink / raw)
  To: Joel Brobecker, Sergio Durigan Junior; +Cc: gdb-patches, Phil Muldoon

On 2014-11-27 03:28 AM, Joel Brobecker wrote:
>> This fix makes sense to me.  Escaping brackets are always a source of
>> confusion in TCL.  Thanks for doing that.
>>
>>> Moreover, both in Python 2.7 and Python 3.3 the numbers don't have the L
>>> suffix, so now the test fails because of that. Anybody knows why they
>>> were there in the first place? I just tested with Python 2.4 and there
>>> are no Ls.
>>
>> Yeah, I don't know.  My wild guess it that it was a thinko because of
>> the test just above it:
>>
>> gdb_test "python list_lines()" \
>>     "L20 A $hex.*L21 A $hex.*L22 A $hex.*L24 A $hex.*L25 A $hex.*L40 A $hex.*L42 A $hex.*L44 A $hex.*L42 A $hex.*L46 A $hex.*" \
>>     "test linetable iterator addr"
>>
>> Phil?
>>
>>> gdb/testsuite/ChangeLog:
>>>
>>> 	* gdb.python/py-linetable.exp: Properly escape sorted(fset)
>>> 	test expected output. Add parentheses for the call to print.
>>> 	Remove L suffix from integers.
>>
>> Two spaces after periods.
> 
> Thanks, Sergio, for your review.
> 
> I agree that the escaping is OK.
> 
> Regarding the issue of the extra 'L' at the end, I think I understand
> what happened: The initial patch was using PyLong_FromUnsignedLongLong
> to create the line number which, as it name indicates, returns a
> Python Long, hence the 'L'. but then, probably prompted by review,
> Phil changed it to use gdb_py_object_from_longest which only uses
> a long if the value does not fit in an 'int'. But because of the missing
> escaping, the change in output was never noticed, and so the test
> never got adjusted.
> 
> The patch is approved after applying Sergio's comments.
> 
> Thanks!

Thanks, pushed with the two spaces fix:

From f28a0564dded48d14df749f11f8ce7638d96db12 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Wed, 26 Nov 2014 13:03:57 -0500
Subject: [PATCH] Fix test always passing in python/py-linetable.exp

The following test is found in python/py-linetable.exp:

gdb_test "python print sorted(fset)" \
    "\[20L, 21L, 22L, 24L, 25L, 28L, 29L, 30L, 32L, 33L, 37L, 39L, 40L, 42L, 44L, 45L, 46L\].*" \
    "Test frozen set contains line numbers"

I noticed that it passed when using Python 3, even though it should fail
because of the missing parentheses for the call print.

There needs to be more escaping of the square brackets. Currently, it is
interpreted as "any one character from this big list of characters,
followed by .*". When adding the required amount of backslashes, the
test starts failing as it should.

Moreover, both in Python 2.7 and Python 3.3 the numbers don't have the L
suffix, so now the test fails because of that. Anybody knows why they
were there in the first place? I just tested with Python 2.4 and there
are no Ls.

gdb/testsuite/ChangeLog:

	* gdb.python/py-linetable.exp: Escape properly sorted(fset)
	test expected output.  Add parentheses for the call to print.
	Remove L suffix from integers.

Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
---
 gdb/testsuite/ChangeLog                   | 6 ++++++
 gdb/testsuite/gdb.python/py-linetable.exp | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a21e88e..16fa87d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2014-11-27  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* gdb.python/py-linetable.exp: Escape properly sorted(fset)
+	test expected output.  Add parentheses for the call to print.
+	Remove L suffix from integers.
+
 2014-11-26  Doug Evans  <dje@google.com>

 	* gdb.dwarf2/dw2-op-out-param.S: Fix comment.
diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
index 682b5b7..2f24ab4 100644
--- a/gdb/testsuite/gdb.python/py-linetable.exp
+++ b/gdb/testsuite/gdb.python/py-linetable.exp
@@ -60,8 +60,8 @@ gdb_test "python print lt.line(1)" "None" \
 # Test gdb.Linetable.sourcelines ()
 gdb_py_test_silent_cmd "python fset = lt.source_lines()" \
     "Get all source lines into a frozen set" 0
-gdb_test "python print sorted(fset)" \
-    "\[20L, 21L, 22L, 24L, 25L, 28L, 29L, 30L, 32L, 33L, 37L, 39L, 40L, 42L, 44L, 45L, 46L\].*" \
+gdb_test "python print (sorted(fset))" \
+    "\\\[20, 21, 22, 24, 25, 28, 29, 30, 32, 33, 37, 39, 40, 42, 44, 45, 46\\\].*" \
     "Test frozen set contains line numbers"

 # Test gdb.Linetable.has_line ()
-- 
2.1.3

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

end of thread, other threads:[~2014-11-27 14:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-26 18:35 [PATCH] Fix test always passing in python/py-linetable.exp Simon Marchi
2014-11-26 21:08 ` Sergio Durigan Junior
2014-11-27  8:29   ` Joel Brobecker
2014-11-27 14:28     ` Simon Marchi

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).