All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] device-crash-test: Convert to Python 3
@ 2019-01-16 18:33 Nisarg Shah
  2019-01-23 18:50 ` Eduardo Habkost
  0 siblings, 1 reply; 3+ messages in thread
From: Nisarg Shah @ 2019-01-16 18:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, ehabkost, Nisarg Shah

Apply 2to3 tool to scripts/device-crash-test.
Restrict whitelist entry stats in debug mode to be sorted only by "count", since Python 3 does
not implicitly support comparing dictionaries.

Signed-off-by: Nisarg Shah <nshah@disroot.org>
---
 scripts/device-crash-test | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scripts/device-crash-test b/scripts/device-crash-test
index e93a7c0c84..ecdc9828c2 100755
--- a/scripts/device-crash-test
+++ b/scripts/device-crash-test
@@ -23,7 +23,7 @@
 Run QEMU with all combinations of -machine and -device types,
 check for crashes and unexpected errors.
 """
-from __future__ import print_function
+
 
 import sys
 import os
@@ -272,7 +272,7 @@ def qemuOptsEscape(s):
 
 def formatTestCase(t):
     """Format test case info as "key=value key=value" for prettier logging output"""
-    return ' '.join('%s=%s' % (k, v) for k, v in t.items())
+    return ' '.join('%s=%s' % (k, v) for k, v in list(t.items()))
 
 
 def qomListTypeNames(vm, **kwargs):
@@ -574,7 +574,8 @@ def main():
         logger.info("Skipped %d test cases", skipped)
 
     if args.debug:
-        stats = sorted([(len(wl_stats.get(i, [])), wl) for i, wl in enumerate(ERROR_WHITELIST)])
+        stats = sorted([(len(wl_stats.get(i, [])), wl) for i, wl in
+                         enumerate(ERROR_WHITELIST)], key=lambda x: x[0])
         for count, wl in stats:
             dbg("whitelist entry stats: %d: %r", count, wl)
 
-- 
2.19.2

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

* Re: [Qemu-devel] [PATCH] device-crash-test: Convert to Python 3
  2019-01-16 18:33 [Qemu-devel] [PATCH] device-crash-test: Convert to Python 3 Nisarg Shah
@ 2019-01-23 18:50 ` Eduardo Habkost
  2019-01-30 18:00   ` Nisarg Shah
  0 siblings, 1 reply; 3+ messages in thread
From: Eduardo Habkost @ 2019-01-23 18:50 UTC (permalink / raw)
  To: Nisarg Shah; +Cc: qemu-devel, qemu-trivial

On Thu, Jan 17, 2019 at 12:03:58AM +0530, Nisarg Shah wrote:
> Apply 2to3 tool to scripts/device-crash-test.
> Restrict whitelist entry stats in debug mode to be sorted only by "count", since Python 3 does
> not implicitly support comparing dictionaries.

Thanks for the patch.  Comments below:

> 
> Signed-off-by: Nisarg Shah <nshah@disroot.org>
> ---
>  scripts/device-crash-test | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/device-crash-test b/scripts/device-crash-test
> index e93a7c0c84..ecdc9828c2 100755
> --- a/scripts/device-crash-test
> +++ b/scripts/device-crash-test
> @@ -23,7 +23,7 @@
>  Run QEMU with all combinations of -machine and -device types,
>  check for crashes and unexpected errors.
>  """
> -from __future__ import print_function
> +

This breaks Python 2 support:

$ python2 scripts/device-crash-test
  File "scripts/device-crash-test", line 534
    print("No QEMU binary found", file=sys.stderr)
                                      ^
SyntaxError: invalid syntax


>  
>  import sys
>  import os
> @@ -272,7 +272,7 @@ def qemuOptsEscape(s):
>  
>  def formatTestCase(t):
>      """Format test case info as "key=value key=value" for prettier logging output"""
> -    return ' '.join('%s=%s' % (k, v) for k, v in t.items())
> +    return ' '.join('%s=%s' % (k, v) for k, v in list(t.items()))

Why is this necessary?


>  
>  
>  def qomListTypeNames(vm, **kwargs):
> @@ -574,7 +574,8 @@ def main():
>          logger.info("Skipped %d test cases", skipped)
>  
>      if args.debug:
> -        stats = sorted([(len(wl_stats.get(i, [])), wl) for i, wl in enumerate(ERROR_WHITELIST)])
> +        stats = sorted([(len(wl_stats.get(i, [])), wl) for i, wl in
> +                         enumerate(ERROR_WHITELIST)], key=lambda x: x[0])

This seems to be the only change that is described in the commit
message.  I'm applying this hunk after editing the commit message
as shown below.

---
>From 9793d7e7874d944d115ab9ab933b02f8de793460 Mon Sep 17 00:00:00 2001
From: Nisarg Shah <nshah@disroot.org>
Date: Thu, 17 Jan 2019 00:03:58 +0530
Subject: [PATCH] device-crash-test: Python 3 compatibility fix

Restrict whitelist entry stats in debug mode to be sorted only by
"count", since Python 3 does not implicitly support comparing
dictionaries.

Signed-off-by: Nisarg Shah <nshah@disroot.org>
Message-Id: <20190116183358.30287-1-nshah@disroot.org>
[ehabkost: removed 2 unnecessary hunks from patch]
[ehabkost: edited commit message]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 scripts/device-crash-test | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/device-crash-test b/scripts/device-crash-test
index 483dafb2fc..2a13fa4f84 100755
--- a/scripts/device-crash-test
+++ b/scripts/device-crash-test
@@ -557,7 +557,8 @@ def main():
         logger.info("Skipped %d test cases", skipped)
 
     if args.debug:
-        stats = sorted([(len(wl_stats.get(i, [])), wl) for i, wl in enumerate(ERROR_WHITELIST)])
+        stats = sorted([(len(wl_stats.get(i, [])), wl) for i, wl in
+                         enumerate(ERROR_WHITELIST)], key=lambda x: x[0])
         for count, wl in stats:
             dbg("whitelist entry stats: %d: %r", count, wl)
 
-- 
2.18.0.rc1.1.g3f1ff2140

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH] device-crash-test: Convert to Python 3
  2019-01-23 18:50 ` Eduardo Habkost
