zdtm.py --keep-going output

Submitted by Andrey Vagin on March 20, 2018, 10:01 p.m.

Details

Message ID 20180320220134.GA8003@outlook.office365.com
State New
Series "zdtm.py --keep-going output"
Headers show

Commit Message

Andrey Vagin March 20, 2018, 10:01 p.m.
On Tue, Mar 20, 2018 at 05:02:36PM +0100, Adrian Reber wrote:
> Hello Andrei,
> 
> I just saw that the --keep-going output has switched back to printing
> 
>  * testname(unkown)
> 
> instead of:
> 
>      ################### 2 TEST(S) FAILED (TOTAL 297/SKIPPED 34) ####################
>       * zdtm/static/sched_policy00(ns)
>       * zdtm/static/cgroup02(h)
>      ##################################### FAIL #####################################
> 
> This is caused by your commit:
> 
> commit 5785dbd93dec20f56a89245b94f6fde28cd098ac
> Author: Andrei Vagin <avagin@virtuozzo.com>
> Date:   Thu Oct 26 00:27:43 2017 +0300
> 
>     zdtm.py: fix decode_flav()
>     
>     Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
> 
> diff --git a/test/zdtm.py b/test/zdtm.py
> index efed134..d3e0c9a 100755
> --- a/test/zdtm.py
> +++ b/test/zdtm.py
> @@ -293,7 +293,7 @@ def encode_flav(f):
>  
>  
>  def decode_flav(i):
> -       return flavors.keys().get([i - 128], "unknown")
> +       return flavors.get(i - 128, "unknown")
>  
>  
>  def tail(path):
> 
> decode_flav was already changed from the working code with commit
> 
> commit c9ca83f05ae30810bd90e092dfc98fa7afe310b9
> Author: Andrei Vagin <avagin@openvz.org>
> Date:   Mon Oct 23 09:57:48 2017 -0700
> 
> 
> The get() method requires a key and now we are using an index. That
> will never work correctly as it is now.
> 
> Any reasons for your change? Or could we change it back?

The reason was described in the commit message of c9ca83f05a:

    test/zdtm.py:181:4: E722 do not use bare except'

I'm agree that my fix was incorrect. We can return the origin code and
specify the IndexError exception, ot we can fix this by this way:



> 
> 		Adrian

Patch hide | download patch | download mbox

diff --git a/test/zdtm.py b/test/zdtm.py
index 030065dde..6ec0fe88d 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -289,18 +289,18 @@  class userns_flavor(ns_flavor):
 
 
 flavors = {'h': host_flavor, 'ns': ns_flavor, 'uns': userns_flavor}
-
+flavors_codes = dict(zip(xrange(len(flavors)), sorted(flavors.keys())))
 #
 # Helpers
 #
 
 
 def encode_flav(f):
-       return (flavors.keys().index(f) + 128)
+       return sorted(flavors.keys()).index(f) + 128
 
 
 def decode_flav(i):
-       return flavors.get(i - 128, "unknown")
+       return flavors_codes.get(i - 128, "unknown")
 
 
 def tail(path):

Comments

Adrian Reber March 21, 2018, 1:48 p.m.
On Tue, Mar 20, 2018 at 03:01:34PM -0700, Andrei Vagin wrote:
> On Tue, Mar 20, 2018 at 05:02:36PM +0100, Adrian Reber wrote:
> > Hello Andrei,
> > 
> > I just saw that the --keep-going output has switched back to printing
> > 
> >  * testname(unkown)
> > 
> > instead of:
> > 
> >      ################### 2 TEST(S) FAILED (TOTAL 297/SKIPPED 34) ####################
> >       * zdtm/static/sched_policy00(ns)
> >       * zdtm/static/cgroup02(h)
> >      ##################################### FAIL #####################################
> > 
> > This is caused by your commit:
> > 
> > commit 5785dbd93dec20f56a89245b94f6fde28cd098ac
> > Author: Andrei Vagin <avagin@virtuozzo.com>
> > Date:   Thu Oct 26 00:27:43 2017 +0300
> > 
> >     zdtm.py: fix decode_flav()
> >     
> >     Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
> > 
> > diff --git a/test/zdtm.py b/test/zdtm.py
> > index efed134..d3e0c9a 100755
> > --- a/test/zdtm.py
> > +++ b/test/zdtm.py
> > @@ -293,7 +293,7 @@ def encode_flav(f):
> >  
> >  
> >  def decode_flav(i):
> > -       return flavors.keys().get([i - 128], "unknown")
> > +       return flavors.get(i - 128, "unknown")
> >  
> >  
> >  def tail(path):
> > 
> > decode_flav was already changed from the working code with commit
> > 
> > commit c9ca83f05ae30810bd90e092dfc98fa7afe310b9
> > Author: Andrei Vagin <avagin@openvz.org>
> > Date:   Mon Oct 23 09:57:48 2017 -0700
> > 
> > 
> > The get() method requires a key and now we are using an index. That
> > will never work correctly as it is now.
> > 
> > Any reasons for your change? Or could we change it back?
> 
> The reason was described in the commit message of c9ca83f05a:
> 
>     test/zdtm.py:181:4: E722 do not use bare except'
> 
> I'm agree that my fix was incorrect. We can return the origin code and
> specify the IndexError exception, ot we can fix this by this way:

