Commit graph

452 commits

Author SHA1 Message Date
Peter Bigot 3d46ea5946 sanitycheck: summarize device testing targets before starting
Confirm to the user what devices were found and where they are before
starting a long run that might not have found everything it was supposed
to test.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-25 07:52:23 -05:00
Peter Bigot da7384846e sanitycheck: allow device runner board-id to differ from board id
Boards like mimxrt1060_evk are recognized by the scanner through their
USB device which has an ID, but in some cases the board may be
programmed using an external J-Link probe.  Support this by adding a
probe_id key that can be added to the yaml dictionary to override the
use of id for this purpose.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-25 07:52:23 -05:00
Peter Bigot 52356ebde4 sanitycheck: recognize more hardware
Add manufacturer and product identifiers to produce board information
for SiLabs and NXP hardware when using --generate-hardware-map.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-25 07:52:23 -05:00
Christian Taedcke c415a4ef2d sanitycheck: Fix --enable-coverage option
This commit fixes the issue, that --enable-coverage alone did not create
coverage information. It also required to give --coverage-platform.
Now the fallback for coverage-platform to platform works as documented
also for enable-coverage, not only for coverage option.

Signed-off-by: Christian Taedcke <hacking@taedcke.com>
2019-11-24 11:54:16 -05:00
Anas Nashif 19d67e4cd2 sanitycheck: support on windows
We now support building on windows. Running in Qemu still does not work.

Partially addresses #2664

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-24 07:49:44 -05:00
Anas Nashif 12d8cce8b7 sanitycheck: fix documentation of --discard-report
The discard report is now generated for every run as
sanity-out/sanitycheck_discard.csv, the option --discard-report was
dropped.

Fixes #20804

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-20 14:01:34 -05:00
Anas Nashif 3a00d0ca75 sanitycheck: record results when running on devices
Write recording.csv file when running on devices.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-15 08:05:33 -05:00
Kumar Gala a4b2b5bbf8 sanitycheck: Add support for TI XDS110 to --generate-hardware-map
Add support for boards that utilize the TI XDS110 like the CC3220SF,
CC3235SF, CC1352R1 and CC26x2R1 LaunchXL boards.  The XDS110 can expose
multiple serial endpoints one for the uart device, but another for a
trace buffer.  We assume that endpoint 0 will be the UART device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-14 09:16:50 -05:00
Kumar Gala 1ad3543ada sanitycheck: add setting runner type for J-Link & STLink
Add setting runner type to jlink for 'J-Link' and openocd for
'STM32 STLink' when generating the hardware map.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-14 09:16:50 -05:00
Stephanos Ioannidis e1827c04d3 sanitycheck: Relocate QEMU-specific code to QEMUHandler.
This commit relocates the QEMU-specific code that currently resides in
ProjectBuilder.run to QEMUHandler.handle, in order to align with what
other handlers are doing.

For more details, refer to the PR #20573.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-11-13 06:32:31 -06:00
Stephanos Ioannidis 938890041a sanitycheck: Fix incorrect QEMUHandler status reporting.
The current QEMUHandler implementation in sanitycheck does not check
for the process exit code and reports "PASS" even when either the QEMU
executable cannot be launched or exited immediately due to an error
(e.g. unsupported machine type, missing file, ...).

This commit adds QEMU process exit code check and error reporting when
the exit code is a non-zero value.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-11-13 06:32:31 -06:00
Kumar Gala ae88e442d6 sanitycheck: fix filtering for boards without DTS
If we don't have a DTS (like nrf52_bsim) we shouldn't try and create an
EDT, but we still need to call expr_parser.parse to filter testcases.
So move the os.path.exists(dts_path) around the creation of the EDT.

Fixes: #20371

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-06 13:48:08 +01:00
Anas Nashif 556f3cbaaa sanitycheck: deal with board that have no DTS
nrf52_bsim does not generate any DTS data to be processed by
sanitycheck, skip filtering if we have no dts data.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-05 19:39:39 -05:00
Anas Nashif 4f04386e61 sanitycheck: exit thread executor on exceptions
When something goes wrong, exit thread execution pool and report and
error.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-05 10:06:00 -05:00
Anas Nashif 89c83044c8 sanitycheck: get environment regardless of option specified
environment is passed to execution thread and should be available
regardless of SAN being enabled or not.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-05 10:06:00 -05:00
Jan Van Winkel 21212f30b5 sanitycheck: native: Added option to enable ASAN & LSAN
Added option to sanitycheck script to enable address - and leak
sanitizer.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-11-04 17:38:39 +01:00
Kumar Gala 9b5720d76c sanitycheck: remove import of dt kconfig symbols
All users of dt kconfig symbols for tests and samples are using dt
functions instead so we can remove the support for parsing the
generated file.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-04 09:02:14 -05:00
Kumar Gala 7733b94224 sanitycheck: Add functions to query device tree for filters
Add the following functions to allow filtering based on device tree

dt_compat_enabled(compat) - Returns true if a device tree node
compatible matches 'compat' and the node is enabled.

dt_alias_exists(alias) - Returns true if a device tree node exists with
'alias' and the node is enabled.

dt_compat_enabled_with_alias - Returns true if a device tree node
compatible matches 'compat' and the node has 'alias' and the node is
enabled.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-04 09:02:14 -05:00
Ulf Magnusson 97c310e225 sanitycheck: Remove pointless shutdown() from BoundedExecutor
Just calls through to concurrent.futures.Executor.shutdown() in the base
class, which has the same signature. Removing it means the base class
version will get used directly.

Fixes this pylint warning:

    W0235: Useless super delegation in method 'shutdown'
    (useless-super-delegation)

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 08:42:12 -05:00
Ulf Magnusson e73d286b89 sanitycheck: Make log_info_file() a regular function
Fixes this pylint warning:

    R0201: Method could be a function (no-self-use)

Could also make it a class method.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 08:42:12 -05:00
Ulf Magnusson 5c2e814212 sanitycheck: Suppress bogus not-subscriptable pylint warning
pylint gets confused by contextlib.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 08:42:12 -05:00
Anas Nashif c1ea45280b sanitycheck: enable valgrind checking using an option
Enable valgrind using --enable-valgrind option and fix reporting.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-24 12:24:48 -04:00
Flavio Ceolin ca1feea5bb sanitycheck: Fix --log-file option
save_reports should be one of the last tasks executed because it
closes the log file. Withouth it, other functions that use debug
functions like info and error will try to write into a close file.

This fixes the following problem:

sanitycheck -x=USE_CCACHE=0 -p native_posix -T samples/hello_world/ -b
-N --log-file sanity.log
JOBS: 8
Building initial testcase list...
1 test configurations selected, 0 configurations discarded due to filters.
Adding tasks to the queue...
total complete:    1/   1  100%  skipped:    0, failed:    0
1 of 1 tests passed (100.00%), 0 failed, 0 skipped with 0 warnings in
2.91 seconds
Traceback (most recent call last):
  File "./zephyr/scripts/sanitycheck", line 3866, in <module>
    main()
  File "./zephyr/scripts/sanitycheck", line 3854, in main
    suite.summary(options.disable_unrecognized_section_test)
  File "./zephyr/scripts/sanitycheck", line 2306, in summary
    self.duration))
  File "./zephyr/scripts/sanitycheck", line 432, in info
    log_file.write(what + "\n")
