Commit graph

452 commits

Author SHA1 Message Date
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
Andrei Emeltchenko c6b38a2a86 usb: tests: Add usb_bos_desc to sanitycheck table
Fix check warnings

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-06-20 15:47:00 -04:00
Andrei Emeltchenko 391cf424a7 usb: tests: Add missing sections to sanitycheck
Fix warnings during sanitycheck

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-06-15 11:02:05 +02:00
Ruslan Mstoi 33fa63e40e sanitycheck: Add progress to verbose mode
In verbose mode (-v) progress of running test cases number out of total
number is not printed. Thus, if there are many test cases, it is
impossible to follow the progress. This commit adds printing of current
test case and total numbers to the verbose output.

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2018-06-11 17:30:58 -04:00
Anas Nashif 5d6e7eb7c6 sanitycheck: export list of tests as CSV
Export tests to a file with Section, subsection and identifier as
columns making it easy to import testcases into test management system.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-06-07 18:01:49 -05:00
Andrew Boie 29599f6d80 sanitycheck: deprecate assertion options
This is now done directly in Kconfig for tests.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-24 15:12:56 -07:00
Anas Nashif 333a315f7b sanitycheck: improve help message
Aply some feedback to the help messages of sanitycheck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-24 16:55:55 -04:00
Andy Ross a3a7e8e781 sanitycheck: Add support for _bt_settings_area linker section
This section got added in commit 470349c25a ("Bluetooth: settings:
Add support for per-submodule handlers"), but sanitycheck didn't know
about it and was whining.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-05-23 20:54:36 -04:00
Andy Ross dec163fe83 sanitycheck: Disable parallel builds with Ninja
Ninja and GNU make don't play well with each other.  Both try to start
enough processes to keep the system's CPUs busy, resulting in an
O(N^2) system load in the number of processors.

Long term, Ninja seems likely to support the GNU make jobserver
mechanism for sharing access to parallelism.  But for now we can get
90% of the way there with a simple hack: just run ninja in serial mode
with -j1.  Sanitycheck when run in non-trivial circumstances has
PLENTY of parallelism just from the number of test cases.

One interesting note is that even with -j1, system loads under ninja
are rather higher.  That may be because of significant work done in
the (serial) makefiles that dilutes the parallelism of the eventual
build, or possibly because ninja itself is multithreaded in its setup
code.  So I tweaked the number of jobs down to keep the load roughly
where it is with make.

With this change, I see no difference in behavior or system load, and a
~24% improvement in runtime.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-05-22 10:17:22 -04:00
Anas Nashif 61e2163ec9 sanitycheck: support skipped tests, enhance device handler
- Some tests start with test_, some do not, so make sure we parse both.
- Parse skipped tests
- Improve handling of test case identifier
- Handle Exceptions in device handler

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-08 07:56:18 -04:00
Anas Nashif a3abe967d6 sanitycheck: do not count duplicate tests
Some tests are being reused to reset or re-init state, ignore them in
accounting.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-08 07:56:18 -04:00
Anas Nashif 37f9dc5c2d sanitycheck: simplify argument passing and use global options
We are passing global arguments from one level to the next when those
variables are available globally. Reduce the arguments and remove unused
arguments as well.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-08 07:56:18 -04:00
Anas Nashif d3384fb71c sanitycheck: cleanup handler class
init class in one place, no need to duplicate all class members in every
subclass.
run_log is not needed in the handler class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-08 07:56:18 -04:00
Anas Nashif e0a6a0b692 sanitycheck: parse test results and create detailed report
Parse the test results and create a test report with more granular
results that can be imported to into test management/reporting system.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-08 07:56:18 -04:00
Anas Nashif 73440ead7d sanitycheck: device handler, allow running tests on real hw
This will allow us to run sanitycheck on real devices and get reporting
out of it the same way we do that with Qemu.

To use this, run sanitycheck with the following new options:

 scripts/sanitycheck --device-testing --device-serial /dev/ttyACM0 -p
 frdm_k64f  -T tests/crypto/

--device-serial denotes the serial device the board is connected to.
This needs to be accessible by the user running sanitycheck. You can
run this on one board only at a time, the board is specified using the
--platform option.

This was tested with only a few boards, some board will not work
because how they reset the serial device during flashing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-08 07:56:18 -04:00
Alberto Escolar Piedras 770178b76e sanitycheck: Stop on linker warnings also in native_posix
After removing the -T linker warning for the POSIX arch
we can, and should, also treat its linker warnings as errors

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-05-02 10:19:09 -04:00
Inaky Perez-Gonzalez 75e2d901e7 sanitycheck: refinements to --list-tests
This packs a few improvements:

- Add a smarter regex that will catch multiple combinations of

    ztest_[user_]unit_test[_setup_teardown](NAME[, setup, teardown])

  as well as single liners like:

    ztest_test_suite(mutex_complex, ztest_user_unit_test(TESTNAME));

- Limit how much we look forward in suite_regex -- we don't have to
  look past the first argument, otherwise we consume too much and the
  loopup at suite_regex_match.start() will start too late.

- Remove include_regex, unused

- Fix the path where we warn about matches in achtung_regexes--it
  needed a few decodes and to use error() vs the unexistant warning()

- Cleanup the path to produce the subcase names, doing the decode and
  the purging of any test_ prefix in scan_path().

Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2018-04-26 21:27:57 +05:30
Håkon Øye Amundsen de223cce8a sanitycheck: Updated helptext to -O/--outdir argument.
This addresses issue #7146.

The current helptext does not state that the directory
will be deleted.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2018-04-25 17:37:29 +05:30
Anas Nashif c0149cc01d sanitycheck: support listing test cases
Parse all yaml file and create a list of declared testcases. This does
list the individual tests inside test projects, not only the projects
containing the tests, for example:

$ sanitycheck --list-tests  -T tests/net/socket/
 - net.socket.udp.send_recv_2_sock
 - net.socket.udp.v4_sendto_recvfrom
 - net.socket.udp.v6_sendto_recvfrom
 - net.socket.udp.v4_bind_sendto
 - net.socket.udp.v6_bind_sendto
 - net.socket.getaddrinfo_ok
 - net.socket.getaddrinfo_no_host
 - net.socket.tcp.v4_send_recv
 - net.socket.tcp.v6_send_recv
 - net.socket.tcp.v4_sendto_recvfrom
 - net.socket.tcp.v6_sendto_recvfrom
 - net.socket.tcp.v4_sendto_recvfrom_null_dest
 - net.socket.tcp.v6_sendto_recvfrom_null_dest
13 total.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-25 14:18:15 +05:30
Anas Nashif aae71d74dd sanitycheck: parse test cases from source files
This parses the tests that run within a test project/application from
the source code and gives us a view of what was run, skipped and what
was blocked due to early termination of the test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-25 14:18:15 +05:30
Kumar Gala c84235eee3 sanitycheck: Exit on load errors
If we have some error parsing a testcase or other files we treat these
as errors and will exit before continuing on building other tests.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-04-10 18:28:21 -04:00
Anas Nashif 75547e2b40 sanitycheck: add option to list all available tags
To avoid duplication when adding a new testcase.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 13:29:37 -04:00
Anas Nashif 5df8cff046 sanitycheck: simplify logic of build_only/enable_slow checking
Make checking for flags readable and fix logic for enable_slow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 13:29:37 -04:00
Anas Nashif ab351f407a sanitycheck: do not create overlays for filtered platforms
Only create those for tests/boards we are actually going to run.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 13:29:37 -04:00
Anas Nashif 20f553fe8d sanitycheck: do not call cmake twice on run
In many cases we are calling cmake twice with the same options, first to
build, and then we do the same thing when we want to call 'make run'.
Just call cmake once.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 13:29:37 -04:00
Anas Nashif 424a3db775 sanitycheck: do not always dump footprint statistics
When running large set of tests we always get a huge list of footprint
changes that mask the test results making them impossible to see on the
screen. Show the footprint results only on-demand and not on every
build.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 13:29:37 -04:00
Jukka Rissanen 6049207a29 net: Add initial TX and RX traffic class support
With this commit it is possible to add priority to sent or received
network packets. So user is able to send or receive higher priority
packets faster than lower level packets.
The traffic class support is activated by CONFIG_NET_TC_COUNT option.
The TC support uses work queues to separate the traffic. The
priority of the work queue thread specifies the ordering of the
network traffic. Each work queue thread handles traffic to one specific
work queue. Note that you should not enable traffic classes unless
you really need them by your application. Each TC thread needs
stack so this feature requires more memory.

It is possible to disable transmit traffic class support and keep the
receive traffic class support, or vice versa. If both RX and TX traffic
classes are enabled, then both will use the same number of queues
defined by CONFIG_NET_TC_COUNT option.

Fixes #6588

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-27 10:06:54 -04:00
Jukka Rissanen 47dafffb67 net: if: Separate IP address configuration from net_if
Move IP address settings from net_if to separate structs.
This is needed for VLAN support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-27 10:06:54 -04:00
Anas Nashif 25f6ab62c7 Revert "sanitycheck: Default to using Ninja"
This reverts commit 0e6689d559.

Parallel builds are broken due to a mix of Make/Ninja and the job server
not being operational.

See https://github.com/ninja-build/ninja/issues/1139

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-03-20 12:31:52 -04:00
Anas Nashif 7fe35cf886 sanitycheck: check for deprecated variant env variable
For those still using old variable ZEPHYR_GCC_VARIANT.
raise an error if the variable is not defined.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-15 08:53:25 -05:00
Erwin Rol cb3d127981 sanitycheck: add ccm_bss, ccm_noinit and ccm_data sections
Add the STM32 ccm_bss, ccm_noinit, abd ccm_data sections
to the list of allowed sections so the sanity check passes.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-02-13 12:36:22 -06:00
Anas Nashif 7ee8bb9677 build: deprecate ZEPHYR_GCC_VARIANT
We want to support other toolchain not based on GCC, so the variable is
confusing, use ZEPHYR_TOOLCHAIN_VARIANT instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-13 07:44:45 -08:00
Sebastian Bøe 0e6689d559 sanitycheck: Default to using Ninja
It is important that it is easy to reproduce CI issues locally. Using
the same sanitycheck options locally and in CI helps in this
regard. Specifically, Ninja and Make can produce different results and
therefore the default generator should be the same for sanitycheck and
shippable.

This patch makes four changes:

The sanitycheck option '--make' is introduced to allow specifying Make
as a generator.

CI no longer passes the option '--ninja' to sanitycheck.

Sanitycheck defaults to using Ninja.

Sanitycheck documents the --ninja option as deprecated.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-02-12 08:24:23 -05:00
Alberto Escolar Piedras bc101c5b25 sanitycheck: better coverage report generation
When generating coverage report:
* Also generate branch coverage
* If the report is properly generated tell user where to find it
* Handle case in which no ztests are run (it would crash before)

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-02-11 11:09:42 -05:00
Alberto Escolar Piedras 25e0636c84 doc: Sanitycheck command line options fixup
Aligned sanitycheck command line options in doc
with the actual ones.
+
Minor fix in --coverage description.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-02-10 13:22:06 -05:00
Alberto Escolar Piedras c6524abc39 CI: also generate coverage for unit tests
sanitycheck: Compile unit tests with coverage enabled always
      + run also first unit tests together with native_posix
shippable: also include unit_testing coverage into report to
      codecov

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-02-09 07:39:55 -05:00
Andy Gross c59d6cb760 scripts: sanitycheck: Add MPU userspace related sections
This patch adds app_pad and priv_stacks to the rw section list so that
tests which validate the sections found in the binary pass when run on
systems which contain MPUs.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-02-07 11:14:12 -06:00
Anas Nashif 9a839df82e sanitycheck: rename qemu_crash -> handler_crash
qemu is only one of many handler we support now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-06 20:59:35 -05:00
Anas Nashif a49048b9db sanitycheck: all handlers produce the same log now
Rather than having handler generate differently named log files,
generate the same for all handlers, so qemu, native and unit will now
generate handler.log.

This will simplify things and reporting will be consistent.  Also, this
fixes a bug where we only included qemu.log in generated reports.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-06 20:59:35 -05:00
Anas Nashif b630ca6292 sanitycheck: fixed function documentation
Functions now accept a different set of parameters, adapt the docs

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-06 20:59:35 -05:00
Alberto Escolar Piedras 2151b864d4 sanitycheck: fix crashes with symlinks in path
When building the testcase path, replace symlinks in path
with the realpath both in the testcase root and in ZEPHYR_BASE

For more info see issue #5772

Fixes: #5772

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-01-29 23:50:08 -05:00
Kumar Gala 0d48cbe13e sanitycheck: default to assertions being enabled
Changed the default behavior for when we run sanitycheck to match the -R
flag that turns on assertions.  Introduced a --disable-asserts option if
we desire to explicitly turn of asserts.

This matches behavior that our CI builds have been doing and addresses
part of #5726.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-01-27 05:18:10 +05:30
Anas Nashif fd6eb76579 sanitycheck: native: write output to run.log
Native handler should write output to a file, this is not happening
right now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-25 04:45:35 +05:30
Anas Nashif 576be98525 sanitycheck: add harness classes
Add 2 classes, one to handle the current TestCase scenario, and one more
for handling generic Console with regex matching.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-25 04:45:35 +05:30
Anas Nashif 8acdbd796e sanitycheck: support new simulation keyword
Some boards are supported natively by qemu. This option will allow us to
run tests using those platforms directly without having to go via a
dedicated qemu board definition.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-18 21:37:48 -05:00
Anas Nashif f18e2abdd5 sanitycheck: reduce verbosity when selecting specifc platforms
if we are using command line platform filter, no need to list every
other platform as excluded, we know that already.  Show only the
discards that apply to the selected platforms on the command line

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-18 11:27:14 -08:00
Anas Nashif 30551f40e9 sanitycheck: do not list discards when loading tests from file
When we load tests from a file, we do not have the discarded list, this
would have been done already when saving the test file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-18 11:27:14 -08:00
Alberto Escolar Piedras 43bae63e88 sanitycheck: Allow pre/postfixes in tests stdout
When checking if a testcase passed or failed, allow there
to be prefixes or postfixes in the line, around
PROJECT EXECUTION SUCCESSFUL/FAILED

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-01-15 18:42:09 -05:00
Anas Nashif 674bb28040 sanitycheck: filter on CONFIG_ASSERT
CONFIG_ASSERT is being set by cmake, so it is not possible to filter
using the generated config, add this as a standalone filter.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-09 11:13:08 -05:00
Anas Nashif 1a5bba72da sanitycheck: move native_posix to the top
Generating coverage data is split over two CI jobs which means the
service will need to merge results and reports wrong coverage data when
only 1 job is finished. This puts the native_posix board first making
sure we run on the first job and generate data in one place.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-05 23:00:50 -05:00
Paul Sokolovsky 100474d99d scripts: sanitycheck: If error happens accessing YAML data, go on
Extend exception handling to cover not just YAML loading, but any
error while accessing parsed data too. That may catch e.g. schema
mismatch errors (for folks who don't have pykwalify installed, which
is optional). So, now error will be logged, but processing of other
tests will continue.

For example, I had a local, uncommitted test which wasn't converted
per 23f81eeb42 and caused:

Traceback (most recent call last):
  File "./scripts/sanitycheck", line 2456, in <module>
    main()
  File "./scripts/sanitycheck", line 2324, in main
    options.outdir, options.coverage)
  File "./scripts/sanitycheck", line 1445, in __init__
    for name in parsed_data.tests.keys():
