Skip to content

Commit e5295ee

Browse files
committed
Check Skiboot NVRAM options before testcase
Skiboot parses configuration options in NVRAM at boot time which affect runtime behaviour, and several of these can be potentially dangerous or detrimental. When possible check NVRAM for any Skiboot configuration options and warn about them and the end of the test run. Fixes #492 Example: 2019-05-10 13:42:57,768:op-test.common.OpTestUtil:dump_nvram_opts:WARNING: 2 NVRAM debugging options set These may adversely affect test results; verify these are appropriate if a failure occurs: ---------------------------------------------------------- bootargs=modprobe.blacklist=amdgpu test-cfg=test-value ---------------------------------------------------------- Signed-off-by: Samuel Mendoza-Jonas <[email protected]>
1 parent 63f76a1 commit e5295ee

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

OpTestConfiguration.py

+1
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ def __init__(self):
372372
self.util_bmc_server = None # OpenBMC REST Server
373373
atexit.register(self.__del__) # allows cleanup handler to run (OpExit)
374374
self.firmware_versions = None
375+
self.nvram_debug_opts = None
375376

376377
for dir in (os.walk(os.path.join(self.basedir, 'addons')).next()[1]):
377378
optAddons[dir] = importlib.import_module("addons." + dir + ".OpTest" + dir + "Setup")

common/OpTestSystem.py

+5
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,11 @@ def goto_state(self, state):
378378
message=("OpTestSystem something set the system to UNKNOWN,"
379379
" check the logs for details, we will be stopping the system"))
380380

381+
# If we haven't checked for dangerous NVRAM options yet and
382+
# checking won't disrupt the test, do so now.
383+
if self.conf.nvram_debug_opts is None and state in [OpSystemState.PETITBOOT_SHELL, OpSystemState.OS]:
384+
self.util.check_nvram_options(self.console)
385+
381386
def run_DETECT(self, target_state):
382387
self.detect_counter += 1
383388
detect_state = OpSystemState.UNKNOWN

common/OpTestUtil.py

+28
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ def cleanup(self):
284284
if self.conf.dump:
285285
self.conf.dump = False # possible for multiple passes here
286286
self.dump_versions()
287+
self.dump_nvram_opts()
287288

288289
# leave closing the qemu scratch disk until last
289290
# no known reasons at this point, document in future
@@ -313,6 +314,33 @@ def dump_versions(self):
313314
else ('\n'.join(f for f in self.conf.firmware_versions)))
314315
))
315316

317+
def check_nvram_options(self, console):
318+
try:
319+
console.run_command("which nvram")
320+
except:
321+
log.info("No NVRAM utility available to check options")
322+
return
323+
324+
result = console.run_command("nvram -p ibm,skiboot --print-config")
325+
self.conf.nvram_debug_opts = [o for o in result if "=" in o]
326+
327+
if len(self.conf.nvram_debug_opts) == 0:
328+
log.info("No NVRAM debugging options set")
329+
return
330+
331+
log.warning("{} NVRAM debugging options set".format(len(self.conf.nvram_debug_opts)))
332+
333+
def dump_nvram_opts(self):
334+
if self.conf.nvram_debug_opts is None or len(self.conf.nvram_debug_opts) == 0:
335+
return
336+
337+
log.warning("\n{} NVRAM debugging options set\n"
338+
"These may adversely affect test results; verify these are appropriate if a failure occurs:\n"
339+
"----------------------------------------------------------\n"
340+
"{}\n"
341+
"----------------------------------------------------------\n"
342+
.format(len(self.conf.nvram_debug_opts), '\n'.join(f for f in self.conf.nvram_debug_opts)))
343+
316344
def build_proxy(self, proxy, no_proxy_ips):
317345
if no_proxy_ips is None:
318346
return proxy

0 commit comments

Comments
 (0)