ValueError: I/O operation on closed file.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-10-23 16:05:39 -04:00
Thomas Stilwell 5310510d07 sanitycheck: fix --board-root parser to enable multiple path args
accidently removed during sanitycheck refactor

Signed-off-by: Thomas Stilwell <Thomas.Stilwell@nordicsemi.no>
2019-10-23 16:00:53 -04:00
Anas Nashif a5984ab1c6 sanitycheck: fail on warnings
Missed adding extra cflags to fail on warning. Adding those back.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-23 10:47:22 -04:00
Anas Nashif f72d1904f5 sanitycheck: fix error handling with host binaries
Failed unit tests were setting wrong fail string (error instead of
failed) which made unit tests always pass.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-21 09:50:48 -04:00
Flavio Ceolin 063ab90dd8 sanitycheck: Making child thread exits when main thread dies
Set threads spawned by BinaryHandler dameon, so when the main thread
exits for some unusual reason (e.g SIGINT) the child threads are
automatically killed.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-10-18 08:09:09 -05:00
Paul Sokolovsky 3ea18692c6 sanitycheck: Use os.makedirs to create --report-dir.
os.mkdir() is not suitable to create arbitrary directory path (can
create only a subdir of an existing dir, will error out if already
exists), os.makedirs() should be always used in such cases.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-10-15 11:07:12 -07:00
Anas Nashif 83fc06a8fe sanitycheck: Complete overhaul and job handling rework
A complete overhaul of the sanitycheck script and how we build and run
tests. This new version of sanitycheck uses python for job distribution
and drop use of Make.

In addition to the move to python threading library, the following has
been changed:

- All handlers now run in parallel, meaning that any simulator will run
in parallel and when testing on multiple devices (using
--device-testing) the tests are run in parallel.

- Lexicial filtering (using the filter keyword in yaml files) is now
evaluated at runtime and is no long being pre-processed. This will allow
us to immediately start executing tests and skip the wait time that was
needed for filtering.

- Device testing now supports multiple devices connected at the same
time and is managed using a hardware map that needs to be generated and
maintained for every test environment. (using --generate-hardware-map
option).

- Reports are not long stored in the Zephyr tree and instead stored in
the output directory where all build artifacts are generated.

- Each tested target now has a junit report in the output directory.

- Recording option for performance data and other metrics is now
available. This will allow us to record the output from the console and
store the data for later processing. For example benchmark data can be
captured and uploaded to a tracking server.

- Test configurations (or instances) are no longer being sorted, this
will help with balancing the load when we run sanitycheck on multiple
hosts (as we do in CI).

And many other cleanups and improvements...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-11 07:28:19 -07:00
Jorgen Kvalvaag d50fb31e19 scripts: sanitycheck: Multiple --west-flash arguments
Make --west-flash support multiple arguments

Signed-off-by: Jorgen Kvalvaag <jorgen.kvalvaag@nordicsemi.no>
2019-09-19 22:19:49 -04:00
Paul Sokolovsky 8c6d2e23f6 sanitycheck: Merge common vs per-test "filter" field values semantically
Currently, string values comming from "common" test definition section
and from test-specific section are just concatenated. Suppose, we want
to define some common filter condition, and also per-test additional
criteria. Currently, that leads to following syntax:

common:
  filter: TOOLCHAIN_FOO == 1
tests:
  sample.net.sockets.http_get.posix:
    filter: and not CONFIG_BAR

That's arguable quite adhoc, and the only way to figure it out for
most people will be to add debug logging.

This patch proposes to use the expected syntax (i.e.
"filter: not CONFIG_BAR"), and combine conditions properly based on
their semantic meaning (which also includes parans for proper
evaluation order).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-09-19 00:29:41 -04:00
Jan Van Winkel e483b11a90 sanitycheck: native: Removed --coverage from EXTRA_LDFLAGS
Removed redundant linker flag --coverage from native posix
EXTRA_LDFLAGS.

The correct linker flags will be set by defining the Kconfig flag
CONFIG_COVERAGE, either by sanitcheck it self or via the test/sample
prj.conf.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-09-17 11:25:29 +02:00
Alberto Escolar Piedras af30f2b7d4 sanitycheck: Use system gcov for unit testing by default
As a nicety for users, also select by default the system
gcov for unit_testing

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-09-17 11:17:56 +02:00
Kumar Gala 11e91a83c1 scripts/sanitycheck: optimize disk usage for --save-tests
If we are doing a nightly build we can utilize a large (over 50G) of
disk space just to generate the list of tests to build.  We need to
optimize this so as we finish building the initial pass we clean up
as we go and only keep around the files we need (like .config,
generated_dts_board.conf, CMakeCache.txt, etc).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-31 18:46:32 -04:00
Anas Nashif 578ae40761 boards: remove quarl_se_c1000
This board and SoC was discontinued some time ago and is currently not
maintained in the zephyr tree.
Remove all associated configurations and variants from the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-07-29 21:30:25 -07:00
Jukka Rissanen f95938da0f net: ppp: Initial support for point-to-point protocol
This implements ppp L2 component, LCP and IPCP modules.