AttributeError: 'list' object has no attribute 'keys'

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-05 09:48:11 -05:00
Anas Nashif 712d34513e sanitycheck: encode logs correctly
We were encoding logs twice.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-02 11:54:02 -05:00
Anas Nashif 43e4127df0 sanitycheck: remove unused map
This map is not being used anymore.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-02 11:54:02 -05:00
Anas Nashif a8a1388ae4 sanitycheck: support ninja builder
Add an option to support building with ninja instead of make.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-02 11:54:02 -05:00
Anas Nashif 4f02888b58 sanitycheck: use global command line options variable
Now use glabal options instead of passing them around as function
arguments.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-02 11:54:02 -05:00
Anas Nashif e10b651e2d sanitycheck: declare command line options global
We have been passing around options from one function to the next making
it very difficult to add a new option easily and requiring changes to
man function prototypes.
This declated the parsed command line options global and renames args to
options. args is being used elsewhere and this was confusing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-02 11:54:02 -05:00
Anas Nashif b0f3ae0e98 sanitycheck: harness support
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-28 20:24:29 -05:00
Anas Nashif ab940163ee tests: add a new harness keyword to schema
This keyword would mean that a special harness is needed to run the
tests sucessfully. This can be as simple as a loopback wiring or a
complete hardware test setup for sensor and IO testing. It is free form
initially and would be changed to be an enum once we have more values in
place.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-28 20:24:29 -05:00
Anas Nashif 262e4a4b8b sanitycheck: work around linking posix port
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2017-12-27 14:16:08 -05:00
Anas Nashif cc16422538 sanitycheck: add native handler
Support running native applications in sanitycheck using a new handler.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif 2f4e170eb2 sanitycheck: support native build with *.exe extension
search for .exe file when running native applications in sanitycheck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif 4d25b50c9c sanitycheck: remove usage of qemu for generic handlers
We have now different runners/handlers, so avoid using qemu terminology
for the generic classes and for generic usage.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Anas Nashif f487699810 sanitycheck: descriptive variable names
Use qemu instead of q and make code more readable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Anas Nashif 305a88eb00 sanitycheck: we do not need to pass ARCH= on command line
Passing ARCH during the build process is something from the past and
samples/tests should not do that, remove it here to catch any
violations.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Anas Nashif ab74706e2c sanitycheck: remove platform-level option
Since the move to YAML format and the change in how we define default
platforms this is no longer needed as we are able to set multiple
default platforms per architecture and not using a list based on
priority anymore.

