Commit graph

18 commits

Author SHA1 Message Date
Tom Hughes
b35c3a64a5 tests: lib: smf: Add missing equals
When building with clang and -Wno-gnu it complains about the missing
equals:

tests/lib/smf/src/test_lib_hierarchical_5_ancestor_smf.c:415:8: error:
use of GNU 'missing =' extension in designator
[-Werror,-Wgnu-designator]

[P05] SMF_CREATE_STATE(p05_entry, p05_run, p05_exit, NULL, NULL),
      ^
      =

tests/lib/smf/src/test_lib_hierarchical_5_ancestor_smf.c:416:8: error:
use of GNU 'missing =' extension in designator
[-Werror,-Wgnu-designator]

[P04] SMF_CREATE_STATE(p04_entry, p04_run, p04_exit, &test_states[P05],
      ^                NULL),
      =

tests/lib/smf/src/test_lib_hierarchical_5_ancestor_smf.c:417:8: error:
use of GNU 'missing =' extension in designator
[-Werror,-Wgnu-designator]

[P03] SMF_CREATE_STATE(p03_entry, p03_run, p03_exit, &test_states[P04],
      ^                NULL),
      =

tests/lib/smf/src/test_lib_hierarchical_5_ancestor_smf.c:418:8: error:
use of GNU 'missing =' extension in designator
[-Werror,-Wgnu-designator]

[P02] SMF_CREATE_STATE(p02_entry, p02_run, p02_exit, &test_states[P03],
      ^                NULL),
      =

tests/lib/smf/src/test_lib_hierarchical_5_ancestor_smf.c:419:8: error:
use of GNU 'missing =' extension in designator
[-Werror,-Wgnu-designator]

[P01] SMF_CREATE_STATE(p01_entry, p01_run, p01_exit, &test_states[P02],
      ^                NULL),
      =

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-01-20 16:27:10 +01:00
Glenn Andrews
895f246227 Lib: SMF: Add test for stuck handled bit
Update test_lib_self_transition_smf.c to detect the bug that was in
smf_set_handled().

Also delete unneeded test state STATE_D_ENTRY

Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
2024-06-24 14:50:00 -04:00
Glenn Andrews
27d7e38ee0 Lib: SMF: Refactor test_lib_self_transition_smf.c
Make the code less dependent on
magic #defines by using a single enum for test states.

Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
2024-06-24 14:50:00 -04:00
Glenn Andrews
531c457550 Lib: SMF Modify HSM operation for UML-Style transitions
Modify the SMF such that state transitions from parent states choose the
correct Least Common Ancestor based on the transition source rather than
the current state.

SMF set as experimental.

Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
2024-05-22 21:41:06 -04:00
Fin Maaß
7d83a8a68a lib: smf: constant number of arguments for SMF_CREATE_STATE()
This sets the number of arguments for SMF_CREATE_STATE() to always
be the same, independent of the selected Kconfig options.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-07 17:46:21 +02:00
Glenn Andrews
0569809c80 Lib: SMF: Add initial transition and smf_set_handled()
Brings SMF framework closer into alignment with accepted Hierarchical State
Machine operation by:
1. Allowing 'programming by difference' by having some child states handle
   events and prevent propagation up to the parent run actions while others
   propagate events up to a common handler in a parent state.
2. Optionally allow initial transitions within a parent state to determine
   the most nested child state to transition to.
3. Adding a test case for `CONFIG_SMF_INITIAL_TRANSITION` and
   `smf_set_handled()`
4. Updating documentation for the new API (and fixing some references)

There was discussion in https://github.com/zephyrproject-rtos/zephyr/issues/55344
about not making the initial transition a Kconfig option, but I'm not sure
of any way else of doing it without permanently adding a pointer to each
`smf_state` entry, which is a problem for resource-constrained devices.

This does not fix https://github.com/zephyrproject-rtos/zephyr/issues/66341
but documentation has been updated to warn users of the issue.

Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
2024-03-04 22:16:40 +01:00
Alberto Escolar Piedras
1a3ba0ec82 tests/lib/*: Switch integration platform to native_sim
Swith integration_platforms from native_posix(_64)
to native_sim(_64).

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-30 09:42:25 -05:00
Anas Nashif
345735d0a8 tests: remove CONFIG_ZTEST_NEW_API in all tests
Remove all usage of CONFIG_ZTEST_NEW_API from tests and sample as this
is now enabled by default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Anas Nashif
3349cb9a75 tests: smf: cleanup test metadata
Remove definition of testcases in yaml file, those are now detected from
binary.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-05-25 04:44:11 -04:00
Fabio Baltieri
f5b4acac57 yamllint: indentation: fix files in tests/
Fix the YAML files indentation for files in tests/.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 14:23:53 +01:00
Gerard Marull-Paretas
79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
li biao
b6fadd1600 tests: lib: move smf to new ztest API
Move test smf to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-08-18 11:34:50 +00:00
Fabio Baltieri
def230187b test: fix more legacy #include paths
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00
Reto Schneider
7a6c5710ff cmake: Update cmake_minimum_required to 3.20.0
As Zephyr currently requires CMake version 3.20.0, update all
occurrences of cmake_minimum_required.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-07-04 10:18:45 +02:00
Anas Nashif
9276f30bdd tests: smf: use integration_platforms and list tests
list testcase in yaml file to workaround conditional testsuite
definition.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Gerard Marull-Paretas
ade7ccb918 tests: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all tests to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:02:14 +02:00
Nazar Kazakov
f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Sam Hurst
cb4785542e lib: smf: Add State Machine Framework
Add an application agnostic State Machine Framework library to
Zephyr that provides an easy way for developers to integrate
state machines into their application.

Twister passed:
twister -T tests/lib/smf/

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2021-10-04 20:33:11 -04:00