Fixes #14034

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Alberto Escolar Piedras f8908cd0d8 sanitycheck: Add missing section to whitelist
In a3bea8872b (PR #16352)
_bt_br_channels_area was added to the code but not the
sanitycheck sections whitelist => Add it

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-07-12 17:08:25 -07:00
Alberto Escolar Piedras 010c609bba sanitycheck: update sections whitelist
In c20ff1150f
and 5f19c8160a
(PR #16897)
_bt_settings_area was replaced with _settings_handlers_area

Update sanitycheck sections whitelist accordingly

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-07-12 13:36:13 +02:00
Michael Scott 4ca54390f4 sanitycheck: handle west-flash dependency for device-testing
sanitycheck --help mentions that west-flash requires device-testing
to be enabled (and indeed it does because DeviceHandler will never
be called where west_flash option is used.  Let's generate an error
if west-flash is used w/o specifying device-testing.

Also cleanup help text which looks odd in both sanitycheck --help
and in the file itself.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-07-10 08:13:57 -07:00
Michael Scott 421ce46f4b sanitycheck: add west-runner parameter
Several boards have multiple runners setup.  We need a way to specify
which runner to use with sanitycheck.  Introduce --west-runner option.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-07-10 08:13:57 -07:00
Marc Herbert c7633de038 sanitycheck: fix priority of --extra-args=CONFIG_ over testcase.yaml
sanitycheck takes any "extra_config" list found in the testcase.yaml
file and generates an "overlay" file from it. This file is placed in
the per-test build directory and passed to cmake/kconfig.cmake through a
-DOVERLAY_CONF= option set in the (also) generated sanity-out/Makefile.

This commit moves this generated config overlay to a subdirectory one
level down from the build directory, otherwise kconfig.cmake picks it
up *twice*: once from the -DOVERLAY_CONF= option already mentioned above
and a second time because kconfig.cmake scans the build directory and
blindly picks up ALL files ending with .conf[*]. The second pickup is
problematic because kconfig.cmake currently gives it the top precedence,
even higher than anything the user espressed with --extra-args=CONFIG_*

Here's a quick and simple demonstration of the issue fixed by this
commit:

  cd $ZEPHYR_BASE/samples/net/sockets/net_mgmt/
  sanitycheck -T. -p qemu_x86 -b -v # --extra-args=CONFIG_USERSPACE=y|n
  grep CONFIG_USERSPACE $(find sanity-out/ -name .config)

  .net_mgmt.kernelmode/zephyr/.config: # CONFIG_USERSPACE is not set
    .net_mgmt.usermode/zephyr/.config: CONFIG_USERSPACE=y

  grep 'Merged configuration' $(find sanity-out/ -name build.log)

Without this commit, attemps to override anything with
--extra-args=CONFIG_ are silently dropped on the floor.

For more background this issue was found while using the recipe in
commit message 4afcc0f8af

[*] picking up all .conf files is debatable but a much bigger debate
with backward compatibility implications. This small fix makes
absolutely zero difference to anyone or anything not using sanitycheck.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-07-09 19:16:30 -07:00
Andrew Boie 49cf4867c7 sanitycheck: select gcov tool based on target
Use PATH gcov if no SDK in use, or native-posix derived
targets are in use.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-09 10:20:31 +02:00
Marc Herbert e5cedcae43 sanitycheck help: how to spot tests that were not run and just built
There are a few reasons why sanitycheck will only build a test and not
run it: list them in the developer guide. Also lists the --options that
provide that information and update their --help message.

A couple other --help fixes.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-07-08 08:07:57 -04:00
Marc Herbert d7ca903b72 sanitycheck: replace cmake -H "not meant for public use" with -S
https://www.mail-archive.com/cmake-developers@cmake.org/msg16769.html

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-07-08 08:04:39 -04:00
Marc Herbert 9e57338efd sanitycheck: fix --jobs help message + other cosmetic fixes
The --jobs default was recently changed in commit 9f4f57eed3, update
its help message.

Add the hopefully last missing verbose("Spawning...") statement.

Fix comment updated in commit 095b82a301.

Replace two tags with whitespace.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-07-03 23:04:16 -07:00
Andrew Boie 1578ef71b1 sanitycheck: workaround file limits
sanitycheck is opening an insane number of file descriptors
simultaneously as it opens up communication pipes with
every test that supports emulation, on every emulated
board target.

Increase the resource limit on open files until this code
can be properly refactored.

Workaround for: #17239

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-03 16:49:21 -04:00
Andrew Boie 8047a6f4d0 sanitycheck: make coverage reports easier to do
- The --gcov-tool argument now has a reasonable default
  if the Zephyr SDK is in use.
- --coverage-platform, if unspecified, defaults to what
  was passed to --platform
- --coverage implies --enable-slow, so that tests with
  the 'slow' tag are built and run.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 22:56:14 -04:00
Andrew Boie 095b82a301 sanitycheck: correct timeout extension comment
This wasn't discussing why there is extra time for when
code coverage is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 22:54:24 -04:00
Andrew Boie 9f4f57eed3 sanitycheck: don't multiply CPU count
We have a number of timing sensitive tests which run
correctly on a much more frequent basis if the system
is not so heavily loaded. Instead of squeezing a few
more crumbs of performance by doubling the CPU count,
just use the number of CPUs reported by the system.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 22:51:24 -04:00
Andrew Boie d62e229680 sanitycheck: extend coverage timeout
If GCOV coverage is enabled, the coverage dump happens after
"PROJECT EXECUTION SUCCESSFUL" is printed. In some cases,
the additional time added was not enough to capture all the
GCOV output on a heavily loaded system before the emulator
gets killed.

Ideally, the decision to kill the emulator needs to be smarter
and less race-prone, but that can wait for a future
enhancement.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 20:30:41 -04:00
Alberto Escolar Piedras b91f37494b sanitycheck: Minor optimization in BinaryHandler
Do not search for the valgrind binary (which) if valgrind
was not selected to be used.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-07-02 18:49:44 -04:00
Alberto Escolar Piedras 649368c018 sanitycheck: Record time used in BinaryHandler
So the time used to run boards which use the BinaryHandler can be
reported, record the time used from spawning the process until
it finnishes or is killed.
The BinaryHandler is used by the "native" boards, unit tests,
nsim and Renode.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-07-02 18:49:44 -04:00
Marc Herbert 35dc96399c sanitycheck: show handler_time in -v output (qemu 2.032s)
We already have the info so let's show it. This helps spots intermittent
issues[*], gives an indication of the time --build-only saves, can help
spot an overloaded test system, highlights the most time-consuming tests
which may need a longer timeout in their config, shows the effective
timeout value when one occurs... all this for a dirt cheap screen estate
price and two extra lines of code.

Sample -v output:

32/81 board123  tests/testme              PASSED (qemu 2.049s)
33/81 board456  samples/hello             PASSED (build)
34/81 qemu_x3   tests/kernel.stack.usage  FAILED: timeout (qemu 60.029s)
     see: sanity-out/qemu_x3/tests/kernel.stack.usage/handler.log
35/81 board456  tests/testme              PASSED (build)
36/81 qemu_x5   tests/kernel.queue        FAILED: failed (qemu 2.191s)
     see: sanity-out/qemu_x5/tests/kernel.queue/handler.log

[*] running qemu in heavily packed cloud virtual machines comes to mind,
    also see #12553, #14173 etc.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-21 13:47:32 -04:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Tyler Hall bb359257bf scripts/sanitycheck: fix ZEPHYR_BASE subdir check edge case
There is a case where using startswith to determine if a path is a
subdirectory of another path can erroneously match. When using a
testcase root outside of ZEPHYR_BASE, an erroneous match will cause the
relative path containing ".." to get prepended to the test output
directory.

Example:

$HOME/zephyr/zephyr # ZEPHYR_BASE
$HOME/zephyr/zephyr-rust/tests # testcase root

The relative path prepended to the testcase name is ../zephyr-rust/tests
and an example test output dir is
./sanity-out/qemu_x86/../zephyr-rust/tests/rust/rust.main

In this case, the build directory escapes the board directory and is no
longer unique. Parallel tests then clobber each other.

Use pathlib instead of string matching to cover this case.

Signed-off-by: Tyler Hall <tylerwhall@gmail.com>
2019-06-19 13:56:26 -04:00
Kumar Gala 84cf9dc671 scripts/sanitycheck: Add --cmake-only option
Add an option that only invokes the cmake phase of sanitycheck.  This
can be useful for any testing that only needs to initial generation
phase of cmake, for example device tree.  Also useful if we want to
just generate compile_commands.json files from cmake via:

./sanitycheck -xCMAKE_EXPORT_COMPILE_COMMANDS=1 --cmake-only

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-18 12:02:03 -04:00
Anas Nashif 49b22d4fc3 sanitycheck: report tests that never build/run
Add new option --report-excluded to list all those tests with bad
filtering that never build or run. This option produces accurate results
with --all but can be used with default sanitycheck options to see what
does not run/build in CI for example. (limited coverage).

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-16 14:13:25 -04:00
Luiz Augusto von Dentz a3bea8872b Bluetooth: L2CAP: Move fixed channels to its own section in ROM
This changes the declaration of fixed channels to be statically defined
with use of BT_L2CAP_CHANNEL_DEFINE since fixed channels are never
unregistered.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-29 16:31:03 +03:00
Jan Van Winkel 6b9e160b5a sanitycheck: Execute binary in output directory
Execute the test binary from the output directory instead of directory
where sanitycheck was started.

This will ensure that any artifact created with a relative path by the
test binary will be placed in the output directory instead of creating
the artifact in the directory where sanitycheck was executed and prevent
any possible conflicts.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-05-23 08:37:09 -04:00
Marc Herbert 75276a7d97 sanitycheck: when present, point at handler.log instead of run.log
When Zephyr crashes immediately QEMU reports an error immediately. This
is immediately reported by "make run". Then sanitycheck points the user
at the output of "make run". However the error message(s) are in QEMU's
output which is in a different .log file.

To address this situation point the error message at handler.log
instead of run.log if and only if handler.log is not empty.

To reproduce here's an artificial but very simple crash:

  sanitycheck --extra-args=CONFIG_TEST_USERSPACE=n \
    -p qemu_x86 -T tests/kernel/mem_protect/stackprot/

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-05-21 08:28:07 -04:00
Andy Doan cbecaddff1 sanitycheck: Add a "test-only" option
This makes it easy to re-run tests from an existing build directory
w/o trying to rebuild artifacts.

Signed-off-by: Andy Doan <andy@foundries.io>
2019-05-16 07:08:01 -05:00
Andy Doan 79c48849fe sanitycheck: Allow custom arguments for west-flash
This allows you to use west to flash the device and pass custom
arguments to the flash command.

Signed-off-by: Andy Doan <andy@foundries.io>
2019-05-16 07:08:01 -05:00
Jukka Rissanen 89bf1578d9 net: sockets: Add a way to register a socket family handler
Allow automatic handling of registered socket families.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-10 22:43:27 +03:00
Marc Herbert 1c8632cfaa sanitycheck: support symbolic links in ZEPHYR_BASE
Fix issue where sanitycheck wrongly assumed tests inside ZEPHYR_BASE
to be outside ZEPHYR_BASE and dropped the prefix in their name. This
happened when:
- ZEPHYR_BASE contains symbolic link(s), and
- relative --testcase-root argument(s) are passed

To generate unique names, TestCase.get_unique(testcase_root) first
checks whether "testcase_root" starts with ZEPHYR_BASE. Either may or
may not include symbolic links so both must be canonicalized before
comparison. While fixing this method, replace explicit forward slash
"/" and string replace with os.path.relpath() and make a couple other
simplifications and minor pydoc fixes.

Add new canonical_zephyr_base = os.path.realpath(ZEPHYR_BASE) constant
and corresponding comments and guidelines.

The most visible effect of this mismatch was sanitycheck dropping the
--testcase-root prefix from the unique name of tests inside
ZEPHYR_BASE. This means some test names could be not unique anymore
and silently overwrite each other's results, example:

 bash# cd zephyr_dir_with_symlink; export ZEPHYR_BASE=$(pwd)
 ./scripts/sanitycheck -T samples/portability/cmsis_rtos_v1 \
                       -T samples/portability/cmsis_rtos_v2

The more systematic and practical consequence (and how I actually
found this) was test outputs landing in unexpected locations.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-05-07 23:19:35 -04:00
Marc Herbert af1090c3bd sanitycheck: clarify who spawns processes and threads and where
Notably fix the wrong comment I added in commit 6f011c95c477: when
testing with QEmu sanitycheck does _not_ spawn QEmu; it relies on "make
run" instead.

Searching the code for "Spawning" now cycles directly to all the places
starting processes and threads.

- Sample -v -v verbose output (lines wrapped for commit message check)

 Spawning QEMUHandler Thread for \
     qemu_x86/samples/hello_world/sample.helloworld 'make run'

- native_posix example:

 Spawning process /home/.../sanity-out/native_posix/\
    /samples/hello_world/sample.helloworld/zephyr/zephyr.exe
 Spawning BinaryHandler Thread for native_posix/\
     samples/hello_world/sample.helloworld

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-05-04 18:29:01 -04:00
Luiz Augusto von Dentz e0f3ab6bf2 Bluetooth: GATT: Add support for static services
This reintroduces support for static service in the form of a new API,
BT_GATT_SERVICE_DEFINE, and changes the internal services (GAP/GATT)
to be defined as const as they are never register/unregistered.

Internal service needed to be renamed in order to keep the same order
as before since the section elements are sorted by name.

The result is the following (make ram_report):

before:
      gatt.c                                    572     0.66%
        cf_cfg                                   32     0.04%
        db                                        8     0.01%
        db_hash                                  16     0.02%
        db_hash_work                             32     0.04%
        gap_attrs				180     0.21%
        gap_svc                                  12     0.01%
        gatt_attrs                              160     0.18%
        gatt_sc                                  80     0.09%
        gatt_svc                                 12     0.01%
        sc_ccc_cfg                               32     0.04%
        subscriptions                             8     0.01%

after:
      gatt.c                                    210     0.24%
        cf_cfg                                   32     0.04%
        db                                        8     0.01%
        db_hash                                  16     0.02%
        db_hash_work                             32     0.04%
        gatt_sc                                  80     0.09%
        last_static_handle                        2     0.00%
        sc_ccc_cfg                               32     0.04%
        subscriptions                             8     0.01%

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-02 08:29:23 +03:00
Flavio Ceolin bf878ced12 sanitycheck: Fix an error in scan_path exception
The function error expects only one parameter. The excpetion handler in
scan_path was calling this function with multiple parameters instead of
formatting the string.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-04-28 13:38:32 -04:00
Anas Nashif d18ec53575 sanitycheck: show handler in verbose mode
When running in verbose mode, show what handler is being used.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-20 14:14:47 -04:00
Anas Nashif d6476eee3e sanitycheck: handle pid file not being present
Do not try to open non-existing pid files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-20 14:14:47 -04:00
Anas Nashif 042d9b7d83 sanitycheck: fix reporting: build vs. run
If build fails, report a build failure instead of handler error.

Fixes #15272

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-20 14:14:47 -04:00
Anas Nashif 654ec598ac sanitycheck: add timestamps to messages
Using the new option --timestamps, any output from sanitycheck will have
a timestamp to help identify bottle necks and monitor execution time.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-20 14:14:47 -04:00
Marc Herbert 0f7255c3b8 sanitycheck: order results.csv and discards.csv deterministically
One of the first things needed when comparing builds of tests across
different environments/systems is to make sure the same (sub)tests were
selected and run in the first place. For that purpose sort the output of
--testcase-report and --discard-report as they were in random order.

Actually make the entire class TestInstance sortable by adding a
standard __lt__() method comparing unique instance names; it could be
useful again.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-04-17 08:28:54 -04:00
Andrew Boie 9e69c54060 sanitycheck: add more info during processing
After the testcase configs are built, there is a step to
filter all the test case information to determine the set
of tests to run.

As this step takes a nontrivial amount of time, add an
informational message about it.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-10 13:09:28 -04: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
Anas Nashif 366ed11bfa sanitycheck: deal with special charachters in xml
Some logging text and colors were not escaped correctly, make sure we
generate well formed XML reports.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-01 12:23:09 -04:00
Anas Nashif f16e92c000 sanitycheck: count samples in reports
We have not been counting samples in reports. This change lists tests
associated with sample code which in many cases is just verifying output
from the sample and counts as 1 test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-01 12:23:09 -04:00
Marc Herbert 682961a382 sanitycheck: document that --save-tests appends to existing file
Fix --help message. Also rename run_report() to save_tests() as it's
used only once by --save-tests and nowhere else. Maybe the code was
shared with some --other-report feature in the past but not any more.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-03-28 09:30:00 -04:00
Marc Herbert 6f011c95c4 sanitycheck: don't generate the top-level Makefile in random order
Also add a "generated by sanitycheck" header to indicate origin and a
warning about the dependency required to actually run the test.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-03-26 22:23:56 -04:00
Marc Herbert 932a33ad75 sanitycheck: fix, expand and clarify test case selection --help
- Fix wrong --test help message
- Provide more examples to clarify naming hierarchy
- Document that --sub-test runs its entire --test
- Point out that save/load options use their own format
- Document that --list-tests is flattened

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-03-18 22:07:25 -07:00
Kumar Gala 1230ae1e63 scripts/sanitycheck: Add 'vectors' section to whitelist
Add 'vectors' to the whitelisted list of linker sections.  This is
needed by the openisa_rv32m1 SoC.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-03-13 17:02:05 -05:00
Marc Herbert 0c465bbec1 sanitycheck: make --subtest and --test mutually exclusive
They're effectively mutually exclusive already because
options.sub_test in main() immediately discards any --test
argument(s). This commit preempts user confusion thanks to this new
message:

 sanitycheck: error: argument --sub-test: not allowed with
    argument -s/--test

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-03-13 01:44:52 +01:00
Marc Herbert edf17591dd sanitycheck: group case selection options in the help message
$ sanitycheck -h # is re-ordered like this:

 < ... all other options ... >

 -C, --coverage        Generate coverage reports. Implies
                       --enable_coverage

 --coverage-platform   COVERAGE_PLATFORM
                       Plarforms to run coverage reports on. This
                       option may be used multiple times.

Test case selection:

 -f, --only-failed     Run only those tests that failed the previous
                       sanity check invocation.

 -s TEST, --test TEST  Run only the specified test cases. These are
                       named by <path to test project relative to
                       --testcase-root>/<testcase.yaml section name>

 --sub-test SUB_TEST   Run only the specified sub-test cases and its
                       parent. These are named by test case name
                       appended by test function, i.e.
                       kernel.mutex.mutex_lock_unlock.
 --list-tests          list all tests.
 -F FILENAME, --load-tests FILENAME
                       Load list of tests to be run from file.
 -E FILENAME, --save-tests FILENAME
                       Save list of tests to be run to file.
 -T TESTCASE_ROOT, --testcase-root TESTCASE_ROOT
                       Base directory to recursively search for test
                       cases. All testcase.yaml files under here will
                       be processed. May be called multiple times.
                       Defaults to the 'samples' and 'tests' directories
                       in the Zephyr tree.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-03-12 08:32:49 +01:00
Daniel Leung c8066c55fc linker: remove references to _k_task_list/_k_event_list
Commit 45a7e5d076 removed scripts/sysgen
and _k_task_list/_k_event_list sections are no longer being used.
So remove them.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-03-09 16:01:23 -05:00
Daniel Leung bd40fc2c90 linker: remove references to no longer exist _k_memory_pool
Commit 73cb9586ce renamed linker
section from _k_memory_pool to _k_mem_pool, but the references
in linker scripts are still there. So remove them now.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-03-09 16:01:23 -05:00
Anas Nashif f4d8eccb70 sanitycheck: fixed handling of retries
When re-running failed tests, do not go through any filtering, just load
the failed tests directly and execute them. The filtering was done based
on default platforms and any tests that were failing on non-default
platforms were ignored.

Fixes #13956

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-03-04 14:08:12 -05:00
Anas Nashif 5923760dd5 sanitycheck: handle serial exception
Do not throw excpetion when there is no serial output, just timeout.

Fixes #13541

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-03-04 08:14:29 -05:00
Anas Nashif f9e73c90f2 sanitycheck: do no overide OVERLAY_CONFIG
We have been overriding OVERLAY_CONFIG coming from tests. Concat all
files and create one variable that we pass to kconfig as list.

Fixes #13320

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-18 10:49:08 -05:00
Kumar Gala e6393dd22e scripts/sanitycheck: Add 'nocache' section to whitelist
Add 'nocache' to the whitelisted list of linker sections.

Fixes #13449

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-16 22:14:34 -05:00
Marti Bolivar 5591ca2374 sanitycheck: various fixes for device testing
Device testing has various problems:

- the main thread doesn't halt the serial monitoring thread when an
  error occurs while flashing, meaning flash errors can look like
  timeouts

- serial_line is unbound if the ser.readline() call raises an
  exception, so the following "if serial_line" would raise NameError
  in that case

- the serial monitoring thread is not a daemon, so exceptions or
  errors in the handle() thread that cause thread exit will leave the
  process sitting around until the serial monitoring thread has a
  chance to exit

Fix these issues:

- Rewrite the serial monitoring thread as a select loop over the
  serial port file descriptor and a pipe shared by the main thread and
  serial monitoring thread. If flashing fails, the main thread uses
  the pipe to signal to the serial monitoring thread that it should
  exit.

- Make sure serial_line is always bound when read.

- Mark the serial thread daemonic.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-08 08:08:32 -05:00
Marti Bolivar 303b52268a sanitycheck: print flash output if VERBOSE
If the user has requested verbose output, then use check_call() when
running the flash target so that the build system output goes to the
controlling terminal's stdout instead of being swallowed.

This makes it easier to debug flashing failures.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-08 08:08:32 -05:00
Anas Nashif 45a9786a41 sanitycheck: support filtering based on cmake cache
Parse CMakeCache.txt and filter based on variables defined in CMake.
The CMakeCache.txt parsing is borrowed from west.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-07 22:46:10 -06:00
Anas Nashif c96c90acf7 sanitycheck: return build.log when we think we crashed
In some cases sanitycheck handles a build error that started with 'make
run' as a handler crash when it actually failed during building. Right
now we try to attach the handler.log to the XML output even if it did
not exist. Check for the file and if it was not found, go back to the
build.log

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-05 13:40:49 -05:00
Alberto Escolar Piedras 834b86f8d7 sanitycheck: coverage: Tolerate missing source files
When calling genhtml to generate a coverage report directly from
sanitycheck (-C option), call it with the "--ignore-errors source"
option, so it does not exit when it meets a missing file, but
instead it warns the user and continues.

Fixes #13014

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-02-03 15:28:53 -05:00
Andrew Boie c253a686bf app_shmem: auto-initialize partitions
There are no longer per-partition initialization functions.
Instead, we iterate over all of them at boot to set up the
derived k_mem_partitions properly.

Some ARC-specific hacks that should never have been applied
have been removed from the userspace test.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-01-30 23:15:51 -05:00
Anas Nashif f29087ee1b sanitycheck: Handle data over UART from gcov
Make sure we capture data from gcov and do not timeout before all the
data has been captured. Also report on incomplete data capture.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-29 15:03:38 -05:00
Anas Nashif 47cf4bf544 sanitycheck: add option to point to gcov-tool
When building with older versions of the toolchain we need to use gcov
from the same tool set, otherwise data formar might not be compatible.

Added an option to point to the gcov tool from the same toolchain used
to build the code. By default the host gcov is used.

Relates to #12571

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-29 15:03:38 -05:00
Anas Nashif a4b5a739d9 sanitycheck: link with --coverage only for native_posix
Link with --coverage only when building with the host toolchain.

Relates to #12571

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-29 15:03:38 -05:00
Sebastian Bøe 56d7471b0c sanitycheck: Error out when running sanitycheck from Windows
Running sanitycheck from Windows is not supported yet. Unfortunately,
the error message is obscure when a user is unaware of this and runs
it from Windows anyway.

This patch gives an easy to understand error message explaining this
issue.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-01-22 07:44:06 -05:00
Anas Nashif 74dbe338d4 sanitycheck: do not keep extending timeout
While trying to catch crashes after test completes, do not keep
extending the timeout which might lead to and endless loop and not
getting out based on set timeout.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-17 19:46:45 -05:00
Peter A. Bigot bfad9721d2 kernel: remove k_alert API
This API was used in only one place in non-test code.  See whether we
can remove it.

Closes #12232

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-01-16 21:34:07 -05:00
Anas Nashif dbd7649fc0 sanitycheck: add option to specify platforms with coverage support
We want to run coverage on select platforms even if a few do support
that now. Specify which platforms should be enabled using the new option

--coverage-platform

By default we have the posix platform configured. Any additional
platforms can be specified using the option above.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-16 06:12:33 -05:00
Anas Nashif db9592aa3e sanitycheck: convert gcov data to gcda
Collect data generated by built-in gcov over UART.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-16 06:12:33 -05:00
Jan Kowalewski 265895b293 sanitycheck: Add Renode support
The change adds an optional capability to kill process by PID in the
BinaryHandler. At the moment proc.terminate only closed the make
process, also closing the stdin/stdout, but this is impossible to detect
in .NET.

Signed-off-by: Dawid Wojciechowski <dwojciechowski@internships.antmicro.com>
Signed-off-by: Jan Kowalewski <jkowalewski@antmicro.com>
Signed-off-by: Piotr Zierhoffer <pzierhoffer@antmicro.com>
2019-01-14 09:12:07 -05:00
Andy Ross dc4151f8f3 scripts/sanitycheck: Don't build "slow" tests either
Extend the "slow" flag on tests to inhibit building too.  The original
assumption was that building would be fast but running slow, but now
We have tests using a component (OpenThread) that wants to pull and
build software from github for every app.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-04 14:59:28 -05:00
Andy Ross 9c9162dfd9 sanitycheck: Add --disable-size-report option
The segment size computation has value, but it's actually a very slow
process that parallizes poorly.  It seems to be bound by the Python
GIL doing the parsing, so never sees more than about 150% of CPU in
use even on wildly parallel systems.  And it takes about 75-80
seconds, which is 15-20% of the entire runtime of the test on that
box!

And the only "failure" case this can detect (unexpected sections in
the output file) is now a duplicate of the orphan section warning
we've since enalbled at the linker level.

This defaults to enabling the test to preserve behavior (as I don't
know where all the existing users of the size report are to change
them), but long term we might consider making "disabled" the default
and switching this to an --enable flag.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-03 16:06:28 -05:00
Alberto Escolar Piedras 3980e0cf64 sanitycheck: Use supression file for valgrind and dump log
When running valgrind in sanitycheck, use the suppression file
and dump the log in its own file.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-12-21 21:07:18 +01:00
Alberto Escolar Piedras 661bc8206f sanitycheck: Fail test if the process returns != 0
If the test process returns an error (return code != 0),
it should be considered a failure, even if the handler
considers the test passed.
But this is not done when we are killing (SIGTERM) the processes,
as then the return code is not necessarily sensible.

Without this, for example, when running with valgrind, all valgrind
errors are missed.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-12-21 21:07:18 +01:00
Anas Nashif 1c65b6b3a4 sanitycheck: filter by device tree configs
In addition to Kconfig values from generated .config, also parse and
filter based on configs generated by device-tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-12-11 13:13:26 -06:00
Anas Nashif 724d6f7909 sanitycheck: add new _TEXT_SECTION_NAME_2 section to whitelist
Add _TEXT_SECTION_NAME_2 to the whitelisted list of linker sections.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-12-07 16:50:24 -05:00
Andrew Boie c2e01dff3f workqueues: don't put k_work in special section
There's no current need for this and it makes work items
declared with K_WORK_DEFINE() inaccessible to user mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-11-29 09:21:18 -08:00
Bobby Noelte 9cf8b3cd20 sanitycheck: fix false passed on localized error message
Fix false passed on localized error message in make invocation.

Fixes #8348

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-21 20:04:19 -05:00
Anas Nashif f114a1383d sanitycheck: outdir should not be relative to ZEPHYR_BASE
We should leave ZEPHYR_BASE alone and create the test output wherever
we are running.
This will support running sanitycheck on test roots other than zephyr's
main git repo.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-21 15:05:07 +01:00
Anas Nashif f18ad9dd4b sanitycheck: support running tests out of the tree
right now we assume we are running the tests inside the Zephyr tree and
things do not work well when someone tries to use sanitycheck on tests
outside the tree with a different test root. Cleanup the name handling
and support running outside of Zephyr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-21 15:05:07 +01:00
Anas Nashif 3cbffefb26 sanitycheck: use overlays to enable coverage
Set COVERAGE option using an overlay instead of piping it through CMAKE
which breaks dependecies, i.e. if someone wants to disable that option
on the application level.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-15 08:31:34 -05:00
Anas Nashif 8d72bb909f sanitycheck: remove dependency of coverage on native_posix
Make it more generic and depend on Kconfig taking care of dependencies.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-15 08:31:34 -05:00
Anas Nashif 4df6c565d2 sanitycheck: ignore generated headers in outdir
With this, we will get results for the same file for every build (tests
and samples).

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-15 08:31:34 -05:00
Anas Nashif 7dd19ea74d sanitycheck: filter by test fixtures
Support specifying a test fixture attached to a board to filter in/out
tests that require this fixture to be able to run a test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-14 23:42:45 -05:00
Sebastian Bøe 03ed0950e5 sanitycheck: Allow skipping the 'unrecognized section' test
Allow the user to disable the "unrecognized section" test. I can see
multiple use-cases for disabling the test.

If orphan sections exist and are dynamically or unpredictably named
the unrecognized section test will fail.

If out-of-tree sections exist, one might want to temporarily disable
the "unrecognized section" test until one has made it recognized.

The test is disabled through a CLI flag.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-13 11:13:33 -05:00
Andrew Boie 506f15c381 interrupts: simplify position of sw ISR table
We now place the linker directives for the SW ISR table
in the common linker scripts, instead of repeating it
everywhere.

The table will be placed in RAM if dynamic interrupts are
enabled.

A dedicated section is used, as this data must not move
in between build phases.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-11-10 11:01:22 -05:00
Anas Nashif a4c368ef07 sanitycheck: only log printable chars
New Qemu is emitting binary charachters which is disturbing generation
of XML, so make sure we only log printable charachters.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-05 11:00:38 -05:00
Adithya Baglody 1fa8cf9279 linker: arm: place priv.noinit at the end of RAM
This puts the priviledged stack at the end of RAM.
This combines PR #10507 and #10542.

Fixes #10473
Fixes #10474
Fixes #10515

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2018-10-19 16:11:34 -04:00
Anas Nashif 924a4e7000 sanitycheck: support requirements on env variables
Some boards depend on environment variables so we want to make sure we
do not attempt to build boards requiring additional setup.

Add the section below into the board YAML file, sanitycheck will check
the environment and will only run tests on that board if the variables
are defined.

env:
  - VAR1
  - VAR2

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-19 10:57:54 -04:00
Johann Fischer fcffebfe15 sanitycheck: whitelist font entry section
Whitelist font entry section.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-10-16 14:54:47 -04:00
Alberto Escolar Piedras 3777b4452d sanitycheck: nf52_bsim testcases to run with other native
To be able to collect all coverage reports from the "native"
applications in the first CI instance, let's also place the
nrf52_bsim testcases first. The order now is:
 unit_testing
 native_posix
 *_bsim
 anything else

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-10-15 09:36:37 -04:00
Anas Nashif 2c7636bc88 sanitycheck: fix skipped element in junit output
The skipped element was left empty, fill it with details to make parsers
happy.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-13 11:35:45 -04:00
Anas Nashif 1ea5d7b472 sanitycheck: run tests based on sub-testcases
run tests based on sub-testcases, for example:
  sanitycheck  --sub-test net.app.app_tcp4_client_hostname_fail

will run all the tests in tests/net/app/net.app.

Useful for re-running tests that are reported in testrail and in reports
generated by sanitycheck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-13 11:35:45 -04:00
Anas Nashif 07d54c042e sanitycheck: force configured toolchain
Do not check for board/toolchain combination and if a certain toolchain
is configured for a board, run with whatever toolchain we have.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-13 11:35:45 -04:00
Sebastian Bøe 5681f87fd7 sanitycheck: Support legacy variant 'gccarmemb'
CMake will translate from the toolchain variant 'gccarmemb' to
'gnuarmemb', but sanitycheck does not. This causes inconsistent and
therefore confusing behaviour between CMake and sanitycheck.

Until gccarmemb is dropped support for, do the same translation with
sanitycheck.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-12 11:05:07 -04:00
Praful Swarnakar cf89e2883d sanitycheck: Add fixture option for external hardware dependecy
Add a new option as fixture in harness configurations for utilizing
sanitycheck to identify test cases that require external hardware
such as sensor, ble, networking for validation. The config will be
added to yaml files with unique fixture name to identify each hardware
and allow automation to trigger test execution on setup having the
specific fixture enabled. Also, remove the default required for type and
regex configs that is not essential in case of ztest based test cases.

Signed-off-by: Praful Swarnakar <praful.swarnakar@intel.com>
2018-10-10 19:11:29 -04:00
Anas Nashif ba4643b778 sanitycheck: remove special ansi charachters from xml
XML does not like special ansi charachters (coming from logger), so
remove them.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-09-23 13:04:05 -04:00
Krzysztof Chruscinski 6aed72e487 shell: Shell subsystem reimplementation
New shell support features like:
- multi-instance
- command tree
- static and dynamic commands
- multiline
- help print function
- smart tab (autocompletion)
- meta-keys
- history, wildcards etc.
- generic transport (initially, uart present)

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2018-09-19 09:30:29 -04:00
Anas Nashif 39ae72b4cb sanitycheck: capture delayed faults
Do not close console after PASS is reported, wait a bit for any
remaining messages from the tests, sometimes we have faults that need to
be parsed.
This now works for Qemu handler, support for other handlers to follow.

Fixes #9646

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-08-30 15:05:30 -04:00
Oleg Zhurakivskyy f3bc967e49 sanitycheck: Overcommit the default number of jobs
Overcommit the default number of jobs by factor 2
to keep the original behavior intact.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-19 13:12:15 -07:00
Oleg Zhurakivskyy 99aacd9808 sanitycheck: Rename CPU_COUNTS to JOBS
This would correspond the help and avoid cpus/threads confusion.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-19 13:12:15 -07:00
Oleg Zhurakivskyy c97054c1c9 sanitycheck: Fix the logic for jobs
multiprocessing.cpu_count() already returns the number of threads
(not cores), no need to multiply it by 2.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-19 13:12:15 -07:00
Oleg Zhurakivskyy 42822083c4 sanitycheck: Get ZEPHYR_BASE only once
Also clean up ZEPHYR_BASE discovery.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-19 13:12:15 -07:00
Anas Nashif b4bdd66924 sanitycheck: exit on exceptions
Exit on exceptions with crashing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-08-16 13:22:10 -07:00
Shawn Mosley 573f32b6d2 userspace: compartmentalized app memory organization
Summary: revised attempt at addressing issue 6290.  The
following provides an alternative to using
CONFIG_APPLICATION_MEMORY by compartmentalizing data into
Memory Domains.  Dependent on MPU limitations, supports
compartmentalized Memory Domains for 1...N logical
applications.  This is considered an initial attempt at
designing flexible compartmentalized Memory Domains for
multiple logical applications and, with the provided python
script and edited CMakeLists.txt, provides support for power
of 2 aligned MPU architectures.

Overview: The current patch uses qualifiers to group data into
subsections.  The qualifier usage allows for dynamic subsection
creation and affords the developer a large amount of flexibility
in the grouping, naming, and size of the resulting partitions and
domains that are built on these subsections. By additional macro
calls, functions are created that help calculate the size,
address, and permissions for the subsections and enable the
developer to control application data in specified partitions and
memory domains.

Background: Initial attempts focused on creating a single
section in the linker script that then contained internally
grouped variables/data to allow MPU/MMU alignment and protection.
This did not provide additional functionality beyond
CONFIG_APPLICATION_MEMORY as we were unable to reliably group
data or determine their grouping via exported linker symbols.
Thus, the resulting decision was made to dynamically create
subsections using the current qualifier method. An attempt to
group the data by object file was tested, but found that this
broke applications such as ztest where two object files are
created: ztest and main.  This also creates an issue of grouping
the two object files together in the same memory domain while
also allowing for compartmenting other data among threads.

Because it is not possible to know a) the name of the partition
and thus the symbol in the linker, b) the size of all the data
in the subsection, nor c) the overall number of partitions
created by the developer, it was not feasible to align the
subsections at compile time without using dynamically generated
linker script for MPU architectures requiring power of 2
alignment.