Fixes #4445

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Anas Nashif 877d3caee3 sanitycheck: reworked Platform/Architecture classes
Fix documentation of both classes and minor cleanup.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Anas Nashif b4754ede52 sanitycheck: use test instead of section
The section terminology was relevant with the ini syntax, with yaml we
can call this a test and avoid confusion and make the code more
readable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Anas Nashif 3ba1d43847 sanitycheck: flake8 fixes and move closer to pep8
run through flake8 and autopep8 scripts and cleanup as much as possible.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Anas Nashif 255625b0a3 sanitycheck: refactor data parsing in script
Simplify parsing of yaml structures and remove usage of cp which was for
the ConfigParser used for ini files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Sebastian Bøe abbdd88683 cmake: Fix EXTRA_LDFLAGS feature
It is supported to add give extra flags to the linker from the
commandline like this:

cmake -DEXTRA_LDFLAGS=-Lmy_dir path

But unfortunately this was broken during the CMake
migration. Interestingly, the reason that it was broken is that KBuild
was also partially broken. KBuild would pass on EXTRA_LDFLAGS when
object files were linked together into built-in.o files, but it would
not use EXTRA_LDFLAGS for the final link into an elf file.

This patch fixes EXTRA_LDFLAGS.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-05 08:39:43 -05:00
Anas Nashif 5fd499b3c6 sanitycheck: remove obsolete DISABLE_TRYRUN
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-28 15:31:27 -05:00
Anas Nashif 66bdb3223e sanitycheck: fix documentation and remove mention of kbuild
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-28 15:31:27 -05:00
Anas Nashif c8390f1b49 sanitycheck: rename qemu_time to handler time
This can be used by other handlers and is defined in the main Handler
class. Qemu is just an implementer.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-28 15:31:27 -05:00
Anas Nashif 8b11a1f207 sanitycheck: use glob to find board yaml file
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-28 15:31:27 -05:00
Paul Sokolovsky 3ba0876a3f sanitycheck: Flush stdout in info()
This makes piped output work as the user expects. And looking at the
piped output is the only way to use sanitycheck normally because
of #4603.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-11-13 19:31:19 -05:00
Sebastian Bøe c218261a33 sanitycheck: Fixed documentation for --extra-args and extra_args
sanitycheck was incorrectly documenting that --extra-args would pass
on it's input unchanged to Make.

