Fixed problems introduced by obmc_boot_test.robot merge.
Note: The caller must set PATH and PYTHONPATH so that libraries and resources
can be found. Example:
export PATH=/home/robot/openbmc-test-automation/bin:$PATH
export PYTHONPATH=/home/robot/openbmc-test-automation/lib:$PYTHONPATH
lib/gen_print.py:
- sprint_varx: Failure to support dot_dict.
- sprint_pgm_header:
- Fixed failure to support uid of 0.
- Fixed failure to handle non-existent DISPLAY env variable.
lib/obmc_boot_test.py
- plug_in_setup: Fixed failure to handle non-existent FFDC_DIR_PATH env
variable.
Resolves https://github.com/openbmc/openbmc-test-automation/issues/230
Change-Id: I81a2ac6ad0bc69b24f9e160d38120ffb31c632f1
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/gen_print.py b/lib/gen_print.py
index 6b405d7..ad06757 100755
--- a/lib/gen_print.py
+++ b/lib/gen_print.py
@@ -526,6 +526,8 @@
if type(var_value) in (dict, collections.OrderedDict):
type_is_dict = 1
except AttributeError:
+ pass
+ if not type_is_dict:
try:
if type(var_value) is DotDict:
type_is_dict = 1
@@ -936,14 +938,26 @@
loc_col1_width)
buffer += sprint_varx(pgm_name_var_name + "_pgid", os.getpgrp(), 0, indent,
loc_col1_width)
- buffer += sprint_varx("uid", str(os.geteuid()) + " (" + os.getlogin() +
+ userid_num = str(os.geteuid())
+ try:
+ username = os.getlogin()
+ except OSError:
+ if userid_num == "0":
+ username = "root"
+ else:
+ username = "?"
+ buffer += sprint_varx("uid", userid_num + " (" + username +
")", 0, indent, loc_col1_width)
buffer += sprint_varx("gid", str(os.getgid()) + " (" +
str(grp.getgrgid(os.getgid()).gr_name) + ")", 0,
indent, loc_col1_width)
buffer += sprint_varx("host_name", socket.gethostname(), 0, indent,
loc_col1_width)
- buffer += sprint_varx("DISPLAY", os.environ['DISPLAY'], 0, indent,
+ try:
+ DISPLAY = os.environ['DISPLAY']
+ except KeyError:
+ DISPLAY = ""
+ buffer += sprint_varx("DISPLAY", DISPLAY, 0, indent,
loc_col1_width)
# I want to add code to print caller's parms.
diff --git a/lib/obmc_boot_test.py b/lib/obmc_boot_test.py
index e8f44fe..427aeeb 100755
--- a/lib/obmc_boot_test.py
+++ b/lib/obmc_boot_test.py
@@ -85,10 +85,12 @@
ffdc_prefix += "." + time_string
- ffdc_dir_path = OperatingSystem().get_environment_variable(
- "FFDC_DIR_PATH")
- # Add trailing slash.
- ffdc_dir_path = os.path.normpath(ffdc_dir_path) + os.sep
+ try:
+ ffdc_dir_path = os.environ['FFDC_DIR_PATH']
+ # Add trailing slash.
+ ffdc_dir_path = os.path.normpath(ffdc_dir_path) + os.sep
+ except KeyError:
+ ffdc_dir_path = ""
BuiltIn().set_global_variable("${FFDC_DIR_PATH}", ffdc_dir_path)
# For each program parameter, set the corresponding AUTOBOOT_ environment