History log of /openbmc/phosphor-psu-code-mgmt/src/utils.hpp (Results 1 – 18 of 18)
Revision Date Author Comments
# 638b84ae 01-Feb-2025 Patrick Williams <patrick@stwcx.xyz>

clang-format: update latest spec and reformat

Copy the latest format file from the docs repository and apply.

Change-Id: I9230bbf1838e1e34ee6b6b49553a59fc9245cca1
Signed-off-by: Patrick Williams <p

clang-format: update latest spec and reformat

Copy the latest format file from the docs repository and apply.

Change-Id: I9230bbf1838e1e34ee6b6b49553a59fc9245cca1
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>

show more ...


# 487e2e19 25-Nov-2024 Shawn McCarney <shawnmm@us.ibm.com>

Improve error handling for exceptions and asserts

The phosphor-psu-code-manager application currently exits abnormally due
to the following conditions:
* Uncaught exception
* False assert() statemen

Improve error handling for exceptions and asserts

The phosphor-psu-code-manager application currently exits abnormally due
to the following conditions:
* Uncaught exception
* False assert() statement

An abnormal exit can result in a core dump and/or a BMC dump. It also
causes the service to be restarted. If the failure condition remains,
the restarts will fail repeatedly, and systemd will stop trying to start
the service.

Improve error handling for exceptions in the following ways:
* Add try/catch blocks to the following locations:
* Code that calls functions that throw and needs to handle exceptions.
* For example, code looping over PSU objects may need to handle an
exception for one PSU and then continue to the remaining PSUs.
* D-Bus PropertiesChanged and InterfacesAdded event handlers.
* Do not allow exceptions to escape to the sdbusplus stack frames.
* main()
* Last line of defense; catching avoids a core dump.
* Write exception error message to the journal if appropriate

Replace assert statements with exceptions or error messages to the
journal.

Tested:
* Tested all modified functions/methods.
* Verified that all exceptions were caught and logged to the journal if
appropriate.
* Verified that asserts were replaced by exceptions and logging.
* See complete test plan at
https://gist.github.com/smccarney/b4bf568639fedd269c9737234fa2803d

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

show more ...


# d57bd2f2 02-Dec-2024 Shawn McCarney <shawnmm@us.ibm.com>

Rename getPSUInventoryPath to getPSUInventoryPaths

Rename the utils method/function getPSUInventoryPath() to
getPSUInventoryPaths(). The method/function returns multiple paths in a
vector, so the n

Rename getPSUInventoryPath to getPSUInventoryPaths

Rename the utils method/function getPSUInventoryPath() to
getPSUInventoryPaths(). The method/function returns multiple paths in a
vector, so the name should be plural. This will make the return type
more clear. Currently the name implies only one path will be returned.

Tested:
* Verified all automated tests build and run successfully
* Verified getPSUInventoryPaths() returns correct data

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

show more ...


# 783406e6 17-Nov-2024 Shawn McCarney <shawnmm@us.ibm.com>

Get model using command line tool

Get the PSU model using a command line tool specified in the meson
options. The default tool is 'psutils --get-model'. The tool should
get the model data directly

Get model using command line tool

Get the PSU model using a command line tool specified in the meson
options. The default tool is 'psutils --get-model'. The tool should
get the model data directly from the PSU.

This is more accurate than getting the Model property of the Asset
interface on D-Bus. Inventory Manager saves its state to files. When
the BMC is booted, Inventory Manager initializes itself using the saved
state. This is necessary to handle the scenario where the BMC is
rebooted while the rest of the system is powered on (such as a
concurrent BMC code update).

However, if all power was removed from the system, a PSU may have been
added/removed/replaced while the BMC was offline. When the BMC boots,
the Inventory Manager saved state is not correct.

Eventually the PSU monitoring application will update the model on
D-Bus, but this can take a non-trivial amount of time. This is
especially true if EntityManager is used to provide the PSU bus and
address information to the PSU monitoring application.

Tested:
* Verified all automated tests build and run successfully
* Verified application uses command line tool to obtain model
* Verified command line tool was returning the correct model
* Test where command line tool fails with non-zero exit code
* Tested where all PSU information available when application starts
* Tested where PSU information is obtained after application starts
using the InterfacesAdded handler
* Tested where PSU presence changes and is obtained by the
PropertiesChanged handler
* Full test plan is available at
https://gist.github.com/smccarney/87bd821a6d317ec0915d1f162028ff01

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

