summaryrefslogtreecommitdiffstats
path: root/test.py
diff options
context:
space:
mode:
authornima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-12-21 07:53:54 +0000
committernima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-12-21 07:53:54 +0000
commit0ff1b5b45facd7543529dab5711cf2812c47c218 (patch)
tree7cb4ba131f2ee5437079ae5b959889fac172f1e4 /test.py
parent42617d59e66684bff7272c9c49c0cadd2e53c7f9 (diff)
downloadpython-dmidecode-0ff1b5b45facd7543529dab5711cf2812c47c218.tar.gz
python-dmidecode-0ff1b5b45facd7543529dab5711cf2812c47c218.tar.xz
python-dmidecode-0ff1b5b45facd7543529dab5711cf2812c47c218.zip
Handle cases where user does not have appropriate permission to access the
memory file or device. git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@155 abc39116-655e-4be6-ad55-d661dc543056
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/test.py b/test.py
index 2b8772b..699a0bf 100755
--- a/test.py
+++ b/test.py
@@ -25,6 +25,7 @@ def test(r):
return False
total += 1
+print "-"*80
sys.stdout.write("Importing module...")
try:
import dmidecode
@@ -33,6 +34,7 @@ try:
sys.stdout.write(" * Version: %s\n"%dmidecode.version)
sys.stdout.write(" * DMI Version String: %s\n"%dmidecode.dmi)
+ print "-"*80
sys.stdout.write("Testing that default device is /dev/mem...")
test(dmidecode.get_dev() == "/dev/mem")
@@ -54,11 +56,14 @@ try:
os.unlink(DUMP)
types = range(0, 42)+range(126, 128)
- types = range(0, 42)+[126, 127]
bad_types = [-1, -1000, 256]
sections = ["bios", "system", "baseboard", "chassis", "processor", "memory", "cache", "connector", "slot"]
- devices = [os.path.join("private", _) for _ in os.listdir("private")]
- devices.remove('private/.svn')
+ devices = []
+ if os.path.exists("private"):
+ devices.extend([os.path.join("private", _) for _ in os.listdir("private")])
+ devices.remove('private/.svn')
+ else:
+ sys.stdout.write("If you have memory dumps to test, create a directory called `private' and drop them in there.\n")
devices.append("/dev/mem")
random.shuffle(types)
random.shuffle(devices)
@@ -67,6 +72,15 @@ try:
for dev in devices:
sys.stdout.write(" * Testing %s..."%dev); sys.stdout.flush()
if test(dmidecode.set_dev(dev) and dmidecode.get_dev() == dev):
+ print "-"*80
+ print sections
+ for section in sections:
+ sys.stdout.write(" * Testing %s..."%section); sys.stdout.flush()
+ output = getattr(dmidecode, section)()
+ test(output is not False)
+ if output: sys.stdout.write(" * %s\n"%output.keys())
+
+ print "-"*80
for i in bad_types:
sys.stdout.write(" * Testing bad type %i..."%i); sys.stdout.flush()
try:
@@ -74,17 +88,14 @@ try:
test(output is False)
except SystemError:
sys.stdout.write("FAILED\n")
+
+ print "-"*80
for i in types:
sys.stdout.write(" * Testing type %i..."%i); sys.stdout.flush()
output = dmidecode.type(i)
test(output is not False)
if output:
sys.stdout.write(" * %s\n"%output.keys())
- for section in sections:
- sys.stdout.write(" * Testing %s..."%section); sys.stdout.flush()
- output = getattr(dmidecode, section)()
- test(output is not False)
- if output: sys.stdout.write(" * %s\n"%output.keys())
except ImportError:
sys.stdout.write("FAILED\n")