diff mbox

[piglit] igt: Make "warn" status work again as expected.

Message ID 571633B0.1080804@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Maarten Lankhorst April 19, 2016, 1:33 p.m. UTC
When writing a patch that adds a igt_warn() when lockdep is unavailable
I noticed that the warn error doesn't work any more. Fix this by monitoring
stderr, and only setting 'pass' when stderr is empty.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Dylan Baker <baker.dylan.c@gmail.com>
---

Comments

Dylan Baker April 19, 2016, 6:13 p.m. UTC | #1
Quoting Maarten Lankhorst (2016-04-19 06:33:36)
> When writing a patch that adds a igt_warn() when lockdep is unavailable
> I noticed that the warn error doesn't work any more. Fix this by monitoring
> stderr, and only setting 'pass' when stderr is empty.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Dylan Baker <baker.dylan.c@gmail.com>
> ---
> diff --git a/tests/igt.py b/tests/igt.py
> index 7ebb03646b50..1e5d2f111fa6 100644
> --- a/tests/igt.py
> +++ b/tests/igt.py
> @@ -114,7 +114,9 @@ class IGTTest(Test):
>      def interpret_result(self):
>          super(IGTTest, self).interpret_result()
>  
> -        if self.result.returncode == 0:
> +        if self.result.returncode == 0 and len(self.result.err) > 0:

I think this would be cleaner as:
if self.result.returncode == 0:
    if self.result.err:
        self.result.result = 'warn'
    else:
        self.result.result = 'pass'

Since that avoids checking the returncode twice, and avoids calling len
on a possibly quite large string.

Note that in python an empty string, False, None, 0, an empty container
(dict, list, set, etc) will automatically fail an if statement, without
having to additionally call len() on the item.

> +            self.result.result = 'warn'
> +        elif self.result.returncode == 0:
>              self.result.result = 'pass'
>          elif self.result.returncode == 77:
>              self.result.result = 'skip'
> 

With that change you have my rb,
Reviewed-by: Dylan Baker <baker.dylan.c@gmail.com>
diff mbox

Patch

diff --git a/tests/igt.py b/tests/igt.py
index 7ebb03646b50..1e5d2f111fa6 100644
--- a/tests/igt.py
+++ b/tests/igt.py
@@ -114,7 +114,9 @@  class IGTTest(Test):
     def interpret_result(self):
         super(IGTTest, self).interpret_result()
 
-        if self.result.returncode == 0:
+        if self.result.returncode == 0 and len(self.result.err) > 0:
+            self.result.result = 'warn'
+        elif self.result.returncode == 0:
             self.result.result = 'pass'
         elif self.result.returncode == 77:
             self.result.result = 'skip'