In reality --extra-args acts as a way to define extra CMake cache
entries. The key-value entries will be prefixed with -D before being
passed to CMake.

E.g
"sanitycheck -x=USE_CCACHE=0"
will translate to
"cmake -DUSE_CCACHE=0"

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-09 17:55:30 -05:00
Sebastian Bøe 71d7de01ef sanitycheck: Minor internal documentation fixes
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-09 17:55:30 -05:00
Sebastian Bøe 781e39887c sanitycheck: Remove the --ccache option from sanitycheck
The --ccache option will be replaced by another mechanism.

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-09 17:55:30 -05:00
Anas Nashif fb91ad6b88 sanitycheck: adapt for cmake
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-08 20:00:22 -05:00
Andrew Boie 8c20db7d44 sanitycheck: tone down verbose output
We only had a few hundred tests run when sanitycheck was first written,
and printing out the reasoning why tests were skipped seemed reasonable
at the time. Now that we are running tens of thousands of tests, this
is too much information.

The dump of what tests were skipped and why now requires two instances
of --verbose on the command line.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-27 10:55:12 -07:00
Andrew Boie 877f82e847 userspace: add K_THREAD_ACCCESS_GRANT()
It's possible to declare static threads that start up as K_USER,
but these threads can't do much since they start with permissions on
no kernel objects other than their own thread object.

