Commit Graph

240 Commits

Author SHA1 Message Date
Sebastian Bøe c25ac487af tests: crypto: rand32: Check return code of sys_csrand_get
Check the return code of sys_csrand_get when testing the function.

Ignoring it is bad practice and can also be a security issue if users
copy-paste this test code.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2024-01-03 23:57:13 -06:00
Alberto Escolar Piedras 6568825174 tests/crypto/*: Switch from native_posix to native_sim
Enable these tests which run in native_posix in native_sim,
Switch from native_posix to native_sim as default test platform
For drivers.rand32.random_psa_crypto, filter the posix
arch to save some CI time, as TFM is not supported in this
architecture all together.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-27 16:06:42 +00: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
Flavio Ceolin f9c7a5e6fb kernel: random: Rename early random get function
Rename z_early_boot_rand_get with z_early_rand_get to get consistent
with other early functions.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-13 10:03:53 +03:00
Flavio Ceolin e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03:00
Flavio Ceolin 646a06c9fe random: Fix kconfig symbol name
s/CSPRING_ENABLED/CSPRNG_ENABLED/g

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-09-27 11:55:10 -05:00
Anas Nashif b835b02136 tests: cleanup metadata and filtering
- Add integration_platforms to avoid excessive filtering
- Make sure integration platforms are actually part of the filter
- Fix some tags and test meta data

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-13 09:38:27 -04:00
Anas Nashif 0064b6e8b6 tests: samples: cleanup test tags, add integration_platforms
Use integration platforms and sanitize tags.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-02 04:47:06 -04: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
Keith Packard bfa6a44746 tests,samples: Fix picolibc malloc arena settings
With picolibc moving to using the common malloc implementation, samples and
tests with picolibc-specific settings need to switch to using the common
malloc settings instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-05-09 01:29:16 +09:00
Anas Nashif fcefc27823 tests: remove intel adsp cavs platforms from filters
Remove all filters related to dropped platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-06 18:51:56 +02:00
Anas Nashif 693e9915fd tests: tinycrypt: do not use TC_START for debugging
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Anas Nashif e7af676be9 tests: mbedtls: do not use TC_START for debugging
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Anas Nashif 126053c0e2 tests: tinycrypt_hmac_prng: do not use TC_START for debugging
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Andrzej Głąbek 29d7c90779 tests: Align zephyr,psa-crypto-rng node names with those used by SoCs
This is a follow-up to commit 9951971aee.

Align names of "zephyr,psa-crypto-rng" compatible nodes used in tests
(crypto/rand32 and drivers/entropy/api) with those introduced by the
above commit into SoC definitions (nRF5340/nRF9160). This way the test
overlays will overwrite the already existing nodes instead of adding
second instances of them, what leads to build failures at the linking
stage as the related driver supports only single instance (and creates
it for the first node found).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-02-07 14:26:18 +01:00
Anas Nashif ed79b1f25e tests: use namespacing in extra_configs and drop duplicated scenarios
Use namespacing with extra_configs in some tests and remove duplicated
scenarios the were made arch or platform specifc.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-13 09:42:59 +01:00
Henrik Brix Andersen 11aa8454f0 Revert "random: Change testing random generator"
This reverts commit d6881de3b3.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-09 19:29:50 +09:00
Declan Snyder d6881de3b3 random: Change testing random generator
The old random timer test was not random-looking
enough on some platforms.

Replace with new test which is psuedo-xoshiro.

The generator is still deterministic
and does not depend on entropy at all,
but should look more random for testing.

Change name of generator tree-wide also.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-09 10:16:55 +01:00
Fabio Baltieri 7db1d17ee3 yamllint: fix all yamllint line-length errors
Fix all line-length errors detected by yamllint:

yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
  grep '(line-length)'

Using a limit is set to 100 columns, not touching the commandlines in
GitHub workflows (at least for now).

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 01:16:45 +09:00
Keith Packard 5b845d60ba tests/mbedtls: Reduce MPU partition usage for picolibc
Disable the picolibc heap to avoid using one MPU partition.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-11-08 10:44:36 +01:00
Neil Armstrong 62dc712a50 test: drivers: rand32: add overlay for PSA Crypto Random entropy
This adds an overlay DT & config to enable the PSA Crypto Random entropy
driver to get random bytes from TFM.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2022-10-27 16:32:05 +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
Enjia Mai 66da4c2854 tests: crypto: move the tinycrypt test to new ztest API
Migrate the testsuite tests/crypto/tinycrypt to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-01 20:36:15 -04:00
Enjia Mai 64f096d264 tests: crypto: move the tinycrypt_hmac_prng test to new ztest API
Migrate the testsuite tests/crypto/tinycrypt_hmac_prng to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-01 20:36:15 -04:00
Enjia Mai 7a39635f0d tests: crypto: move the rand32 test to new ztest API
Migrate the testsuite tests/crypto/rand32 to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-01 20:36:15 -04:00
Enjia Mai ae30549207 tests: crypto: move the mbedtls test to new ztest API
Migrate the testsuite tests/crypto/mbedtls to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-01 20:36:15 -04:00
Enjia Mai eab566a533 tests: crypto: move the crypto_hash test to new ztest API
Migrate the testsuite tests/crypto/crypto_hash to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-01 20:36:15 -04: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
Hu Zhenyu 5921eccf1b test: tests/crypto/tinycrypt timeout
It takes more than 300 seconds to finish the test,
so enlarge the timeout value from 300 to 500(seconds)

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-06-29 20:59:31 -04:00
Marcin Niestroj 945b5085c5 tests: crypto: mbedtls: remove default mbedTLS options
Whenever MBEDTLS_BUILTIN is selected then
CONFIG_MBEDTLS_CFG_FILE="config-tls-generic.h" is set as a default value.
It is even impossible to change it, as without CUSTOM_MBEDTLS_CFG_FILE it
is just a hidden (not configurable by user) Kconfig option.

Remove explicit configuration from prj.conf.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-23 09:10:03 +02:00
Marcin Niestroj 96e9971797 tests: crypto: crypto_hash: remove default mbedTLS options
Whenever MBEDTLS_BUILTIN is selected then
CONFIG_MBEDTLS_CFG_FILE="config-tls-generic.h" is set as a default value.

Remove explicit configuration from prj.conf.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-23 09:10:03 +02:00
Stephanos Ioannidis 4735e10630 libc: minimal: Introduce CONFIG_MINIMAL_LIBC_NON_REENTRANT_FUNCTIONS
This commit introduces a new configuration called
`CONFIG_MINIMAL_LIBC_NON_REENTRANT_FUNCTIONS`, which enables the
traditional non-reentrant (i.e. not thread-safe) version of the C
standard library functions such as rand() and gmtime() when the
respective configs are enabled.

The non-reentrant functions make use of the globals and require an
additional memory partition (MPU region), which is scarce on low-end
devices, when CONFIG_USERSPACE=y.

The purpose of this option is to classify the MPU resource intensive
functions as a separate category and only enable them when there is a
demand for such.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-01 11:03:38 +02: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
Anas Nashif 7323038129 tests: tinycrypt: fix test output
This onse single test with multiple dataset was pretending to be
multiple tests with output that is missing and causing confusion when
results get evaluated for example by twister.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-08 09:36:34 +02:00
Anas Nashif 736520a4fe tests: mbedtls: exclude m2gl025_miv
This test just takes forever on this platform. Exclude it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-03-30 21:39:56 -04:00
Flavio Ceolin 890f619936 tests: mbedtls: Fix GCC warning about `test_snprintf`
Fix errors like:

inlined from ‘test_mbedtls’ at
zephyrproject/zephyr/tests/crypto/mbedtls/src/mbedtls.c:172:6:
zephyrproject/zephyr/tests/crypto/mbedtls/src/mbedtls.c:96:17: error:
‘test_snprintf’ reading 10 bytes from a region of size 1
[-Werror=stringop-overread]
   96 |                 test_snprintf(1, "", -1) != 0 ||
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~

In GCC >= 11 because `ret_buf` in some calls are shorter literals

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-03-23 18:14:07 -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
Flavio Ceolin 72bc514f4a tests: crypto: Add test for hashing on crypto driver
Test crypto driver hash capability.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-03-01 16:32:43 -05:00
Carles Cufi 4b8f1c04ab kconfig: Rename the ZTEST stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Ederson de Souza 6e8338a5b6 tests/crypto: Don't build tinycrypt tests under XCC
XCC (based on GCC 4.2) doesn't support some asm constraints used by
tinycrypt, so let's not test tinycrypt under XCC.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-02-21 19:37:54 -05:00
Daniel Leung 8f7f62869a tests: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Anas Nashif d4962db828 tests: m2gl025_miv: exclude slow platform from some tests
This platform is slow on some tests and times out on non-hardware
related tests, so exclude it or increase timeout for some of the tests
to avoid false negatives in the test results due to timeouts.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-29 19:39:38 -05:00
Daniel Leung bb595a85f1 kernel: mem_domain: add/remove partition funcs to return errors
This changes both k_mem_domain_add_partition() and
k_mem_domain_remove_partition() to return errors instead of
asserting when errors are encountered. This gives the application
chance to recover.

The arch_mem_domain_parition_add()/_remove() will be modified
later together with all the other arch_mem_domain_*() changes
since the architecture code for partition addition and removal
functions usually cannot be separately changed.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-11-22 12:45:22 -05:00
Flavio Ceolin 2bc9059bd2 tests: crypto: Follow changes in mbedTLS 3.0 version
Apply the modifications required by the newer library version.
These modifications came from the original file in the mbedTLS
repository.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-10-07 14:02:40 -05: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
Jordan Yates fdeaa9103e random: deprecate `XOROSHIRO_RANDOM_GENERATOR`
Deprecate the xoroshiro128+ PRNG algorithm in favour of xoshiro128++.
xoshiro128++ is a drop-in replacement which is invisible from the user
perspective.

xoroshiro128+ is unsuitable because it is explicitly a floating-point
PRNG, not a general-purpose PRNG. This means that the lower 4 bits of
the output are actually linear, not random (from the designers,
https://prng.di.unimi.it/). This means 1/8th of the generated data is
not random.

Additionally, xoroshiro128+ is not a 32bit algorithm, it operates on
64bit numbers. For the vast majority of Zephyr devices, this makes the
PRNG slower than it needs to be. The replacement (xoshiro128++) is
32bit, with no loss in state space (still 128 bit).

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-05 11:24:44 +02:00
Jordan Yates 3a204adf7b tests: crypto: rand32: test xoshiro128 impl
Validate the xoshiro128++ implementation against the randomness tests.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-05 11:24:44 +02:00
Yasushi SHOJI 5e535a8551 tests: crypto: mbedtls: Remove local implementation of rand()
When MBEDTLS_RSA_C is defined, mbedtls define its local version of
rand() function.  Since we already have rand() in our minimal libc, we
can safely remove this.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2021-07-20 13:32:36 -04:00
Jian Kang e169015c6e tests: crypto: Add a unnormal testing condition
For z_early_boot_rand_get(), give a length less than uint32 to be input
value, ensure the API can work normally with error condition to improve
code coverage.

Signed-off-by: Jian Kang <jianx.kang@intel.com>
2021-03-09 05:10:54 -05:00
Andy Ross 3d81464194 tests: samples: Add targetted platform_excludes for intel_adsp_cavs15
This platform has a tiny handful of remaining tests that fail.  We
will track them as issues, but let's exclude them from integration
testing to allow full runs to complete.  Often a hung device in one
test will break an entire twister run.

Tests with known (and tracked) failures:

  samples/application_development/external_lib
  samples/posix/eventfd
  samples/userspace/hello_world_user
  tests/kernel/fatal/message_capture
  tests/net/socket/socketpair
  tests/portability/cmsis_rtos_v2

These tests never fail in isolated testing, but are reliable timeouts
when run in sequence in a big twister run.  It's possible that the bug
here may be in twister or the flash/serial scripts:

  tests/crypto/tinycrypt
  tests/subsys/logging/log_immediate
  tests/subsys/logging/log_output

See: #32836

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 19:25:25 -05:00