In order to provide support for MPU architectures that require a
power of 2 alignment, a python script is run at build prior to
when linker_priv_stacks.cmd is generated.  This script scans the
built object files for all possible partitions and the names given
to them. It then generates a linker file (app_smem.ld) that is
included in the main linker.ld file.  This app_smem.ld allows the
compiler and linker to then create each subsection and align to
the next power of 2.

Usage:
 - Requires: app_memory/app_memdomain.h .
 - _app_dmem(id) marks a variable to be placed into a data
section for memory partition id.
 - _app_bmem(id) marks a variable to be placed into a bss
section for memory partition id.
 - These are seen in the linker.map as "data_smem_id" and
"data_smem_idb".
 - To create a k_mem_partition, call the macro
app_mem_partition(part0) where "part0" is the name then used to
refer to that partition. This macro only creates a function and
necessary data structures for the later "initialization".
 - To create a memory domain for the partition, the macro
app_mem_domain(dom0) is called where "dom0" is the name then
used for the memory domain.
 - To initialize the partition (effectively adding the partition
to a linked list), init_part_part0() is called. This is followed
by init_app_memory(), which walks all partitions in the linked
list and calculates the sizes for each partition.
 - Once the partition is initialized, the domain can be
initialized with init_domain_dom0(part0) which initializes the
domain with partition part0.
 - After the domain has been initialized, the current thread
