Skip to content

Commit

Permalink
tests: cpp: add some basic Device Tree coverage
Browse files Browse the repository at this point in the history
This provides C++ coverage for Z_DEVICE_INIT() fixed in the previous
commit and for some other Device Tree macros.

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb committed Mar 20, 2024
1 parent 4cef8c4 commit a19094b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/lib/cpp/cxx/app.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
* Copyright (c) 2020 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*
* Application overlay for creating a fake device instance we can use to
* test. Tiny subset of tests/kernel/device/app.overlay.
*/

/ {
fakedomain_0: fakedomain_0 {
compatible = "fakedomain";
status = "okay";
};
};
8 changes: 8 additions & 0 deletions tests/lib/cpp/cxx/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,11 @@ ZTEST(cxx_tests, test_new_delete)
delete test_foo;
}
ZTEST_SUITE(cxx_tests, NULL, NULL, NULL, NULL, NULL);

/*
* Unused macros are parsed but not really compiled. Even with all the
* NULL arguments this line adds a lot of additional coverage.
*
* DEVICE_DEFINE(dev_id, name, * init_fn, pm, data, config, level, prio, api)
*/
DEVICE_DT_DEFINE(DT_NODELABEL(fakedomain_0), NULL, NULL, NULL, NULL, POST_KERNEL, 33, NULL);

0 comments on commit a19094b

Please sign in to comment.