Skip to content

Commit

Permalink
tests: cpp: add C++ coverage for pm/device.h
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
marc-hb committed Jun 14, 2024
1 parent 623675a commit 57e2676
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/lib/cpp/cxx/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,21 @@ CONFIG_ZTEST_STACK_SIZE=2048
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=128
CONFIG_CRC=y

# Enable optional features that are off by default to cover as much as
# possible of the same .h files. Ideally, kconfiglib.py would support
# "randconfig" because turning on some options can also reduce test
# coverage in some areas. But: 1. combinatorial explosion, 2. it does
# not.

# RTIO
CONFIG_RTIO=y
CONFIG_RTIO_SUBMIT_SEM=y
CONFIG_RTIO_CONSUME_SEM=y
CONFIG_RTIO_SYS_MEM_BLOCKS=y

# Enable more features and C++ coverage in device.h, pm/device.h, pm.h...
CONFIG_PM=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
# Deprecated but on by default! Silence the warning:
CONFIG_PM_DEVICE_RUNTIME_EXCLUSIVE=n
5 changes: 5 additions & 0 deletions tests/lib/cpp/cxx/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <zephyr/init.h>
#include <zephyr/device.h>
#include <zephyr/pm/device.h>
#include <zephyr/kernel.h>
#include <zephyr/net/buf.h>
#include <zephyr/sys/crc.h>
Expand Down Expand Up @@ -147,3 +148,7 @@ ZTEST_SUITE(cxx_tests, NULL, NULL, NULL, NULL, NULL);
DEVICE_DT_DEFINE(DT_NODELABEL(test_dev0_boot), NULL, NULL, NULL, NULL, POST_KERNEL, 33, NULL);

DEVICE_DT_DEFINE(DT_NODELABEL(test_dev1_dfr), NULL, NULL, NULL, NULL, POST_KERNEL, 33, NULL);

static int fake_pm_action(const struct device *dev,
enum pm_device_action pm_action) { return -1; }
PM_DEVICE_DT_DEFINE(DT_NODELABEL(test_dev0_boot), fake_pm_action);

0 comments on commit 57e2676

Please sign in to comment.