History log of /openbmc/phosphor-led-sysfs/test/ (Results 26 – 39 of 39)
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
45eba6fc18-May-2021 George Liu <liuxiwei@inspur.com>

Replace std::experimental::filesystem with std::filesystem

Above c++17, std::filesystem is already supported, so replace
std::experimental::filesystem with std::filesystem.

Signed-off-by: George Li

Replace std::experimental::filesystem with std::filesystem

Above c++17, std::filesystem is already supported, so replace
std::experimental::filesystem with std::filesystem.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I864bd80905e9b61428d17b20a91b3482198d20bc

show more ...

a8a275f626-Mar-2021 Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>

test: Add test cases to cover brightness and asserted values

This commit adds test cases that will validate:

┌────────────┬──────────┬────────────────────────┐
│ brightness │ asserted │ brightnes

test: Add test cases to cover brightness and asserted values

This commit adds test cases that will validate:

┌────────────┬──────────┬────────────────────────┐
│ brightness │ asserted │ brightness && asserted │
├────────────┼──────────┼────────────────────────┤
│ 0 │ 0 │ 0 │
│ 0 │ 1 │ 0 │
│ 1 │ 0 │ 0 │
│ 1 │ 1 │ 1 │
└────────────┴──────────┴────────────────────────┘

where:
getMaxBrightness() would map to asserted value
getBrightness() would map to brightness value

Change-Id: Iac2373e61614750e2f2879da46973ff1ab06213b
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>

show more ...

db21bc0026-Mar-2021 Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>

Add test cases to validate state of physical LED

This commit adds code that verifies the state of
physical LED is appropriately set in various cases

Change-Id: I9eab752f6f2b47e719934c14ef95e775d36b

Add test cases to validate state of physical LED

This commit adds code that verifies the state of
physical LED is appropriately set in various cases

Change-Id: I9eab752f6f2b47e719934c14ef95e775d36bcaa0
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>

show more ...

61b9063621-Jun-2020 George Liu <liuxiwei@inspur.com>

clang-format: update to latest from docs repo

Since `Cpp11` is an alias for `Latest` and we should tend towards using the
latest C++ standard, update the C++ standard to Latest.

https://github.com/

clang-format: update to latest from docs repo

Since `Cpp11` is an alias for `Latest` and we should tend towards using the
latest C++ standard, update the C++ standard to Latest.

https://github.com/llvm/llvm-project/commit/e5032567903de19962333c4bf7d2edceaf4f9824#diff-b49a097415dff2837d9626d422c58ba8R82
https://github.com/openbmc/docs/blob/master/style/cpp/.clang-format

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Id5684236b64867ba631a3a00dadababe2c36db16

show more ...

5b1417bd18-Mar-2019 Andrew Jeffery <andrew@aj.id.au>

physical: Conform to LED class kernel ABI

The kernel says the following about the LED sysfs interface:

> LED handling under Linux
> ========================
>
> In its simplest form, the LED class

physical: Conform to LED class kernel ABI

The kernel says the following about the LED sysfs interface:

> LED handling under Linux
> ========================
>
> In its simplest form, the LED class just allows control of LEDs from
> userspace. LEDs appear in /sys/class/leds/. The maximum brightness of the
> LED is defined in max_brightness file. The brightness file will set the brightness
> of the LED (taking a value 0-max_brightness). Most LEDs don't have hardware
> brightness support so will just be turned on for non-zero brightness settings.

The existing code assumed that max_brightness always held a value of
255 and defined a constant for it. Instead, use a class variable to
cache the max brightness for the associated LED.

Change-Id: I2d8f46de0cddac5f9d8ff5444449518bb4056130
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...

30726a0c25-May-2018 Andrew Jeffery <andrew@aj.id.au>

test: physical: Capture state(Action::{On,Off}) parameters

Implement value sensing to verify the behaviour of the On and Off
actions. This constrains future on/off changes to interacting with sysfs

test: physical: Capture state(Action::{On,Off}) parameters

Implement value sensing to verify the behaviour of the On and Off
actions. This constrains future on/off changes to interacting with sysfs
in the same manner.