show more ...


# 66a54ad4 23-Aug-2024 George Liu <liuxiwei@ieisystem.com>

clang-tidy: Enable cppcoreguidelines-special-member-functions

The check finds classes where some but not all of the special member
functions are defined.

By default the compiler defines a copy cons

clang-tidy: Enable cppcoreguidelines-special-member-functions

The check finds classes where some but not all of the special member
functions are defined.

By default the compiler defines a copy constructor, copy assignment
operator, move constructor, move assignment operator and destructor.
The default can be suppressed by explicit user-definitions. The
relationship between which functions will be suppressed by
definitions of other functions is complicated and it is advised that
all five are defaulted or explicitly defined.

Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: Icbfd448b2bf78ebf99ec07b55220871e093cb899

show more ...


# bab5ed99 16-Aug-2024 Patrick Williams <patrick@stwcx.xyz>

clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda forma

clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.

See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.

Change-Id: I08efc0671773edfae814ebcda5c01389155e2cac
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>

show more ...


# 5670b188 10-May-2023 Patrick Williams <patrick@stwcx.xyz>

clang-format: copy latest and re-format

clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest

clang-format: copy latest and re-format

clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository and reformat the
repository.

Change-Id: Idb72665dbadfa8afd569a2e0e254d84f0a2108d3
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>

show more ...


# 374fae56 22-Jul-2022 Patrick Williams <patrick@stwcx.xyz>

sdbusplus: use shorter type aliases

The sdbusplus headers provide shortened aliases for many types.
Switch to using them to provide better code clarity and shorter
lines. Possible replacements are

sdbusplus: use shorter type aliases

The sdbusplus headers provide shortened aliases for many types.
Switch to using them to provide better code clarity and shorter
lines. Possible replacements are for:
* bus_t
* exception_t
* manager_t
* match_t
* message_t
* object_t
* slot_t

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie530f2c63000bbfac7c5fbbc74ebe6bc8c07fb1a

show more ...


# b5f9b829 16-Jun-2022 Patrick Williams <patrick@stwcx.xyz>

remove std::experimental usage

The bug previously referenced that instigated the usage of
std::experimental::any instead of std::any has long been fixed in
GCC/libstdc++. Switch back to use the non

remove std::experimental usage

The bug previously referenced that instigated the usage of
std::experimental::any instead of std::any has long been fixed in
GCC/libstdc++. Switch back to use the non-experimental library.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Icb162fd24105b32196993c319ddf232ab1b8c50e

show more ...


# bfa8d16f 13-May-2020 Patrick Williams <patrick@stwcx.xyz>

sdbusplus: replace message::variant with std::variant

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ia0910c101ca50cbfee460f0476562b9c66e4c5d1


# 2e9a3b29 13-May-2020 Patrick Williams <patrick@stwcx.xyz>

sdbusplus: remove deprecated variant_ns

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie341309b8c1811fe3960dc25aaa9c7f6a9e7aafb


# 4b9ac392 11-Oct-2019 Lei YU <mine260309@gmail.com>

utils: Add function to check if PSU is associated

Add a helper function to check if a PSU is in an association list, which
will be used in future commits to check if a PSU is running a software
imag

utils: Add function to check if PSU is associated

Add a helper function to check if a PSU is in an association list, which
will be used in future commits to check if a PSU is running a software
image.

Tested: added unit test case and verify it passes.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I99b5d3d8d09f8e09a1eb42ba104a4804b7214cf1

show more ...


# 6520748d 11-Oct-2019 Lei YU <mine260309@gmail.com>

utils: Add function to get the latest version

This repo does not know which PSU version is the latest, and it lets the
vendor tool to decide which one is the latest.

This commit defines PSU_VERSION

utils: Add function to get the latest version

This repo does not know which PSU version is the latest, and it lets the
vendor tool to decide which one is the latest.

This commit defines PSU_VERSION_COMPARE_UTIL which is expected to be a
tool that accepts arguments of a list of versions, and returns the
latest version string.

Tested: Put and configure to use the example get_latest_version on
Witherspoon, verify the versionId with a larger version string
is returned.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: Ic5a10d3724cf6a98b3979486c72d54f8deac7038

show more ...


# d0bbfa9e 11-Sep-2019 Lei YU <mine260309@gmail.com>

Activation: Delete version interface after activation

