Commit graph

46 commits

Author SHA1 Message Date
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
Daniel Leung b7eb04b300 x86: consolidate x86_64 architecture, SoC and boards
There are two set of code supporting x86_64: x86_64 using x32 ABI,
and x86 long mode, and this consolidates both into one x86_64
architecture and SoC supporting truly 64-bit mode.

() Removes the x86_64:x32 architecture and SoC, and replaces
   them with the existing x86 long mode arch and SoC.
() Replace qemu_x86_64 with qemu_x86_long as qemu_x86_64.
() Updates samples and tests to remove reference to
   qemu_x86_long.
() Renames CONFIG_X86_LONGMODE to CONFIG_X86_64.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-10-25 17:57:55 -04:00
Anas Nashif 9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Paul Sokolovsky bf070716d1 tests: mbedtls: Call mbedtls_platform_set_printf() only if needed
It exists only if MBEDTLS_PLATFORM_PRINTF_ALT is defined, whcih we
no longer do, but make the call condiitonal in case we'll need to
make it configurable later.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-05-23 09:27:59 -04:00
Ryan QIAN 46289bed0c tests: change the min_ram for mbedtls and mem_protect
- Change the min_ram to 36K, since they can't be built on RT1015 which
has 32K ram.

Signed-off-by: Ryan QIAN <jianghao.qian@nxp.com>
2019-05-14 12:23:42 -05:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Andrew Boie 7b1ee5cf13 tests: CONFIG_TEST_USERSPACE now off by default
Unlike CONFIG_HW_STACK_PROTECTION, which greatly helps
expose stack overflows in test code, activating
userspace without putting threads in user mode is of
very limited value.

Now CONFIG_TEST_USERSPACE is off by default. Any test
which puts threads in user mode will need to set
CONFIG_TEST_USERSPACE.

This should greatly increase sanitycheck build times
as there is non-trivial build time overhead to
enabling this feature. This also allows some tests
which failed the build on RAM-constrained platforms
to compile properly.

tests/drivers/build_all is a special case; it doesn't
put threads in user mode, but we want to ensure all
the syscall handlers compile properly.

Fixes: #15103 (and probably others)

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie 027b6aaf89 tests: set userspace tag for all tests that use it
This lets us quickly filter tests that exercise userspace
when developing it.

Some tests had a whitelist with qemu_cortex_m3; change
this to mps2_an385, which is the QEMU target with an
MPU enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie e686aefe09 mbedtls: provide user mode access
The mbedtls library has some globals which results in faults
when user mode tries to access them.

Instantiate a memory partition for mbedtls's globals.
The linker will place all globals found by building this
library into this partition.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-03-05 08:27:20 -05:00
Anas Nashif 99beaed7c0 tests: mbedtls: report results once only
We were reporting results twice, something that might confuse test
systems and end up reporting wrong results. Assert if any self-tests
have failed and report at the very end.

Disable test on x86_64.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-03-04 17:32:08 -08:00
Anas Nashif 3b745cc648 mbedtls: enable self-test in config-tls-generic.h
MBEDTLS_SELF_TEST is needed when setting CONFIG_MBEDTLS_TEST

Fixes #13919

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-03-04 17:32:08 -08:00
Andrew Boie feab37096b libc: fix CONFIG_STDOUT_CONSOLE semantics
The intent of this Kconfig is to allow libc stdout
functions like printf() to send their output to the
active console driver instead of discarding it.

This somehow evolved into preferring to use
printf() instead of printk() for all test case output
if enabled. Libc printf() implementation for both
minimal libc and newlib use considerably more stack
space than printk(), with nothing gained by using
them.

Remove all instances where we are conditionally
sending test case output based on this config, enable
it by default, and adjust a few tests that disabled
this because they were blowing stack.

printk() and vprintk() now work as expected for
unit_testing targets, they are just wrappers for
host printf().

Fixes: #13701

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-26 08:00:33 -06:00
Anas Nashif 5060ca6a30 cmake: increase minimal required version to 3.13.1
Move to latest cmake version with many bug fixes and enhancements.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-01-03 11:51:29 -05:00
Patrik Flykt 440b535602 tests: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Reto Schneider 7eabab2f5d samples, tests: Use semi-accurate project names
When using an IDE (e.g. Eclipse, Qt Creator), the project name gets
displayed. This greatly simplifies the navigation between projects when
having many of them open at the same time. Naming every project "NONE"
defeats this functionality.