Rather than do some run-time synchronization to have some other thread
grant the necessary permissions, we introduce macros
to conveniently assign object permissions to these threads when they
are brought up at boot by the kernel. The tables generated here
are constant and live in ROM when possible.

Example usage:

K_THREAD_DEFINE(my_thread, STACK_SIZE, my_thread_entry,
                NULL, NULL, NULL, 0, K_USER, K_NO_WAIT);

K_THREAD_ACCESS_GRANT(my_thread, &my_sem, &my_mutex, &my_pipe);

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-18 07:37:38 -07:00
Anas Nashif 981f77f756 sanitycheck: fix extra_configs with multiple values
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-18 08:33:03 -04:00
Anas Nashif ebc329dc30 doc: document extra_configs option for testcases
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-17 14:13:52 -04:00
Anas Nashif fa695d2b9e sanitycheck: add extra_configs for testing with multiple values
Support new keywords in testcase.yaml that would allow us to inject
configuration options to be merged with default configuration instead of
having to provide a prj.conf for each variant of the test which is very
difficult to keep in sync.  Sanitycheck script will create an overlay
file that is merged during the build process.

This is now done using the extra_configs option which is a yaml list of
option with the values, for example:

 extra_configs:
   - CONFIG_XXXX=y
   - CONFIG_YYYY=y

