Skip to content

Commit 65f6362

Browse files
marc-hbnashif
authored andcommitted
tests: cpp: add C++ coverage for pm/device.h
Note CONFIG_PM_* affects device.h too. Even if not compiled, the more code the pre-processor sees the better. Signed-off-by: Marc Herbert <[email protected]>
1 parent c1852b8 commit 65f6362

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tests/lib/cpp/cxx/prj.conf

+14
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@ CONFIG_ZTEST_STACK_SIZE=2048
55
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=128
66
CONFIG_CRC=y
77

8+
# Enable optional features that are off by default to cover as much as
9+
# possible of the same .h files. Ideally, kconfiglib.py would support
10+
# "randconfig" because turning on some options can also reduce test
11+
# coverage in some areas. But: 1. combinatorial explosion, 2. it does
12+
# not.
13+
814
# RTIO
915
CONFIG_RTIO=y
1016
CONFIG_RTIO_SUBMIT_SEM=y
1117
CONFIG_RTIO_CONSUME_SEM=y
1218
CONFIG_RTIO_SYS_MEM_BLOCKS=y
19+
20+
# Enable more features and C++ coverage in device.h, pm/device.h, pm.h...
21+
CONFIG_PM=y
22+
CONFIG_PM_DEVICE=y
23+
CONFIG_PM_DEVICE_RUNTIME=y
24+
CONFIG_DEVICE_DT_METADATA=y
25+
# Deprecated but on by default! Silence the warning:
26+
CONFIG_PM_DEVICE_RUNTIME_EXCLUSIVE=n

tests/lib/cpp/cxx/src/main.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <zephyr/init.h>
1717
#include <zephyr/device.h>
18+
#include <zephyr/pm/device.h>
1819
#include <zephyr/kernel.h>
1920
#include <zephyr/net/buf.h>
2021
#include <zephyr/sys/crc.h>
@@ -147,3 +148,7 @@ ZTEST_SUITE(cxx_tests, NULL, NULL, NULL, NULL, NULL);
147148
DEVICE_DT_DEFINE(DT_NODELABEL(test_dev0_boot), NULL, NULL, NULL, NULL, POST_KERNEL, 33, NULL);
148149

149150
DEVICE_DT_DEFINE(DT_NODELABEL(test_dev1_dfr), NULL, NULL, NULL, NULL, POST_KERNEL, 33, NULL);
151+
152+
static int fake_pm_action(const struct device *dev,
153+
enum pm_device_action pm_action) { return -1; }
154+
PM_DEVICE_DT_DEFINE(DT_NODELABEL(test_dev0_boot), fake_pm_action);

0 commit comments

Comments
 (0)