[Piglit] [PATCH 1/3] Adds piglit framework test to test GleanTest.globalParams bug

Dylan Baker baker.dylan.c at gmail.com
Tue Jan 14 15:48:43 PST 2014


This patch adds a framework test to show the problem with
GleanTest.globalParams. It makes use of nose, a python testing
framework, which is simple to write tests for, and is in widespread
usage for testing python code.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 README                       |  2 ++
 framework/gleantest_tests.py | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 framework/gleantest_tests.py

diff --git a/README b/README
index 13f1202..dbebc5a 100644
--- a/README
+++ b/README
@@ -36,6 +36,8 @@ First of all, you need to make sure that the following are installed:
   - GL, glu and glut libraries and development packages (i.e. headers)
   - X11 libraries and development packages (i.e. headers)
   - waffle (http://people.freedesktop.org/~chadversary/waffle)
+  - nose. Only needed for python framework tests
+    (https://nose.readthedocs.org/en/latest/)
 
 Now configure the build system:
 
diff --git a/framework/gleantest_tests.py b/framework/gleantest_tests.py
new file mode 100644
index 0000000..ba2c3a5
--- /dev/null
+++ b/framework/gleantest_tests.py
@@ -0,0 +1,43 @@
+# Copyright (c) 2014 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+
+""" Tests for the glean class. Requires Nose """
+
+from framework.gleantest import GleanTest
+
+
+def test_globalParams_assignment():
+    """ Test to ensure that GleanTest.globalParams are correctly assigned
+
+    Specifically this tests for a bug where globalParams only affected
+    instances of GleanTest created after globalParams were set, so changing the
+    globalParams value had unexpected results.
+
+    If this test passes the GleanTest.command attributes will be the same in
+    the instance created before the globalParams assignment and the one created
+    after. A failure means the that globalParams are not being added to tests
+    initialized before it is set.
+
+    """
+    test1 = GleanTest('basic')
+    GleanTest.globalParams = ['--quick']
+    test2 = GleanTest('basic')
+    assert test1.command == test2.command
-- 
1.8.5.2



More information about the Piglit mailing list