can be added using add_thread_dom0(k_current_get()).
 - The code used in ztests ans kernel/init has been added under
a conditional #ifdef to isolate the code from other tests.
The userspace test CMakeLists.txt file has commands to insert
the CONFIG_APP_SHARED_MEM definition into the required build
targets.
  Example:
        /* create partition at top of file outside functions */
        app_mem_partition(part0);
        /* create domain */
        app_mem_domain(dom0);
        _app_dmem(dom0) int var1;
        _app_bmem(dom0) static volatile int var2;

        int main()
        {
                init_part_part0();
                init_app_memory();
                init_domain_dom0(part0);
                add_thread_dom0(k_current_get());
                ...
        }

 - If multiple partitions are being created, a variadic
preprocessor macro can be used as provided in
app_macro_support.h:

        FOR_EACH(app_mem_partition, part0, part1, part2);

or, for multiple domains, similarly:

        FOR_EACH(app_mem_domain, dom0, dom1);

Similarly, the init_part_* can also be used in the macro:

        FOR_EACH(init_part, part0, part1, part2);

Testing:
 - This has been successfully tested on qemu_x86 and the
ARM frdm_k64f board.  It compiles and builds power of 2
aligned subsections for the linker script on the 96b_carbon
boards.  These power of 2 alignments have been checked by
hand and are viewable in the zephyr.map file that is
produced during build. However, due to a shortage of
available MPU regions on the 96b_carbon board, we are unable
to test this.
 - When run on the 96b_carbon board, the test suite will
