Commit graph

450 commits

Author SHA1 Message Date
Anas Nashif dc43c298a2 sanitycheck: do not retry build errors with --retry-failed
restore how --only-failed works by allow rebuilds in case of build
errors, however, do not rebuild when --retry-failed is used, which is a
CI usecase and nothing would change in the second iteration.

Fixes #26685

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-09 16:46:24 -04:00
Christian Taedcke 3dbe9f2960 sanitycheck: native: Add option to enable UBSAN
Add option for native platform to enable undefined behaviour sanitizer.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2020-07-09 07:49:57 -04:00
Anas Nashif f04461e8d0 sanitycheck: fix --failed-only handling
- Report build errors as errors, not test failures
- Do not try and build/run tests with build failures
- Fix issue with empty reports when running --only-failed
- Report build errors in the detailed and target reports

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-03 07:25:49 -04:00
Anas Nashif b5973930b1 sanitycheck: set selected_plaforms when loading tests from file
Missed the case we use in CI where we pre-generate the testcase list and
load it, this was resulting in empty test reports in CI.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-06-30 18:34:01 -04:00
Anas Nashif ce8c12eb5a sanitycheck: cleanup fixture processing
Cleanup fixture processing and allow ztest testcases to support
harness_config with fixture definition.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-05-24 20:25:51 +02:00
Anas Nashif bb28035a82 sanitycheck: support exporting instances
Enable exporting tests per platform.

sanitycheck --export-tests out.txt  -p qemu_x86 -T tests/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-05-11 17:00:26 +02:00
Anas Nashif 1a5defa924 sanitycheck: support --force-platform
This option allows running tests on platforms that would be excluded
based on the test definition.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-05-11 17:00:26 +02:00
Anas Nashif 60ae507783 sanitycheck: move export-tests handling and deduplicate code
Reuse the same code used for other options.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-05-11 17:00:26 +02:00
Anas Nashif 7a69125fbf sanitycheck: raise exceptions on bad test names
Raise exception on bad test names such as 'test' or 'sample'.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-05-07 14:23:45 -04:00
Ruslan Mstoi f699ab4ee6 sanitycheck: fix enable_coverage argument name typo
Argument name is --enable-coverage, whereas attribute name is
enable_coverage

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2020-05-06 12:03:15 -05:00
Anas Nashif 6915adf899 sanitycheck: add option for report suffix
Add option --report-suffix to append custom string to all generated
files. This is going to be useful for generating results for a specific
version, i.e. --report-suffix zephyr-v2.2.0-1814-ge737761d23

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-04-22 14:21:05 -04:00
Martí Bolívar 07dce820d5 sanitycheck: add --persistent-hardware-map
This option prefers serial device names which are stable
across device plug/un-plug on platforms that support it (currently
just Linux, via /dev/serial/by-id).

