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 <[email protected]> --- 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)) [email protected]_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 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