With this option we can have multiple tests that for example run on
hardware with different values. This type of testing is good on HW but
it does not make sense to be built in normal sanitycheck operation
because it will be just rebuilding the same code with different values.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-17 08:55:38 -04:00
Anas Nashif 86c8e2330d sanitycheck: fix support for unit tests
When we moved to yaml, we missed porting the 'unit' architecture. This
is now being added again.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-11 09:21:05 -05:00
Anas Nashif 7fae29c711 sanitycheck: inifile -> yamlfile
because we do not use ini files anymore, to avoid confusion, rename this
to be yamlfile, which is the format we use for testcases now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-11 09:21:05 -05:00
Anas Nashif bd166f4903 sanitycheck: save/load lists of filterd tests
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-12 18:13:46 -04:00
Anas Nashif 70783cab60 sanitycheck: rename arch_root -> board_root
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-12 18:13:46 -04:00
Anas Nashif db3d55ff1b sanitycheck: move all related files to sanity_chk
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 08:53:56 -07:00
Andrew Boie 945af95f42 kernel: introduce object validation mechanism
All system calls made from userspace which involve pointers to kernel
objects (including device drivers) will need to have those pointers
validated; userspace should never be able to crash the kernel by passing
it garbage.

The actual validation with _k_object_validate() will be in the system
call receiver code, which doesn't exist yet.

