Home
last modified time | relevance | path

Searched hist:"37 c2612b4497f4065a810187e3f99cfaccca368c" (Results 1 – 1 of 1) sorted by relevance

/openbmc/phosphor-power/tools/power-utils/
H A Dversion.cppdiff 37c2612b4497f4065a810187e3f99cfaccca368c Thu Oct 24 13:58:31 CDT 2024 Shawn McCarney <shawnmm@us.ibm.com> psutils: Do not pad PSU version with blanks

When `psutils --get-version <inventory_path>` is run, it returns the
firmware version for the specified PSU inventory path.

If no psu.json file is found, the PSU I2C bus and address are obtained
from D-Bus. The PSU version is then obtained from a file in sysfs.

The contents of the sysfs file are currently treated as VPD. Invalid
characters are replaced with spaces, and the value is padded with spaces
if needed to reach an expected VPD length.

If an error occurs trying to read the sysfs file, the version is
initially set to "". However, since it is being treated as VPD it is
later padded with blanks. Since the version is not an empty string, it
is treated as valid by psutils and the PSU code update application.
This causes subsequent code update issues.

Modify psutils so that the contents of the sysfs file are treated as a
simple string. If an error occurs, set the version to "". This will
cause psutils and the PSU code update application to correctly conclude
that an error occurred and the version is not valid.

Tested:
* psutils --get-version
* psu.json file exists
* Test where getting the version works
* Verify file contents are obtained
* Verify psutils prints out the version
* Verify psutils exits with a return code of 0
* Test where getting the version fails
* Verify exception is written to the journal
* Verify psutils prints out an empty string
* Verify psutils exits with a return code of 1
* psu.json file does not exist; PSU information is obtained from D-Bus
* Test where getting the version works
* Verify file contents are obtained
* Verify psutils prints out the version
* Verify psutils exits with a return code of 0
* Test where getting the version fails
* Verify exception is written to the journal
* Verify psutils prints out an empty string
* Verify psutils exits with a return code of 1

Change-Id: I131ba1b73f5ee96606bcfe86943da258196eca62
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>