When activation is finished, the version interface and the related
images created by phosphor-version-software-manager shall be deleted.

This i

Activation: Delete version interface after activation

When activation is finished, the version interface and the related
images created by phosphor-version-software-manager shall be deleted.

This is done by invoking the Delete method of the related service, so we
need to get all the services from the object, and get the correct
service to invoke the Delete method.

Tested: Verify the Version interface created by
xyz.openbmc_project.Software.Version service, and the related
files in /tmp/image/<versionId> are removed after activation is
completed.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: Icb14731bbea35175c2519bd40b9f88a0b54a034a

show more ...


# 5f3584d4 27-Aug-2019 Lei YU <mine260309@gmail.com>

Get PSU version from vendor specific tool

The code was getting the version from PSU inventory object.
This commit changes the behavior to use a vendor-specific tool to get
the version directly, wher

Get PSU version from vendor specific tool

The code was getting the version from PSU inventory object.
This commit changes the behavior to use a vendor-specific tool to get
the version directly, where the tool is expected to be configured during
build time.

Add an example get_version app that shows the expected behavior of the
tool:
* It accepts an argument of PSU inventory object;
* It outputs the version to stdout.

Tested: 1. Put and configure to use the example get_version on witherspoon,
verify that PSU software objects are created with the version
returned by the exmaple tool.
2. With the Witherspoon specific tool in
https://gerrit.openbmc-project.xyz/c/openbmc/witherspoon-pfault-analysis/+/24811,
verify the version is correctly got from the PSU inventory path
and the software objects are created.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I5195cb6fc8998a76b09abcfe0b107364cb180c01

show more ...


# f77189f7 07-Aug-2019 Lei YU <mine260309@gmail.com>

Add unit test for item_udpater

To test item_updater easier, mocking utils is necessary.
So add a UtilsInterface to make the mocking eaiser.

Due to the fact that there is templated member functions

Add unit test for item_udpater

To test item_updater easier, mocking utils is necessary.
So add a UtilsInterface to make the mocking eaiser.

Due to the fact that there is templated member functions that could not
be virtual, adding an extra "Impl" virtual function makes it possible to
simulates the mock of templated functions.
See
https://stackoverflow.com/questions/7968023/c-virtual-template-method
for details.

However, using std::any in with googlemock has an issue on GCC9, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90415
for details.

So this commit uses std::experimental::any as a workaround.

With the mocked utils, it's easy to test item_updater in different
cases.

This commit adds the test cases for creating PSU objects, when:
* There is no PSU present
* There is one PSU present
* There are two PSUs present with the same version;
* There are two PSUs present with different versions.

Tested: Verify the unit tests passes.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I5d74ab26b344c5c40bc141f97b8aca42e74ee88e

show more ...


# ad90ad51 05-Aug-2019 Lei YU <mine260309@gmail.com>

Create objects for running PSUs

On service startup, create activation and version objects for running
PSUs, and set related active, functional associations.

If multiple PSUs are running with the sa

Create objects for running PSUs

On service startup, create activation and version objects for running
PSUs, and set related active, functional associations.

If multiple PSUs are running with the same software version, they share
the same DBus object, and the object will be associated to multiple PSU
inventories.

Tested: Verify the software objects are created on Witherspoon, and the
active, functional associations are created.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: Ia8372aba8299818baccfdf37e98fdbc99f747b7c

show more ...


# 5e0dcb39 02-Aug-2019 Lei YU <mine260309@gmail.com>

Get psu inventory path

Invoke GetSubTreePaths on configurable psu inventory base path to get
all the PSU paths.
Add unit test case and meson.build to build the unit test case.

In test/meson.build,

Get psu inventory path

Invoke GetSubTreePaths on configurable psu inventory base path to get
all the PSU paths.
Add unit test case and meson.build to build the unit test case.

In test/meson.build, manually adding dynamic_linker related options for
OE SDK environment to link_args, so that the built test binary could be
executed in OE SDK environment. Otherwise, the ld will not find the
correct shared libraries in OE SDK.

And you have to execute the test binaries manually in OE SDK, because
meson skips running the tests due to it thinks it's cross compiling.
This is described in README as well.

Tested: Verify the build and unit test run OK in OE SDK
environment and in OpenBMC CI.
Verify it gets the PSU inventory paths correctly on Witherspoon.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I2e2003c5897d7a623fad7f87d263b71c926fc46d

show more ...