Commit graph

49 commits

Author SHA1 Message Date
Yong Cong Sin bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Fabio Baltieri 02114bf822 tests: shell: add tests for "device list"
Add tests for the "device list" output with the various configuration of
device power management.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-05-01 10:31:03 +02:00
Fabio Baltieri 3574050ed2 tests: shell: add a test for shell_device_filter
Add a test for shell_device_filter and shell_device_lookup.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-04-30 19:30:15 -05:00
Al Semjonovs 023248a1f3 shell: Add test for custom shell macros
Verify customized shell macro APIs

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2024-04-24 16:04:03 -04:00
Yong Cong Sin a25e211ad2 tests: shell: shell_uart: add test for multi-instance
Add test that exercise the instance macros of the UART shell
backend.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-12-06 11:27:20 -08:00
Alberto Escolar Piedras f981bf2fa0 tests/subsys/*: 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
Alberto Escolar Piedras c47702cb7e tests/subsys/shell/shell_flash: Enable for native_sim
Enable this test which runs in native_posix in native_sim.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-27 16:06:42 +00:00
Yong Cong Sin a068288091 shell: add new APIs to get the backend instances
Added some new APIs to get the backend instances more easily,
so that dev does not need to rely on `shell_backend_*_get_ptr`,
which looks more like a hack to access a local variable.

These APIs are basically copied from the log backend
implementation.

Added testcase for the APIs.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-25 09:57:29 +02: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
Gerard Marull-Paretas 93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Gerard Marull-Paretas 667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Jamie McCrae af78cbdc99 samples and tests: Add REQUIRED to Zephyr find_package call
Adds REQUIRED to samples and tests for finding the zephyr package
to align all samples and tests with the same call and parameters.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-02 09:58:27 +01:00
Xinyang Tan 535f5a6c04 shell: support setting help string for each entry in a dictionary command
Add support for setting the help description for each entry in a dictionary
command. Currently the syntax string alone may not provide sufficient
description of its entry. This commit also helps keep the help messages
consistent with existing style.

Signed-off-by: Xinyang Tan <xinyang.tan@delve.com>
2022-12-05 18:40:46 +01:00
Henrik Brix Andersen d785c01b97 tests: shell: add missing assert
Add missing assert after polling for the dummy shell backend to be ready.

Fixes: 491f4dd701

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-09-06 14:12:33 +00:00
Jakub Rzeszutko 491f4dd701 shell: update shell tests
Replace hard fixed delay with function shell_ready to wait
for shell readiness.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2022-09-06 12:36:01 +02: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
Anders Storrø 32ebeb0a5c Shell: Increase ARGC_MAX default val
Increase deafult value of SHELL_ARGC_MAX configuration.
This allows users to utilize deeper nested shell menus without
risking maxing out the number of allowed arguments.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-08-29 10:31:38 +02:00
Eric Johnson 92d0031c91 tests: subsys: shell: Add test case for mix of mandatory and opt raw args
Adds tests to handle missing case with a combination of mandatory args
and an optional raw arg

Signed-off-by: Eric Johnson <eric.johnson2@walgreens.com>
2022-08-22 16:29:59 +00:00
Gerard Marull-Paretas a202341958 devices: constify device pointers initialized at compile time
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).

Automated using:

```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-22 17:08:26 +02:00
Yinfang Wang 0e1cc6977f tests: subsys: shell: move shell to new ztest API
Move test shell to use new ztest API.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
2022-08-03 11:19:08 +02:00
Yinfang Wang 5ac55c18d9 tests: subsys: shell: move shell_history to new ztest API
Move test shell_history to use new ztest API.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
2022-08-03 11:19:08 +02:00
Yinfang Wang dba6bbb727 tests: subsys: shell: move shell_flash to new ztest API
Move test shell_flash to use new ztest API.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
2022-08-03 11:19:08 +02: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
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
Krzysztof Chruscinski a15274839a tests: shell: Add test for section commands
Added test for new macros in the API for adding subcommands:
SHELL_SUBCMD_SET_CREATE, SHELL_SUBCMD_ADD and SHELL_SUBCMD_COND_ADD.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-29 14:54:08 +02:00
Gerard Marull-Paretas 05b2221341 tests: subsys: shell: shell_flash: use DEVICE_DT_GET
Obtain flash device at compile time using DEVICE_DT_GET. Also drop
useless static attribute from flash_dev.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-31 13:55:10 +02:00
Katarzyna Giadla 681e3a16c7 tests: Change duplicated names of the test cases
Some names of the test cases are duplicated within the project.
This commit contains the proposed names of the test scenarios.

Signed-off-by: Katarzyna Giadla <katarzyna.giadla@nordicsemi.no>
2022-03-30 17:42:01 -04: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
Guillaume Lager 5387c25e81 shell: Add test for dictionary command
The test also check that dictionary set with matching
items can be declared

Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
2022-02-04 11:14:21 +01:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
Move to CMake 3.20.0.

At the Toolchain WG it was decided to move to CMake 3.20.0.

The main reason for increasing CMake version is better toolchain
support.

Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
Anas Nashif 4d994af032 kernel: remove object tracing
Remove this intrusive tracing feature in favor of the new object tracing
using the main tracing feature in zephyr. See #33603 for the new tracing
coverage for all objects.

This will allow for support in more tools and less reliance on GDB for
tracing objects.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Andrzej Puzdrowski 53f9a931f4 tests/tree-wide: remove flash_write_protection_set() usage
flash_write_protection_set() was deprecated.
This patch removes usage of it.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-03-29 13:43:55 -04:00
Kumar Gala c217cdff4d tests: shell: set integration_platforms to native_posix
Set integration_platforms on these tests to just native_posix.  This
should be sufficient to make sure these tests build and run.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-03 07:23:51 -05:00
Jack Rosenthal ea9866dc86 shell: add an option for minimal default configuration
The default shell configuration has heavy flash and memory requirements,
requiring project maintainers to set many configuration options to "n"
to keep flash and memory requirements within reason.

This adds a new configuration option, CONFIG_SHELL_MINIMAL, which will
disable flash and memory heavy options by default, and allow project
maintainers to select/imply only the options they want.

On a quick test from an ARM board I'm working on, enabling this option
cut flash space requirements by ~8 KB, and memory requirements by ~1 KB.

Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
2021-02-27 10:26:33 +01:00
Krzysztof Chruscinski 7f08061f0c logging: Revamp menuconfig
Clean up logging menuconfig by grouping configuration into
sections like: mode, processing configuration, backends.

Additionlly, removed LOG_ENABLE_FANCY_OUTPUT_FORMATTING which is no
longer in use.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-01-26 06:15:42 -05:00
Jakub Rzeszutko 91b01ce703 shell: internal api update: history module
Add prefix z_ to internal functions handling history feature.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-01-14 12:07:25 +01:00
Jakub Rzeszutko bfb9ba022a tests: move shell tests to subsys
Move shell tests to tests/subsys directory where it belongs.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-12-03 08:04:50 -05:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Anas Nashif dca317c730 sanitycheck: inclusive language
change whitelist -> allow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-27 07:04:07 -04:00
Jakub Rzeszutko ea9fe2f5ec tests: shell_flash: fix test case scenario
The previous test had two defects. First, the shell command was called
before the backend was initialized.

Second, the test compared the string from shell's backend buffer with
the reference string using strncmp function. This test result was very
susceptible to the time when it was performed because of data contained
in the buffer. Apart from expected string there was data like escape
codes needed to control the terminal.

To fix it, function strncmp was replaced by strstr, which
searches for the reference strings regardless of the characters
controlling the terminal.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-08-05 12:01:14 +02:00
Simon Glass 740b99c937 tests: shell: shell_flash: Add a test for 'flash read'
Add a simple test for this command to check that the output is as
expected.

This requires a larger output buffer in shell_dummy, so update that
too.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-07 17:19:26 -04:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Marc Herbert debade9121 tests: make find_package(Zephyr...) REQUIRED
... because it is (required).

This makes a difference when building with CMake and forgetting
ZEPHYR_BASE or not registering Zephyr in the CMake package registry.

In this particular case, REQUIRED turns this harmless looking log
statement:

-- Could NOT find Zephyr (missing: Zephyr_DIR)
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- ...
-- ...
-- ...
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:8 (target_sources):
  Cannot specify sources for target "app" which is not built by
  this project.

... into this louder, clearer, faster and (last but not least) final
error:

CMake Error at CMakeLists.txt:5 (find_package):
  Could not find a package configuration file provided by "Zephyr" with
  any of the following names:

    ZephyrConfig.cmake
    zephyr-config.cmake

  Add the installation prefix of "Zephyr" to CMAKE_PREFIX_PATH or set
  "Zephyr_DIR" to a directory containing one of the above files.  If
  "Zephyr" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-05-29 10:47:25 +02:00
Torsten Rasmussen 407b49b35c cmake: use find_package to locate Zephyr
Using find_package to locate Zephyr.

Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.

Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.

It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Maksim Masalski 2c5be79e25 tests: remove duplicate names for the shell tests
According to the comment in #20008 I found out that some test cases
for different tests have same names.
To get rid of it, I decided to change test cases names.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2019-10-24 06:24:49 -04:00
Nicolas Pitre 70e77becb1 shell_history_test: make the test succeed on 64-bit targets
A buffer size of 128 bytes is just not quite big enough on 64-bit
targets.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-04 07:24:56 -04:00
Krzysztof Chruscinski 3555c81111 tests: shell: shell_history: Add more tests
Extended test suite with more tests for shell_history module.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-05-30 09:44:03 -04:00
Krzysztof Chruscinski c2cb60f613 shell: Refactor shell_history to use less RW memory
Shell history module reworked to use ring buffer for storing
commands. Dedicated buffer is used to story all command lineary.
History capacity is in bytes not in number of entries, e.g.
many short commands can be stored or few long (depending on
CONFIG_SHELL_HISTORY_BUFFER).

Removed implicit command null termination from shell_history and
added it to shell after fetching command line from the history.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-05-30 09:44:03 -04:00
Krzysztof Chruscinski 80f8481feb tests: subsys: shell: Add shell_history test
Add test suite for shell_history module.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-05-30 09:44:03 -04:00