[Piglit] [PATCH 14/20] framework/tests: Add sudo to the names of privileged tests

Dylan Baker baker.dylan.c at gmail.com
Sat Jun 14 08:05:23 PDT 2014


This makes it very easy to exclude only the tests that use sudo, so
running "nostests framework/tests -e sudo" will run all tests except
the ones that need privileged support.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 framework/tests/dmesg_tests.py |  3 ++-
 framework/tests/utils.py       | 13 +++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/framework/tests/dmesg_tests.py b/framework/tests/dmesg_tests.py
index 166f98f..acdce7b 100644
--- a/framework/tests/dmesg_tests.py
+++ b/framework/tests/dmesg_tests.py
@@ -113,7 +113,7 @@ def test_get_dmesg_linux():
                      "but it actually returned {}".format(type(posix)))
 
 
-def test_update_dmesg():
+def sudo_test_update_dmesg():
     """ Tests that update_dmesg actually updates
 
     This will skip on non-Posix systems, since there is no way to actually test
@@ -186,6 +186,7 @@ def test_dmesg_wrap_complete():
                                   dmesg._new_messages))
 
 
+ at utils.privileged_test
 @utils.nose_generator
 def test_update_result_replace():
     """ Generates tests for update_result """
diff --git a/framework/tests/utils.py b/framework/tests/utils.py
index e4a6cd4..8e1e3c8 100644
--- a/framework/tests/utils.py
+++ b/framework/tests/utils.py
@@ -164,3 +164,16 @@ def nose_generator(func):
             yield tuple(x)  # This must be a tuple for some reason
 
     return test_wrapper
+
+
+def privileged_test(func):
+    """ Wrapper to name the tests as sudo
+
+    This makes the name of the function contain sudo, which is useful for
+    excluding tests with privileged execution requirements
+
+    """
+    def sudo_wrapper(*args, **kwargs):
+        func(*args, **kwargs)
+
+    return sudo_wrapper
-- 
2.0.0



More information about the Piglit mailing list