diff options
author | nima <nima@abc39116-655e-4be6-ad55-d661dc543056> | 2008-12-19 23:45:55 +0000 |
---|---|---|
committer | nima <nima@abc39116-655e-4be6-ad55-d661dc543056> | 2008-12-19 23:45:55 +0000 |
commit | ecc5f901bbb8c888ca3c9e89296a98442bbb0f9e (patch) | |
tree | 16324924001ba2ec8254674a2735da6c3c32b206 /test.py | |
parent | b23485083a007a0490d8ca3125d65bf239e4fae2 (diff) | |
download | python-dmidecode-ecc5f901bbb8c888ca3c9e89296a98442bbb0f9e.tar.gz python-dmidecode-ecc5f901bbb8c888ca3c9e89296a98442bbb0f9e.tar.xz python-dmidecode-ecc5f901bbb8c888ca3c9e89296a98442bbb0f9e.zip |
Test case is close to complete, type 127 results in a segfault - (test case
is serving its purpose).
git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@130 abc39116-655e-4be6-ad55-d661dc543056
Diffstat (limited to 'test.py')
-rwxr-xr-x | test.py | 61 |
1 files changed, 37 insertions, 24 deletions
@@ -2,7 +2,7 @@ #.awk '$0 ~ /case [0-9]+: .. 3/ { print $2 }' src/dmidecode.c|tr ':\n' ', ' from pprint import pprint -import os, sys +import os, sys, random print "Importing module...", import dmidecode @@ -24,36 +24,49 @@ print "Testing that write on new file is ok...", print dmidecode.dump() and "Good" or "Bad" print "Testing that file was actually written...", -print os.path.exists("/tmp/foo") and "Yes" or "No" - -dmidecode.dump() -os.unlink("/tmp/foo") - -#print os.stat("/tmp/foo") - -#. Now test get/set of memory device file... -#print dmidecode.get_dev() -#print dmidecode.set_dev("private/mem-XXX"); -#print dmidecode.get_dev() - -#. Test taking a dump... - -#. Test all functions using /dev/mem... +if os.path.exists("/tmp/foo"): + sys.stdout.write("Good\n") + os.unlink("/tmp/foo") +else: + sys.stdout.write("FAILED\n") +types = range(0, 42)+range(126, 128) +types = range(0, 42)+[126, 127] +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.append("/dev/mem") +random.shuffle(types) +random.shuffle(devices) +random.shuffle(sections) + +total = 0 +success = 0 for dev in devices: - sys.stdout.write(" * Testing %s..."%dmidecode.get_dev()) + sys.stdout.write(" * Testing %s..."%dmidecode.get_dev()); sys.stdout.flush() + total += 1 if dmidecode.set_dev(dev): + success += 1 sys.stdout.write("...\n") - for section in ["bios", "system", "baseboard", "chassis", "processor", "memory", "cache", "connector", "slot"]: - sys.stdout.write(" * Testing %s..."%section) - output = getattr(dmidecode, section) - sys.stdout.write(output and "Done\n" or "FAILED\n") - for i in tuple(range(0, 42))+tuple(range(126, 128)): - sys.stdout.write(" * Testing...") + for i in types: + sys.stdout.write(" * Testing type %i..."%i); sys.stdout.flush() output = len(dmidecode.type(i)) - sys.stdout.write(output and "Done (%d)\n"%i or "FAILED\n") + total += 1 + if output: + sys.stdout.write("Done\n") + success += 1 + else: + sys.stdout.write("FAILED\n") + for section in sections: + total += 1 + sys.stdout.write(" * Testing %s..."%section); sys.stdout.flush() + output = getattr(dmidecode, section) + if output: + sys.stdout.write("Done\n") + success += 1 + else: + sys.stdout.write("FAILED\n") else: sys.stdout.write("FAILED\n") + +print "Score: %d/%d"%(success, total) |