This feature is opt-in as not all manufacturers include the
appropriate metadata for udev to generate unique names for their
devices.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-04-17 18:31:28 +02:00
Martí Bolívar 4fad53522c sanitycheck: infer ZEPHYR_BASE if unset
Now that the main Zephyr build system (and the documentation's) no
longer require ZEPHYR_BASE in the environment, the sanitycheck
script's continuing to require this makes less sense.

We can easily find ZEPHYR_BASE starting from a given sanitycheck
script, so let's just do that. Preserve the ability for a user to
override the ZEPHYR_BASE location in the environment as usual for
compatibility.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-04-15 14:42:21 -04:00
Anas Nashif b06a5b5707 sanitycheck: fix coverage capturing
We got the gcov with the coverage tool (lcov vs gcovr) confused..

Fixes #24003

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-04-07 14:53:20 -04:00
Anas Nashif f6462a3a8c sanitycheck: get rid of global VERBOSE
Do not declare VERBOSE as global, instead pass verbosity as argument.
Also get rid of options as global and fix coverage class to not use
global option variable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-30 09:59:42 -04:00
Anas Nashif ce2b418027 sanitycheck: split main script into an exe and classes
Move most of the classes to sanitycheck.py under sanity_check directory.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-30 09:59:42 -04:00
Anas Nashif 1f6cdbe70a sanitycheck: fix scope and cleanup
Reorder classes to be on top of loose functions. Move a few globals into
the related classes where they are being used.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-30 09:59:42 -04:00
Anas Nashif 507e75b9b5 sanitycheck: remove more global usage of arg options
This will make it easier for us to test classes and functions without
having arg options in the middle.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-30 09:59:42 -04:00
Anas Nashif 64a6c9e3df sanitycheck: use cmake_only from class
Do not use option from args, use class settings instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-30 09:59:42 -04:00
Anas Nashif 6667dc35e7 sanitycheck: catch build failures
CMake is not returning any error codes on build failures so those go
undetected in some cases. Handle the case where we get no output at all
from cmake and deal with that as a failure.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-30 10:33:21 +02:00
Anas Nashif 56993fb9ab sanitycheck: remove confusing message when loading files
This message was intended for retries only, not every time we loaded a
file with a test manifest.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-24 12:15:36 -04:00
Anas Nashif 923b3bf0ae sanitycheck: Add named exceptions
Add named exceptions instead of a generic one. Should help point to the
right issue when something goes wrong.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-24 12:15:36 -04:00
Anas Nashif 2f7c187d77 sanitycheck: cleanup loading of previous results
Merge two functions loading previous results into one and support
filtering based on status.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-24 08:11:07 -04:00
Anas Nashif a45c1da6d7 sanitycheck: use status column for status
We used the column 'passed' as a boolean to signify pass or fail,
however we do have other states that need to be tracked.
Remove the boolean and use a text field instead that has the status as a
string.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-24 08:11:07 -04:00
Anas Nashif 49f6d5a6c6 sanitycheck: fix counting when using --test option
When running 1 specific test, counting was off. Combine functions adding
tests into one and optimize filtering.

Fixes #22270

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-24 08:10:44 -04:00
peng1 chen 921226493b sanitycheck: delete the '\r' char in front of serial output
add lstrip function to delete the '\r' char in front of the
serial output from serail readline, because this '\r'
will influence the result match function in harness.py.

Signed-off-by: peng1 chen <peng1.chen@intel.com>
2020-03-17 12:34:21 -04:00
Stephanos Ioannidis 354f2bbf1e sanitycheck: Update section names for memory size calculation
This commit updates the section names for memory size calculation in
the sanitycheck script as follows:

1. Remove `_TEXT_SECTION_NAME_2` section, which no longer exists, from
  the `rw_sections`.

2. Add `rom_start` section, which mostly contains read-only data such
  as the exception vector table, to the `ro_sections`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-02-18 12:59:25 -05:00
Kumar Gala b81eec951b sanitycheck: make pyserial optional
We only need pyserial python module if we are doing device testing.
Treat it similar to how we treat tabulate module.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-07 19:48:24 -06:00
Anas Nashif 323161dfcd sanitycheck: point to correct gcov path
The SDK has a new path for x86 gcov, point to the new binary. Also, do
not clean artifacts when running coverage.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-02-07 15:14:24 -05:00
Kumar Gala de70e9c5ba scripts/sanitycheck: be more fair with dividing subsets
Since we do interger division to determine how many items are in each
set, its possible we can have bad rounding error and the last set having
a much larger amount of items compared to all other sets.

For example, total = 3740, sets = 300:
	per_set = 3740 / 300 = 12.466 = 12
	last_set = 3740 - 299 * 12 = 152

So instead of doing simple division, we add on extra item to the early
sets and we've exhausted the rounding error:

	num_extra_sets = total - per_set * sets
		   140 = 3740 - 12 * 300

So the first 140 subsets will have 13 per_set, and the last 160 will
have 12 per_set.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 18:57:49 -05:00
Marcin Niestroj be0f5fe0b0 scripts/sanitycheck: fix merging OVERLAY_CONFIG extra args
Overlay files were concatenated into single string with no whitespace
between them. If '--extra-args OVERLAY_CONFIG="overlay-1.conf"
--extra-args OVERLAY_CONFIG="overlay-2.conf"' was used, then the result
was OVERLAY_CONFIG="overlay-1.confoverlay-2.conf".

Another thing was that overlay extra args were not properly removed from
the list of regular arguments. As a result we had incorrect list of
overlays and incorrect list of other arguments.

Rework code to extract overlays in loop in a safe manner. Use for that a
list of strings instead of string directly. Join those strings and form
a single OVERLAY_CONFIG argument just before running cmake.

Tested with following testcase.yaml line:

  extra_args: ARG1 OVERLAY_CONFIG="overlay-1.conf"
              ARG2 OVERLAY_CONFIG="overlay-2.conf"

Before this patch we got:

  args = ['OVERLAY_CONFIG="overlay-1.conf"',
    'OVERLAY_CONFIG="overlay-2.conf"']

After this patch we get:

  args = ['ARG1', 'ARG2',
    'OVERLAY_CONFIG="overlay-1.conf overlay-2.conf"']

While at it, fix also regex pattern by removing requirement of double
quotes around value. Match any option value instead and strip both
single and double quotes when match is positive. Tested with:

  $ ./scripts/sanitycheck -T samples/hello_world/ -p qemu_x86 \
      --extra-args OVERLAY_CONFIG=overlay1.conf '
      --extra-args OVERLAY_CONFIG=\"overlay2.conf\" '
      --extra-args OVERLAY_CONFIG=\'overlay3.conf\'

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-01-31 15:55:36 -05:00
Anas Nashif 471ffbe77d coverage: do not dump coverage data by default
Only dump data when we are interested in the analysing coverage. By
default just collect the data.

CONFIG_COVERAGE_DUMP is used to control this behaviour.

This will help speed up sanitycheck and will avoid lots of noise in the
log when some tests with coverage enabled failed. Dumping data to
console is also suspected to be one of the reason why qemu hangs in CI.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-30 16:04:03 -05:00
Anas Nashif 923ca14b7d sanitycheck: show which threads are stuck
Print a warning if some threads are taking more time and seem to be
stuck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-30 16:49:03 +01:00
Anas Nashif 2c1c399872 sanitycheck: minor comment and style cleanup
Remove an unrelated comment and a minor style change.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-30 16:49:03 +01:00
Peter Bigot ab7773dae8 sanitycheck: leave non-tty terminal unmodified on exit
The terminal configuration should not be reset on exit if
sanitycheck's output is being directed to something that mediates the
terminal control, such as a pager.  Only do the reset if stdout is
interactive.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:54:41 +01:00
Anas Nashif dd65f7c38a sanitycheck: change distribution of tests per set
Sort by testcase name and path and not by platforms. This way we do not
have the same platform executing on CI system causing failures to
overload.

Right now we have almost all qemu targets executing on 1 or 2 nodes,
causing those systems to be overloaded. Instead of taking the default
sorting by platforms, we now sort by testcases, so the distribution is
more "random", but still reproducible.

Remove the ordering function that would put native_posix in the first
set, it is not being used anymore.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-23 14:02:59 -05:00
Flavio Ceolin 9dbb50bac8 scripts: sanitycheck: Simplify if statement
Outer if is checking if the variable is in a list with two options
which means that we can just do an if / else and remove an assignment.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-01-22 17:37:41 -05:00
Anas Nashif e337882189 sanitycheck: fix reporting of timeouts
Timeouts were not reported correctly in the XML file as failures,
causing some confusion in the shippable results.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-22 01:39:28 -05:00
Anas Nashif 9fe1e2a663 sanitycheck: support excluding platforms
It is often needed to run sanitycheck and exclude a specific platform or
multiple platforms. Add an option to provide this using
--exclude-platform. The option can be used multiple times to exclude
multiple platforms at the same time.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-21 21:10:49 -05:00
Anas Nashif 1342d21fc0 sanitycheck: support runtime artifact cleanup
Using --runtime-artifact-cleanup, the script will now remove all
artifacts of passing tests. This is useful for running sanitycheck on
systems with little disk space.

Fixes #21922

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-16 19:19:07 -05:00
Andrew Boie 75bd9b6ce0 sanitycheck: improve summary output
Show how many tests passed out of those that were actually
performed, not including skipped tests (which we also report
a count of)

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-14 23:26:06 -05:00
Anas Nashif cd1f017468 sanitycheck: set extra_args from command line
Missed setting extra_args coming from command line in the testsuite.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-14 13:39:46 -05:00
Anas Nashif e7656ea831 sanitycheck: do not log stderr from BinaryHandler
stderr from the binary handler (native_posix for example) was redirected
to the logger as errors, this is confusing the console and users, so
remove this.

Fixes #21784

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-09 14:28:32 -05:00
Anas Nashif e9450065de sanitycheck: additional scripting hook after flashing
Support custom hooks after flashing is completed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 4522e10d65 sanitycheck: report overflow on SRAM overflow
Instead of failing, report overflow when the SRAM overflows.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif bdffb88950 sanitycheck: close pipe file handles
Make sure we close the pipe file handles after we are done, otherwise we
will end up with too many open file descriptors and crash...

Fixes #20974
Fixes #21637

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 64c84b15ce sanitycheck: more debug messages
More debug messages to help locate issues and debug bugs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 1b1a7e242b sanitycheck: run pre/post script using dedicated function
Reduce duplicated code by introducing a dedicated function for running
custom scripts.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 32e924459d sanitycheck: log errors when executing binaries
Add some verbosity into the log file to help with debugging.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 52b66c6ad1 sanitycheck: when timing out in handler, show correct log file
Fix issue where we timeout in handler and show the device.log file
instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00