diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/commons.py | 28 | ||||
-rw-r--r-- | src/tests/testBasic.py | 39 | ||||
-rw-r--r-- | src/tests/test_plugin_syntax.py | 32 |
3 files changed, 0 insertions, 99 deletions
diff --git a/src/tests/commons.py b/src/tests/commons.py deleted file mode 100644 index fd389dd8..00000000 --- a/src/tests/commons.py +++ /dev/null @@ -1,28 +0,0 @@ -# commons.py -import sys, os - -commons = {} -commons['bin'] = '/usr/sbin/sosreport' -commons['testName'] = 'tester' -commons['testID'] = 1 -commons['batch'] = True -commons['i18n'] = 'en_US.UTF-8' -commons['pluginpath'] = None -commons['plugins'] = [] -if os.path.isfile('/etc/fedora-release'): - commons['distro'] = 'Fedora' -else: - commons['distro'] = 'RHEL' - -paths = sys.path -for path in paths: - if path.strip()[-len("site-packages"):] == "site-packages" \ - and os.path.isdir(path + "/sos/plugins"): - commons['pluginpath'] = path + "/sos/plugins" - -for plugin in os.listdir(commons['pluginpath']): - plugbase = plugin[:-3] - if not plugin[-3:] == '.py' or plugbase == "__init__": - continue - commons['plugins'].append(plugbase) - diff --git a/src/tests/testBasic.py b/src/tests/testBasic.py deleted file mode 100644 index 8338091d..00000000 --- a/src/tests/testBasic.py +++ /dev/null @@ -1,39 +0,0 @@ -import os -from glob import glob -from subprocess import Popen, PIPE -from commons import * -from nose import with_setup - -def setup_func(): - for report in glob("/tmp/sosreport*"): - os.remove(report) - -def teardown_func(): - for report in glob("/tmp/sosreport*"): - os.remove(report) - -def testSosreportBin(): - """ test existence of sosreport bin """ - if not os.path.isfile(commons['bin']): - raise AssertionError("Sosreport executable does not exist") - -# mostly sanity checks on plugins -@with_setup(setup_func, teardown_func) -def testUnattended(): - """ test batch mode """ - (out, err) = Popen([commons['bin'],'-ofilesys','--batch'], - stdout=PIPE,stderr=PIPE).communicate() - output = out - if not len(glob('/tmp/sosreport-*.bz2')): - raise AssertionError("No sosreport created.") - -@with_setup(setup_func, teardown_func) -def testUnattendedNameTicket(): - """ test for --name/--ticket within sosreport file """ - (out, err) = Popen([commons['bin'],'-ofilesys','--name=%s' % (commons['testName'],), - '--ticket-number=%d' % (commons['testID'],),'--batch'],stdout=PIPE, - stderr=PIPE).communicate() - if not len(glob('/tmp/sosreport-%s.%d-*bz2' % (commons['testName'],commons['testID']))): - raise AssertionError("Can not determine sosreport") - -# plugin specific tests diff --git a/src/tests/test_plugin_syntax.py b/src/tests/test_plugin_syntax.py deleted file mode 100644 index 1b0ae31d..00000000 --- a/src/tests/test_plugin_syntax.py +++ /dev/null @@ -1,32 +0,0 @@ -import unittest -import sys -import os -import sos.policyredhat -from sos.helpers import * - -class testPluginSanity(unittest.TestCase): - def setUp(self): - self.policy = sos.policyredhat.SosPolicy() - # build plugins list - paths = sys.path - for path in paths: - if path.strip()[-len("site-packages"):] == "site-packages" \ - and os.path.isdir(path + "/sos/plugins"): - pluginpath = path + "/sos/plugins" - self.plugins = os.listdir(pluginpath) - self.plugins.sort() - - def test_plugin_load(self): - for plug in self.plugins: - plugbase = plug[:-3] - if not plug[-3:] == '.py' or plugbase == "__init__": - continue - try: - loadPlugin = importPlugin("sos.plugins." + plugbase, plugbase) - except: - self.fail("Plugin exception on %s" % (plugbase,)) - -if __name__=="__main__": - suite = unittest.TestLoader().loadTestsFromTestCase(testPluginSanity) - unittest.TextTestRunner(verbosity=2).run(suite) - |