enter execution, but each individaul test will fail due to
an MPU FAULT.  This is expected as the required number of
MPU regions exceeds the number allowed due to the static
allocation. As the MPU driver does not detect this issue,
the fault occurs because the data being accessed has been
placed outside the active MPU region.
 - This now compiles successfully for the ARC boards
em_starterkit_em7d and em_starterkit_em7d_v22. However,
as we lack ARC hardware to run this build on, we are unable
to test this build.

Current known issues:
1) While the script and edited CMakeLists.txt creates the
ability to align to the next power of 2, this does not
address the shortage of available MPU regions on certain
devices (e.g. 96b_carbon).  In testing the APB and PPB
regions were commented out.
2) checkpatch.pl lists several issues regarding the
following:
a) Complex macros. The FOR_EACH macros as defined in
app_macro_support.h are listed as complex macros needing
parentheses.  Adding parentheses breaks their
functionality, and we have otherwise been unable to
resolve the reported error.
b) __aligned() preferred. The _app_dmem_pad() and
_app_bmem_pad() macros give warnings that __aligned()
is preferred. Prior iterations had this implementation,
which resulted in errors due to "complex macros".
c) Trailing semicolon. The macro init_part(name) has
a trailing semicolon as the semicolon is needed for the
inlined macro call that is generated when this macro
expands.

