Parser regression testing support.

Signed-off-by: Cary Hull <chull@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@2432 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/parsers/test/templates/base.py b/tko/parsers/test/templates/base.py
new file mode 100644
index 0000000..af1bbfc
--- /dev/null
+++ b/tko/parsers/test/templates/base.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python2.4
+"""
+This is not meant to be executed unless copied into a
+scenario package and renamed with a _unittest suffix.
+"""
+
+import os, unittest
+from os import path
+import common
+from autotest_lib.tko.parsers.test import scenario_base
+
+GOLDEN = 'golden'
+
+
+class ParserScenerioTestCase(scenario_base.BaseScenarioTestCase):
+    def test_regression(self):
+        """We want to ensure that result matches the golden.
+
+        This test is enabled if there is a golden entry
+        in the parser_result_store.
+        """
+        self.skipIf(
+            GOLDEN not in self.parser_result_store,
+            'No golden data to test against')
+
+        golden = self.parser_result_store[GOLDEN]
+        fresh_parser_result = self.harness.execute()
+        fresh_copy = scenario_base.copy_parser_result(
+            fresh_parser_result)
+        self.assertEquals(golden, fresh_copy)
+
+
+if __name__ == '__main__':
+    unittest.main()