Skip to content

Commit de2fa9f

Browse files
author
David Sommerseth
committed
Make the unit test run without installing python-dmidecode
Load the newly compiled module from the python build dir and use the local pymap.xml file.
1 parent fc09629 commit de2fa9f

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

unit-tests/unit

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ from pprint import pprint
55
import os, sys, random, tempfile, time
66
import commands
77

8+
# Setup temporary sys.path() with our build dir
9+
(sysname, nodename, release, version, machine) = os.uname()
10+
pyver = sys.version[:3]
11+
sys.path.insert(0,'../build/lib.%s-%s-%s' % (sysname.lower(), machine, pyver))
12+
813
root_user = (os.getuid() == 0 and True or False)
914

1015
DUMPS_D = "private"
@@ -130,7 +135,15 @@ try:
130135
if root_user:
131136
devices.append("/dev/mem")
132137
else:
133-
sys.stdout.write(" * %s\n"%red("Running test as normal user, will not try to read /dev/mem\n"))
138+
sys.stdout.write(" * %s\n"%red("Running test as normal user, will not try to read /dev/mem"))
139+
140+
try:
141+
pymap = '../src/pymap.xml'
142+
sys.stdout.write(" * Loading %s for XML->Python dictonary mapping..." % pymap)
143+
dmidecode.pythonmap(pymap)
144+
passed()
145+
except:
146+
failed()
134147

135148
random.shuffle(types)
136149
random.shuffle(devices)
@@ -181,6 +194,7 @@ try:
181194
except LookupError, e:
182195
failed(e, 2)
183196

197+
184198
dmixml = dmidecode.dmidecodeXML()
185199
try:
186200
sys.stdout.write(" * XML: Swapping result type dmidecodeXML::SetResultType('-')...");

0 commit comments

Comments
 (0)