gst-qa-system: Parent Scenarios optionally name subtests

Edward Hervey bilboed at kemper.freedesktop.org
Tue Sep 20 03:40:25 PDT 2011


Module: gst-qa-system
Branch: master
Commit: d17a6823fa4f4f7fa331c19557c0c95bbfc5a4a7
URL:    http://cgit.freedesktop.org/gstreamer/gst-qa-system/commit/?id=d17a6823fa4f4f7fa331c19557c0c95bbfc5a4a7

Author: David Laban <david.laban at collabora.co.uk>
Date:   Wed Sep  7 19:28:32 2011 +0100

Parent Scenarios optionally name subtests

This is done by adding a bogus "instance-name" arg to the Test baseclass.
Default name is: ${i}.${testclass.__test_name__}.

It should be possible examine the db and re-create a name of the form:
${basename(uri)}.${parent_scenario}.${subtest}

---

 insanity/scenario.py |   21 ++++++++++++++++-----
 insanity/test.py     |    5 ++++-
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/insanity/scenario.py b/insanity/scenario.py
index fdf4f31..a27b935 100644
--- a/insanity/scenario.py
+++ b/insanity/scenario.py
@@ -50,6 +50,7 @@ class Scenario(Test):
             return False
         self._tests = [] # list of (test, args, monitors)
         self.tests = [] # executed tests
+        self._n_tests = 0
 
         # FIXME : asynchronous starts ???
         return True
@@ -76,12 +77,14 @@ class Scenario(Test):
 
     def _startNextSubTest(self):
         try:
-            testclass, args, monitors = self._tests.pop(0)
+            testclass, args, monitors, instance_name = self._tests.pop(0)
             if not 'bus' in args.keys():
                 args["bus"] = self.arguments.get("bus")
             if not 'bus_address' in args.keys():
                 args["bus_address"] = self.arguments.get("bus_address")
-            debug("About to create subtest %r with arguments %r", testclass, args)
+            debug("About to create subtest %r (instance_name=%r) "
+                  "with arguments %r", testclass, instance_name, args)
+            args["instance-name"] = instance_name
             instance = testclass(testrun=self._testrun,
                                  **args)
             if monitors:
@@ -116,14 +119,21 @@ class Scenario(Test):
 
     # overridable methods
 
-    def addSubTest(self, testclass, arguments, monitors=None, position=-1):
+    def addSubTest(self, testclass, arguments, monitors=None, position=-1,
+            instance_name=None):
         """
         testclass : a testclass to run next, can be a Scenario
         arguments : dictionnary of arguments
         monitors : list of (Monitor, monitorargs) to run the test with
+        position : the position to insert the test in (-1 for last)
+        instance_name : a human-readable name for the test.
 
         This method can be called several times in a row at any moment.
         """
+        self._n_tests += 1
+        if instance_name is None:
+            instance_name = "%u.%s" % (self._n_tests,
+                                       testclass.__test_name__)
         # filter out unused arguments in arguments for non-scenarios
         if not issubclass(testclass, Scenario):
             args = {}
@@ -134,9 +144,10 @@ class Scenario(Test):
             args = arguments
         debug("Appending subtest %r args:%r", testclass, args)
         if position == -1:
-            self._tests.append((testclass, args, monitors))
+            self._tests.append((testclass, args, monitors, instance_name))
         else:
-            self._tests.insert(position, (testclass, args, monitors))
+            self._tests.insert(position,
+                                (testclass, args, monitors, instance_name))
 
     def subTestDone(self, subtest):
         """
diff --git a/insanity/test.py b/insanity/test.py
index 2e4dfbf..b547bcf 100644
--- a/insanity/test.py
+++ b/insanity/test.py
@@ -79,7 +79,10 @@ class Test(gobject.GObject):
     in one line their purpose and usage.
     """
 
-    __test_arguments__ = { }
+    __test_arguments__ = {
+        "instance-name": ("Name assigned by parent.", "",
+            "Used to identify similar subtests within a scenario.")
+        }
     """
     Dictionnary of arguments this test can take.
 



More information about the gstreamer-commits mailing list