- CONFIG_USERSPACE introduced. We are somewhat far away from having an
  end-to-end implementation, but at least need a Kconfig symbol to
  guard the incoming code with. Formal documentation doesn't exist yet
  either, but will appear later down the road once the implementation is
  mostly finalized.

- In the memory region for RAM, the data section has been moved last,
  past bss and noinit. This ensures that inserting generated tables
  with addresses of kernel objects does not change the addresses of
  those objects (which would make the table invalid)

- The DWARF debug information in the generated ELF binary is parsed to
  fetch the locations of all kernel objects and pass this to gperf to
  create a perfect hash table of their memory addresses.

- The generated gperf code doesn't know that we are exclusively working
  with memory addresses and uses memory inefficently. A post-processing
  script process_gperf.py adjusts the generated code before it is
  compiled to work with pointer values directly and not strings
  containing them.

- _k_object_init() calls inserted into the init functions for the set of
  kernel object types we are going to support so far

Issue: ZEP-2187
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-07 16:33:33 -07:00
Andrew Boie 3ef0b56c15 sanitycheck: fix rw_sections whitespace
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-07 16:33:33 -07:00
Anas Nashif 6222418337 sanitycheck: fix RAM check
make this consistent with flash size check. This issue caused platforms
with 8k to be completelty ignored.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-14 13:28:42 -04:00
Inaky Perez-Gonzalez 662dde6675 sanitycheck: validate YAML files w/ schemas files
This introduces an schema-based YAML validation process when loading
any YAML file, before doing any operations on them. An exception will
be raised at SanityConfigParser() if the file fails to verify with the
given schema.

Schemas are defined for the platform files in board///*.yaml and for
the (sample|testcase).yaml files. The verification is done using the
pykwalify python library. If not installed, a warning is printed and
the verification schema is skipped. At some point, we might want to
force it being installed.

The verification library is made a separate module (scl.py) so it can
be easily imported by others.

Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2017-08-07 21:19:12 -04:00
Sebastian Bøe d3409c5e67 doc: scripts: sanitycheck: s/ini/yaml/
AFAIK an ini file system was ported to a yaml file system. But some
ini file references still remain.

This patch changes all ini file mentions into yaml.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-08-07 12:58:49 -04:00
Anas Nashif 3ac7b3a229 doc: qemu target was deprecated, use 'run'
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-03 11:48:55 -04:00
Anas Nashif 9527693f2a sanitycheck: support feature classes for boards
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-02 07:31:22 -04:00
Andrew Boie 65a9d2a94a kernel: make K_.*_INITIALIZER private to kernel
Upcoming memory protection features will be placing some additional
constraints on kernel objects:

- They need to reside in memory owned by the kernel and not the
application
- Certain kernel object validation schemes will require some run-time
initialization of all kernel objects before they can be used.

Per Ben these initializer macros were never intended to be public. It is
not forbidden to use them, but doing so requires care: the memory being
initialized must reside in kernel space, and extra runtime
initialization steps may need to be peformed before they are fully
usable as kernel objects. In particular, kernel subsystems or drivers
whose objects are already in kernel memory may still need to use these
macros if they define kernel objects as members of a larger data
structure.

It is intended that application developers instead use the
K_<object>_DEFINE macros, which will automatically put the object in the
right memory and add them to a section which can be iterated over at
boot to complete initiailization.

There was no K_WORK_DEFINE() macro for creating struct k_work objects,
this is now added.

k_poll_event and k_poll_signal are intended to be instatiated from
application memory and have not been changed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-10 11:44:56 -07:00
Kumar Gala 5141d526b3 sanitycheck: fix depends_on when multiple dependencies
If the depends_on has more than one item we need to match all of those
dependencies in the supported list.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-07 09:01:01 -05:00
Anas Nashif 25a8b88588 sanitycheck: fix supported/depends_on usage
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-05 12:43:13 -04:00
Andrew Boie 8eed4b0309 sections.h: define application-level sections
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-29 07:46:58 -04:00
Anas Nashif b17e1caf0a sanitycheck: add toolchain keyword to testcases
Some testcases can only be built with certain toolchains. Instead of
using filters, add support for toolchain keyword which enables
whitelisting and exclusion.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-28 09:51:40 -05:00