That patch works for me. If you want to apply/submit it, you can add my
acked-by.

		Adrian

> diff --git a/test/zdtm.py b/test/zdtm.py
> index 030065dde..6ec0fe88d 100755
> --- a/test/zdtm.py
> +++ b/test/zdtm.py
> @@ -289,18 +289,18 @@ class userns_flavor(ns_flavor):
>  
>  
>  flavors = {'h': host_flavor, 'ns': ns_flavor, 'uns': userns_flavor}
> -
> +flavors_codes = dict(zip(xrange(len(flavors)), sorted(flavors.keys())))
>  #
>  # Helpers
>  #
>  
>  
>  def encode_flav(f):
> -       return (flavors.keys().index(f) + 128)
> +       return sorted(flavors.keys()).index(f) + 128
>  
>  
>  def decode_flav(i):
> -       return flavors.get(i - 128, "unknown")
> +       return flavors_codes.get(i - 128, "unknown")
>  
>  
>  def tail(path):
> 
> 
> > 
> > 		Adrian
Andrey Vagin March 22, 2018, 10:05 p.m.
On Wed, Mar 21, 2018 at 02:48:21PM +0100, Adrian Reber wrote:
> On Tue, Mar 20, 2018 at 03:01:34PM -0700, Andrei Vagin wrote:
> > On Tue, Mar 20, 2018 at 05:02:36PM +0100, Adrian Reber wrote:
> > > Hello Andrei,
> > > 
> > > I just saw that the --keep-going output has switched back to printing
> > > 
> > >  * testname(unkown)
> > > 
> > > instead of:
> > > 
> > >      ################### 2 TEST(S) FAILED (TOTAL 297/SKIPPED 34) ####################
> > >       * zdtm/static/sched_policy00(ns)
> > >       * zdtm/static/cgroup02(h)
> > >      ##################################### FAIL #####################################
> > > 
> > > This is caused by your commit:
> > > 
> > > commit 5785dbd93dec20f56a89245b94f6fde28cd098ac
> > > Author: Andrei Vagin <avagin@virtuozzo.com>
> > > Date:   Thu Oct 26 00:27:43 2017 +0300
> > > 
> > >     zdtm.py: fix decode_flav()
> > >     
> > >     Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
> > > 
> > > diff --git a/test/zdtm.py b/test/zdtm.py
> > > index efed134..d3e0c9a 100755
> > > --- a/test/zdtm.py
> > > +++ b/test/zdtm.py
> > > @@ -293,7 +293,7 @@ def encode_flav(f):
> > >  
> > >  
> > >  def decode_flav(i):
> > > -       return flavors.keys().get([i - 128], "unknown")
> > > +       return flavors.get(i - 128, "unknown")
> > >  
> > >  
> > >  def tail(path):
> > > 
> > > decode_flav was already changed from the working code with commit
> > > 
> > > commit c9ca83f05ae30810bd90e092dfc98fa7afe310b9
> > > Author: Andrei Vagin <avagin@openvz.org>
> > > Date:   Mon Oct 23 09:57:48 2017 -0700
> > > 
> > > 
> > > The get() method requires a key and now we are using an index. That
> > > will never work correctly as it is now.
> > > 
> > > Any reasons for your change? Or could we change it back?
> > 
> > The reason was described in the commit message of c9ca83f05a:
> > 
> >     test/zdtm.py:181:4: E722 do not use bare except'
> > 
> > I'm agree that my fix was incorrect. We can return the origin code and
> > specify the IndexError exception, ot we can fix this by this way:
> 
> That patch works for me. If you want to apply/submit it, you can add my
> acked-by.

Done. Thank you for reporting this issue.

> 
> 		Adrian
> 
> > diff --git a/test/zdtm.py b/test/zdtm.py
> > index 030065dde..6ec0fe88d 100755
> > --- a/test/zdtm.py
> > +++ b/test/zdtm.py
> > @@ -289,18 +289,18 @@ class userns_flavor(ns_flavor):
> >  
> >  
> >  flavors = {'h': host_flavor, 'ns': ns_flavor, 'uns': userns_flavor}
> > -
> > +flavors_codes = dict(zip(xrange(len(flavors)), sorted(flavors.keys())))
> >  #
> >  # Helpers
> >  #
> >  
> >  
> >  def encode_flav(f):
> > -       return (flavors.keys().index(f) + 128)
> > +       return sorted(flavors.keys()).index(f) + 128
> >  
> >  
> >  def decode_flav(i):
> > -       return flavors.get(i - 128, "unknown")
> > +       return flavors_codes.get(i - 128, "unknown")
> >  
> >  
> >  def tail(path):
> > 
> > 
> > > 
> > > 		Adrian