diff options
author | nima <nima@abc39116-655e-4be6-ad55-d661dc543056> | 2008-12-19 13:42:10 +0000 |
---|---|---|
committer | nima <nima@abc39116-655e-4be6-ad55-d661dc543056> | 2008-12-19 13:42:10 +0000 |
commit | ef62ae6dea3de725825a92e92bfab6cb9a581f93 (patch) | |
tree | e466e3954455cb02e59051507ee7d583fb02bba0 /test.py | |
parent | bc5647310466c6f4409bc195e5abf32710abedfa (diff) | |
download | python-dmidecode-ef62ae6dea3de725825a92e92bfab6cb9a581f93.tar.gz python-dmidecode-ef62ae6dea3de725825a92e92bfab6cb9a581f93.tar.xz python-dmidecode-ef62ae6dea3de725825a92e92bfab6cb9a581f93.zip |
Improved test case.
git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@126 abc39116-655e-4be6-ad55-d661dc543056
Diffstat (limited to 'test.py')
-rwxr-xr-x | test.py | 76 |
1 files changed, 74 insertions, 2 deletions
@@ -2,8 +2,80 @@ #.awk '$0 ~ /case [0-9]+: .. 3/ { print $2 }' src/dmidecode.c|tr ':\n' ', ' from pprint import pprint +import os, sys + +print "Importing module...", import dmidecode +print "Done" + +#. Test all functions using /dev/mem... +print "Testing bios...", len(dmidecode.bios()) and "Good" or "Failed" +print "Testing system...", dmidecode.system() and "Good" or "Failed" +print "Testing baseboard...", dmidecode.baseboard() and "Good" or "Failed" +print "Testing chassis...", dmidecode.chassis() and "Good" or "Failed" +print "Testing processor...", dmidecode.processor() and "Good" or "Failed" +print "Testing memory...", dmidecode.memory() and "Good" or "Failed" +print "Testing cache...", dmidecode.cache() and "Good" or "Failed" +print "Testing connector...", dmidecode.connector() and "Good" or "Failed" +print "Testing slot...", dmidecode.slot() and "Good" or "Failed" + +if os.path.exists("/tmp/foo"): + print "Removing old file..." + os.unlink("/tmp/foo") + +print "Testing check for write permission on dump...", +print not dmidecode.dump() and "Good" or "Bad" + +print "Testing that default device is /dev/mem", +print dmidecode.get_dev() == "/dev/mem" and "Good" or "Bad" + +print "Testing ability to change device to /tmp/foo...", +print dmidecode.set_dev("/tmp/foo") and "Good" or "Bad" + +print "Testing that device has changed to /tmp/foo...", +print dmidecode.get_dev() == "/tmp/foo" and "Good" or "Bad" + +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" + +#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... +dmidecode.dump() + for i in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 126, 127): - print i - pprint(dmidecode.type(i)) + print "Testing...", i, len(dmidecode.type(i)), "Done" + +sys.exit(0) + +#. Test reading the dump... +print "*** bios ***\n"; pprint(dmidecode.bios()) +print "*** system ***\n"; pprint(dmidecode.system()) +print "*** system ***\n"; pprint(dmidecode.system()) +print "*** baseboard ***\n"; pprint(dmidecode.baseboard()) +print "*** chassis ***\n"; pprint(dmidecode.chassis()) +print "*** processor ***\n"; pprint(dmidecode.processor()) +print "*** memory ***\n"; pprint(dmidecode.memory()) +print "*** cache ***\n"; pprint(dmidecode.cache()) +print "*** connector ***\n"; pprint(dmidecode.connector()) +print "*** slot ***\n"; pprint(dmidecode.slot()) + +print "*** bios ***\n"; pprint(dmidecode.bios()) +print "*** system ***\n"; pprint(dmidecode.system()) +print "*** baseboard ***\n"; pprint(dmidecode.baseboard()) +print "*** chassis ***\n"; pprint(dmidecode.chassis()) +print "*** processor ***\n"; pprint(dmidecode.processor()) +print "*** memory ***\n"; pprint(dmidecode.memory()) +print "*** cache ***\n"; pprint(dmidecode.cache()) +print "*** connector ***\n"; pprint(dmidecode.connector()) +print "*** slot ***\n"; pprint(dmidecode.slot()) + |