aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorastokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8>2010-02-03 17:17:17 +0000
committerastokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8>2010-02-03 17:17:17 +0000
commit4bd7eabf0d0452ab2563db85b408c350db497332 (patch)
tree9500f6935469dbdc5e0731febb211cda60403dc1
parent9637fa5f89e3d25937cae0556615582f1de8ef11 (diff)
downloadsos-4bd7eabf0d0452ab2563db85b408c350db497332.tar.gz
- more tests, using python-nose for simplified testing structure
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@712 ef72aa8b-4018-0410-8976-d6e080ef94d8
-rw-r--r--src/tests/commons.py28
-rw-r--r--src/tests/testBasic.py39
2 files changed, 67 insertions, 0 deletions
diff --git a/src/tests/commons.py b/src/tests/commons.py
new file mode 100644
index 00000000..fd389dd8
--- /dev/null
+++ b/src/tests/commons.py
@@ -0,0 +1,28 @@
+# 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
new file mode 100644
index 00000000..8338091d
--- /dev/null
+++ b/src/tests/testBasic.py
@@ -0,0 +1,39 @@
+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