This patch tries to use sensible project names while not duplicating
too much of what is already represented in the path. This is done by
using the name of the directory the relevant CMakeLists.txt file is
stored in. To ensure unique project names in the samples (and again, in
the tests folder) folder, small manual adjustments have been done.

Signed-off-by: Reto Schneider <code@reto-schneider.ch>
2018-10-27 21:31:25 -04:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Flavio Ceolin a1135620ba misc: printk: Change function return
The result of both printk and vprintk are not used in any place.
MISRA-C says that the return of every non void function must be
checked.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Flavio Ceolin 502db21672 tests: crypto: mbedtls: Fix mbedTLS self test usage
All _self_test functions should be called only if MBEDTLS_SELF_TEST is
enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-06 21:11:31 -04:00
Flavio Ceolin 8b70ace563 crypto: tests: Change crypto tests to use Kconfig defined header
While it's possible to define which mbedTLS config header to use, our
samples should use config-tls-generic.h as default because this header
is configurable through Kconfig.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-06 21:11:31 -04:00
Sebastian Bøe 55ee53ce91 cmake: Prepend 'cmake_minimum_required()' into 'app' build scripts
Prepend the text 'cmake_minimum_required(VERSION 3.8.2)' into the
application and test build scripts.

Modern versions of CMake will spam users with a deprecation warning
when the toplevel CMakeLists.txt does not specify a CMake
version. This is documented in bug #8355.

To resolve this we include a cmake_minimum_required() line into the
toplevel build scripts. Additionally, cmake_minimum_required is
invoked from within boilerplate.cmake. The highest version will be
enforced.

This patch allows us to afterwards change CMake policy CMP000 from OLD
to NEW which in turn finally rids us of the verbose warning.

The extra boilerplate is considered more acceptable than the verbosity
of the CMP0000 policy.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-08-15 04:06:50 -07:00
Andrew Boie aa26d9926a tests: mbedtls: don't use stdout console
This redirects PRINT() to printf() and not printk() and
was causing stack overflows on some platforms.

Fixes: #8033

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-30 15:55:18 -05:00
Praful Swarnakar 0e1a03b866 tests: crypto: mbedtls: enabled test for esp32
Removed esp32 platform exclusion to allow test
to run on esp32 hardware.

Signed-off-by: Praful Swarnakar <praful.swarnakar@intel.com>
2018-03-09 21:29:08 -05:00
Andy Ross 61c0189b91 tests/crypto/mbedtls: Disable CONFIG_FORCE_NO_ASSERT
The root cause for this issue was found in
https://github.com/zephyrproject-rtos/zephyr/issues/6470
so this kconfig isn't needed anymore.

This is a partial reversion of 6eef2f14.  The actual feature is left
in place, as it's plausibly useful in other contexts (otherwise
assertions enabled by sanitycheck can't be disabled by the app as
they're passed in via CFLAGS).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-03-06 14:13:56 -08:00
Anas Nashif 10d75d478d tests: crypto: stop relying on path for naming
Use proper test names instead of relying on path name where the test is
located.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-18 09:16:40 -05:00
Andy Ross 6eef2f1485 misc: Add a FORCE_NO_ASSERT kconfig directive
The mbedtls test is hitting a compiler bug where two subtests will
soft fail on qemu_xtensa when assertions are enabled.  This is despite
the fact that:

+ The failure is entirely internal to the mbedtls suite.
+ The mbedtls code does not use zephyr asserts
+ The mbedtls code does not call into zephyr code that might assert.
+ The behavior persists even when an irq_lock() is held across the
  entire test, ruling out any asserts in interrupt/exception context.
+ And EVEN WHEN the mbedtls library blobs are bytewise identical
  between assert and non-assert cases.

The bug seems to be a layout thing where the mbedtls code behavior
differently based on code address and/or link-time optimizations
(xtensa has a few).

Unfortunately sanitycheck enables assertions by setting CFLAGS
directly and not via kconfig, so we can't fix this by turning the
feature off in an app right now.  This patch adds a simple "override"
flag that can be set by apps like this that hit bugs.