@ 2019-01-30 18:00   ` Nisarg Shah
  0 siblings, 0 replies; 3+ messages in thread
From: Nisarg Shah @ 2019-01-30 18:00 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: qemu-trivial, qemu-devel

Thanks for the review.

On 1/24/19 12:20 AM, Eduardo Habkost wrote:
> 
> This breaks Python 2 support:
> 
> $ python2 scripts/device-crash-test
>    File "scripts/device-crash-test", line 534
>      print("No QEMU binary found", file=sys.stderr)
>                                        ^
> SyntaxError: invalid syntax
> 
> 
Apologies. This is my first patch to qemu and I did not consider 
backward compatibility with Python 2. I'll see if I can fix this.
>>   
>>   import sys
>>   import os
>> @@ -272,7 +272,7 @@ def qemuOptsEscape(s):
>>   
>>   def formatTestCase(t):
>>       """Format test case info as "key=value key=value" for prettier logging output"""
>> -    return ' '.join('%s=%s' % (k, v) for k, v in t.items())
>> +    return ' '.join('%s=%s' % (k, v) for k, v in list(t.items()))
> 
> Why is this necessary?
> 
> 
This was automatically modified by the 2to3 tool. I see that it is not 
really required.

Regards,
Nisarg

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

end of thread, other threads:[~2019-01-30 18:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16 18:33 [Qemu-devel] [PATCH] device-crash-test: Convert to Python 3 Nisarg Shah
2019-01-23 18:50 ` Eduardo Habkost
2019-01-30 18:00   ` Nisarg Shah

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.