187187 vwrite (" * Testing that device has changed to %s..." % DUMP , 1 )
188188 test (dmidecode .get_dev () == DUMP )
189189
190- if root_user :
190+ if root_user and dmidecode . dmi is not None :
191191 vwrite (" * Testing that write on new file is ok..." , 1 )
192192 test (dmidecode .dump ())
193193
@@ -196,10 +196,16 @@ try:
196196 if test (os .path .exists (DUMP )):
197197 os .unlink (DUMP )
198198 else :
199- vwrite (
200- " * %s\n " % red (
201- "Skip testing API function, missing root privileges: dmidecode.dump()"
202- ), 1 )
199+ if dmidecode .dmi is None :
200+ vwrite (
201+ " * %s\n " % yellow (
202+ "Skipped testing API function, hardware does not have DMI data"
203+ ), 1 )
204+ else :
205+ vwrite (
206+ " * %s\n " % red (
207+ "Skip testing API function, missing root privileges: dmidecode.dump()"
208+ ), 1 )
203209
204210 types = range (0 , 42 )+ range (126 , 128 )
205211 bad_types = [- 1 , - 1000 , 256 ]
@@ -220,10 +226,11 @@ try:
220226 else :
221227 vwrite (" * If you have memory dumps to test, create a directory called `%s' and drop them in there.\n " % DUMPS_D , 1 )
222228
223- if root_user :
229+ if root_user and dmidecode . dmi is not None :
224230 devices .append ("/dev/mem" )
225231 else :
226- vwrite (" * %s\n " % red ("Running test as normal user, will not try to read /dev/mem" ), 1 )
232+ if dmidecode .dmi is not None :
233+ vwrite (" * %s\n " % red ("Running test as normal user, will not try to read /dev/mem" ), 1 )
227234
228235 try :
229236 pymap = '../src/pymap.xml'
0 commit comments