Update: updated to alternative CONFIG_APPLCATION_MEMORY.
Added config option CONFIG_APP_SHARED_MEM to enable a new section
app_smem to contain the shared memory component.  This commit
seperates the Kconfig definition from the definition used for the
conditional code.  The change is in response to changes in the
way the build system treats definitions.  The python script used
to generate a linker script for app_smem was also midified to
simplify the alignment directives.  A default linker script
app_smem.ld was added to remove the conditional includes dependency
on CONFIG_APP_SHARED_MEM.  By addining the default linker script
the prebuild stages link properly prior to the python script running

Signed-off-by: Joshua Domagalski <jedomag@tycho.nsa.gov>
Signed-off-by: Shawn Mosley <smmosle@tycho.nsa.gov>
2018-07-25 12:02:01 -07:00
Anas Nashif f3d48e1cce sanitycheck: allow blacklisting boards
Add new kwyboard to board definition to allow blacklisting boards. This
is needed when a board is broken causing CI to fail without a fix in
sight.

Add:

sanitycheck: false

to the board yaml file to disable the board. By default, the value is
set to true.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-24 09:58:18 -04:00
Anas Nashif d2b3c75403 Revert "sanitycheck: set state correctly in case of a crash"
This reverts commit d74a56bd63.

Still not soving the issue and introducing additional problems.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-23 12:58:31 -04:00
Anas Nashif d74a56bd63 sanitycheck: set state correctly in case of a crash
sanitycheck not printing QEMU console in some cases where a crash
happens and when state is not set correctly.

