Add tempest unit test to verify the test list

If there is an error in a test file it could potentially not get run
in the tox jobs used for gating. This commit adds a test which looks
for ImportFailures in the test list to ensure that all the test files
will get run in the gate.

Change-Id: Ia0a5831810d04f2201bd856039362b4a30f39319
diff --git a/tempest/tests/test_list_tests.py b/tempest/tests/test_list_tests.py
new file mode 100644
index 0000000..ab0d114
--- /dev/null
+++ b/tempest/tests/test_list_tests.py
@@ -0,0 +1,38 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+import re
+import subprocess
+
+from tempest.tests import base
+
+
+class TestTestList(base.TestCase):
+
+    def test_no_import_errors(self):
+        import_failures = []
+        p = subprocess.Popen(['testr', 'list-tests'], stdout=subprocess.PIPE)
+        ids = p.stdout.read()
+        ids = ids.split('\n')
+        for test_id in ids:
+            if re.match('(\w+\.){3}\w+', test_id):
+                if not test_id.startswith('tempest.'):
+                    fail_id = test_id.split('unittest.loader.ModuleImport'
+                                            'Failure.')[1]
+                    import_failures.append(fail_id)
+        error_message = ("The following tests have import failures and aren't"
+                         " being run with test filters %s" % import_failures)
+        self.assertFalse(import_failures, error_message)