Change-Id: Ie0ac063cbda3156ca7f0ef2eab9e700013780e44
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...

861e562525-May-2018 Andrew Jeffery <andrew@aj.id.au>

test: physical: Capture Action::Blink parameters

Implement value sensing to verify behaviour of the blink action. This
constrains future blink changes to interacting with sysfs in the same
manner.

test: physical: Capture Action::Blink parameters

Implement value sensing to verify behaviour of the blink action. This
constrains future blink changes to interacting with sysfs in the same
manner.

Change-Id: I7ed0a5d52e8dc99192e7938760ce99f618b9cb16
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...

aee9c2c424-May-2018 Andrew Jeffery <andrew@aj.id.au>

test: physical: Hit both branches of stableStateOperation()

Change-Id: Ic32d87dbe996a03e811e1be88fbcc00bf450e1f3
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

04275e0624-May-2018 Andrew Jeffery <andrew@aj.id.au>

test: physical: Cover trigger:none, brigtness:asserted branch

The test causes execution to take the following path in
setInitialState(), previously outlined in 264d909d3dc9 ("test: Add tests
for Phy

test: physical: Cover trigger:none, brigtness:asserted branch

The test causes execution to take the following path in
setInitialState(), previously outlined in 264d909d3dc9 ("test: Add tests
for Physical class") as being missed:

auto brightness = led.getBrightness();
if (brightness == ASSERT)
{
// LED is in Solid ON
sdbusplus::xyz::openbmc_project::Led::server ::Physical::state(
Action::On);
}

This brings the line coverage to 97.6% (function coverage remains
unchanged by this patch).

Change-Id: I7a04fcd97819559575e69d267c62f16195495010
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...

5669270824-May-2018 Andrew Jeffery <andrew@aj.id.au>

test: physical: Cover trigger:timer branch in setInitialState()

The test causes execution to take the following path in
setInitialState(), previously outlined in 264d909d3dc9 ("test: Add tests
for P

test: physical: Cover trigger:timer branch in setInitialState()

The test causes execution to take the following path in
setInitialState(), previously outlined in 264d909d3dc9 ("test: Add tests
for Physical class") as being missed:

auto trigger = led.getTrigger();
if (trigger == "timer")
{
// LED is blinking. Get the delay_on and delay_off and compute
// DutyCycle. sfsfs values are in strings. Need to convert 'em over to
// integer.
auto delayOn = led.getDelayOn();
auto delayOff = led.getDelayOff();

// Calculate frequency and then percentage ON
frequency = delayOn + delayOff;
auto factor = frequency / 100;
auto dutyOn = delayOn / factor;

// Update.
this->dutyOn(dutyOn);
}

This brings the line coverage to 96.6% (function coverage remains
unchanged by this patch).

Change-Id: Ie311186f6275d3fdd31de5698c7c14bb335128e1
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...

280afaf324-May-2018 Andrew Jeffery <andrew@aj.id.au>

test: physical: Introduce LED mocks

This removes the dependency on touching the filesystem entirely. All
methods are now mocked into an ignored state when called by the NiceMock
template class. The

test: physical: Introduce LED mocks

This removes the dependency on touching the filesystem entirely. All
methods are now mocked into an ignored state when called by the NiceMock
template class. The filesystem is only touched by the SysfsLed tests,
though we still need to provide a temporary path to its constructor in
the decended mock class to ensure we're isolated if something does
manage to get written.

Change-Id: I3955a6e0fb5c3c42887da847239d381ef151fa3e
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...

42e02d3423-May-2018 Andrew Jeffery <andrew@aj.id.au>

sysfs: Integrate class into Physical and tests

Change-Id: I7d5ad19df5ef1258a4e669ea3243b7411f371d9c
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

e185efb823-May-2018 Andrew Jeffery <andrew@aj.id.au>

Add sysfs LED class wrapper

The Physical class implements private templated read() and write()
methods. There are several properties that make this approach less than
ideal:

1. read() and write() a

Add sysfs LED class wrapper

The Physical class implements private templated read() and write()
methods. There are several properties that make this approach less than
ideal:

1. read() and write() are non-virtual template functions, and we would
have to link-seam mock the internals, which means hijacking
std::fstream.

2. Even if read() and write() were virtual functions, this is made
irrelevant by the fact that we want to traverse execution paths in
setInitialState(), which is called from the Physical constructor.
Methods invoked by class constructors are bound to the implementations
specified in the constructor's class and will never dispatch to a
descendant's override. As such we have no mechanism to manipulate the
execution path without resorting to the pre-processor seam, which is
undesirable for other reasons.

3. The abstraction is poor. Physical implements the business logic of
converting interactions with the DBus interface into compatible
interactions with the sysfs LED class attributes, and shouldn't have
knowledge of how to directly interact with sysfs itself.

4. read() and write() are template functions, but the only type
parameter used in the code-base is std::string, and conversions are
left to the caller. This needlessly complicates the caller logic and
reduces readability of the callee code.

The change defines a separate class, SysfsLed, to map actions onto the
LED sysfs class attributes. SysfsLed will be provided by the
dependency-injection pattern to the Physical class by passing an
instance reference through its constructor. The lifetime of the SysfsLed
instance must exceed the lifetime of the associated Physical instance.

Further, the methods of SysfsLed are all marked as virtual and defined
to return concrete types (either unsigned long or std::string as
appropriate). This opens the door for mocking without resorting to
techniques such as using link seams, and removes templates as a point of
complication. Further, defining only a concrete class and not an
abstract base class minimises the boilerplate required as we're likely
never going to have another descendant of SysfsLed that isn't a mock
implementation (we don't need to exclude implementations by way of
sibling types).

Integration tests are provided for SysfsLed, which is necessary as the
class must write to the filesystem (again, unless we want to hijack
std::fstream, which seems unpalatable). Isolated temporary directories
are used to ensure the tests can be run in parallel without
interference. The tests provide 100% line coverage of SysfsLed.

Change-Id: I81fc7d9fd07eed54035f515502f563f25aa1e58f
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...

a607a0d023-May-2018 Andrew Jeffery <andrew@aj.id.au>

test: Add tests for Physical class

The additions to configure expose a new `check-code-coverage` make
target when `--enable-code-coverage` is passed to `./configure`.
Assuming gcov/lcov are installe

test: Add tests for Physical class

The additions to configure expose a new `check-code-coverage` make
target when `--enable-code-coverage` is passed to `./configure`.
Assuming gcov/lcov are installed, `make check-code-coverage` will run
the test suite and generate an HTML line/function/branch coverage report
that enables measurement of the effectiveness of the test suite.

The tests themselves are trivial (integration) tests that get us to
78.8% line coverage and 93.3% function coverage over physical.hpp and
physical.cpp.

However, as we don't have the read() and write() functions under our
control - and as they're implemented to return empty strings when the
target files do not exist - this high level of coverage is more by luck
than design.

To demonstrate, under the current test arrangement, we can never enter
this branch of setInitialState():

auto trigger = read<std::string>(blinkCtrl);
if (trigger == "timer")
{
// LED is blinking. Get the delay_on and delay_off and compute
// DutyCycle. sfsfs values are in strings. Need to convert 'em over to
// integer.
auto delayOn = std::stoi(read<std::string>(delayOnCtrl));
auto delayOff = std::stoi(read<std::string>(delayOffCtrl));

// Calculate frequency and then percentage ON
frequency = delayOn + delayOff;
auto factor = frequency / 100;
auto dutyOn = delayOn / factor;

// Update.
this->dutyOn(dutyOn);
}

For similar reasons, we also fail to enter:

auto brightness = read<std::string>(brightCtrl);
if (brightness == std::string(ASSERT))
{
// LED is in Solid ON
sdbusplus::xyz::openbmc_project::Led::server ::Physical::state(
Action::On);
}

To test both of these paths we need to make changes to isolate
functionality so we can manipulate the read() call to return the
necessary strings at the appropriate times, but that is for a future
change.

Change-Id: I0df2ab2d992ccad514cddb7f7fc6d080aa74f27d
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...

12