summaryrefslogtreecommitdiffstats
path: root/Makefile.am
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-05-23 16:15:26 +0930
committerAndrew Jeffery <andrew@aj.id.au>2019-03-18 16:08:31 +1030
commita607a0d02ceea61c1cfcbaac535fb9f925c0ffc4 (patch)
treee02fb91cc7d2e244f6e0668ea75b30e1af0521b1 /Makefile.am
parentf2086fcd89b53be4842109b06012489acbf7a390 (diff)
downloadphosphor-led-sysfs-a607a0d02ceea61c1cfcbaac535fb9f925c0ffc4.tar.gz
phosphor-led-sysfs-a607a0d02ceea61c1cfcbaac535fb9f925c0ffc4.zip
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>
Diffstat (limited to 'Makefile.am')
-rw-r--r--Makefile.am12
1 files changed, 12 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 3c42e07..5683086 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,3 +9,15 @@ phosphor_ledcontroller_LDFLAGS = $(SDBUSPLUS_LIBS) \
$(PHOSPHOR_DBUS_INTERFACES_LIBS)
phosphor_ledcontroller_CFLAGS = $(SDBUSPLUS_CFLAGS) \
$(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
+
+@CODE_COVERAGE_RULES@
+
+check_PROGRAMS =
+XFAIL_TESTS =
+
+include test/Makefile.am.include
+
+TESTS = $(check_PROGRAMS)
+
+clean-local: code-coverage-clean
+dist-clean-local: code-coverage-dist-clean
OpenPOWER on IntegriCloud