Fixes #9061

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-22 22:14:10 -04:00
Anas Nashif e24350c775 sanitycheck: do not run if we do not have nsimdrv
Check if we have nSim simulator in path, if not, just test build without
attempting to run.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-19 18:59:07 -04:00
Anas Nashif 99f5a6cfed sanitycheck: support additional handlers
Support nsim simulator with 'make run'.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-19 18:59:07 -04:00
Anas Nashif df7ee61c09 sanitycheck: merge native and unit handlers
The two handlers were doing pretty much the same with minor differences,
unify them into one single handler BinaryHandler that will be able to
handle additional targets.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-19 18:59:07 -04:00
Anas Nashif 4a9f3e63b8 sanitycheck: do not redefine handler_log
handler_log was being redefined, define it in the Handler class as log
only.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-19 18:59:07 -04:00
Anas Nashif 1377375af2 sanitycheck: refactor add_goal
refactor all add_goal routines in to one single function that can handle
multiple platforms. Move everything to one single add_goal function.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-19 18:59:07 -04:00
Alberto Escolar Piedras b1045fee59 sanitycheck: Do not calculate size for native builds
For native builds it does not make much sense to calculate
the size of the suposed RAM or ROM, or to check that new
unexpected sections did not appear.
So let's save the time and not do it.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-07-18 15:43:12 -04:00
Alberto Escolar Piedras c026c2ed82 sanitycheck: control coverage from command line
Added a new command line options to sanitycheck:
--enable-coverage which will compile for native_posix
with CONFIG_COVERAGE set, and unit tests accordingly.
+
Now -C --coverage implies also --enable-coverage.

Background:
After 608778a4de
it is possible to add Kconfig options from command
line during the cmake invocation.
So we can use it to set CONFIG_COVERAGE for the native_posix
target when we need to instead of relaying on it always
being compiled with coverage enabled.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-07-03 08:36:06 -04:00
Anas Nashif 0b68560463 sanitycheck: whitelist logging sections
Whitelist recently add sections in the logging subsystem.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-06-29 17:48:26 -05:00
Andrew Boie 3efd2693b3 sanitycheck: fix spammy build output
VERBOSE if set to any value enables verbose build output,
setting to 0 does not have the intended effect.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-06-27 03:52:45 -04:00