Again, note that zephyr assertions are not used nor needed by this one
test.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-02-16 10:44:29 -05:00
Paul Sokolovsky 42680b07af mbedtls: Switch default MBEDTLS_CFG_FILE to config-mini-tls1_2.h
The previous default, "config-threadnet.h", is more or less arbitrary
choice made in a commit 312def2c78 1.5 years ago. In particular,
it's not related to Thread support in Zephyr per se (there was no
such support at that time).

It doesn't make sense to have a default intended for a particular,
not widely used (yet) protocol. Instead, the default should work
out of the box with a contemporary widely deployed arrays of TLS
servers, which are HTTPS server. config-mini-tls1_2.h works with
https://google.com, and by extension, with many other servers on
the Internet.

So, have that as the default, and let applications with special
needs to override that to what they need.

Addresses: #6132

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-02-15 12:35:31 -05:00
Anas Nashif e76de53202 test: mbedtls: remove while loop
Remove useless while loop from test, it serves no purpose.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-25 04:45:35 +05:30
Sebastian Bøe 6f642a19fd cmake: Ported mbedTLS to use Zephyr interface libraries
mbedTLS include directories will now default to be in the 'app'
include path when mbedTLS has been enabled.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-02 22:09:01 -05:00
Anas Nashif 23f81eeb42 tests/samples: fixed yaml syntax
Use a map directory, avoid the list which makes parsing a bit
cumbersome.

Fixes #5109

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Nishikant c1d9cb72f1 tests/crypto/mbedtls: Disabling this test for ESP32
Currently Zephyr is running from RAM, and the space where
instructions can be executed from is quite small.once Flash
cache is enabled in ESP32 port we can remove this check.

Signed-off-by: Nishikant Nayak <nishikantax.nayak@intel.com>
2017-11-18 07:48:30 -05:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Anas Nashif 0356590df5 tests: samples: fix yaml syntax
Fix indentation and syntax and make it pass yamllint tool.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-15 08:15:00 -04:00
Anas Nashif 704f879f8a tests: ztest: call test_main() without arguments
Arguments are not needed and in some cases are being set as unused in
the same function. The test_main function is called from ztest main
routine without any arguments.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-24 09:29:14 -07:00
Kumar Gala 9075e1e368 tests: crypto: mbedtls: set a code size constraint
We have a few systems with small amounts of flash that this test can't
fit into.  For now I set the limit right above 32k, however that might
need to get bumped up if we have any systems with flash sizes between
32k and 64k.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-08-24 10:26:33 -04:00
Niranjhana N 4e40b843e4 tests: mbedtls: convert to ztest
- replaced CONFIG_MAIN_STACK_SIZE with CONFIG_ZTEST_STACKSIZE
  in the config file
- split the main file into two files:
    - main.c has ztest entry and runs separate functions for ztest
    - mbedtls.c has the original routines

JIRA: ZEP-2449

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-07 22:39:47 -04:00
Anas Nashif 5f63386c34 tests: crypto: fix coding style
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-06 10:34:41 -05:00
Anas Nashif 8d108c9d59 tests: mbedtls: cleanup prj.conf
Remove platform specific option CONFIG_ARC_INIT and a copy/pasted
comment with "#nothing here".

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-05 12:43:13 -04:00
Anas Nashif 52a4916cab tests: crypto: do not build when DEBUG is enabled
The external mbedTLS library seems to have some issues when DEBUG is
enabled, so disable this here becauase we will not change external 3rd
party code.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-05 12:43:13 -04:00
Jean-Paul Etienne b31b41604e tests: crypto: include back riscv32 arch for ecc_dh, ecc_dsa and mbedtls
Issue fixed by commit "riscv32: fixed context restore upon exiting ISR"

Jira: ZEP-2020

Signed-off-by: Jean-Paul Etienne <fractalclone@gmail.com>
2017-06-30 06:31:51 -04:00
Anas Nashif 470c5f3189 tests: remove testcase.ini files
We now use yaml files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 20:56:53 -04:00
Anas Nashif cc24f4b03c tests: samples: convert testcase files to yaml
This will prepare test cases and samples with metadata and information
that will be consumed by the sanitycheck script which will be changed to
parse YAML files instead of ini.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 20:56:53 -04:00
Anas Nashif 397d29db42 linker: move all linker headers to include/linker
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-18 09:24:04 -05:00
Anas Nashif 0772abff24 tests: rename test directory test_mbedtls -> mbedtls
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-17 10:34:24 -04:00