Commit Graph

181 Commits

Author SHA1 Message Date
Richard Purdie
c9caf79cab oeqa/concurrencytest: Remove invalid buffering option
Fix warnings from oe-selftest -j:

/usr/lib/python3.10/os.py:1030: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
  return io.open(fd, mode, buffering, encoding, *args, **kwargs)

Remove the option since it clearly doesn't do much.

(From OE-Core rev: 6b872ee72942951fd464c4c6cb9eadcb9b4749c1)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-10-05 21:09:10 +01:00
Richard Purdie
8a69a411c0 oeqa/runner: Ensure class setup errors are shown to bitbake logging
This took a bit of digging but failure messages from testimage are shown to bitbake's
logging through stopTest. In the case of a setUpClass failure stopTest is never
called and the bitbake logging never sees the error. It would still be in the task
logfile. Add some code+comment to ensure logs not shown to the user mid stream are shown
at the end.

(From OE-Core rev: 7342c418bda2cc3c337a190089864ea731ff62e4)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-09-26 10:25:42 +01:00
Richard Purdie
7e6514b28b oeqa: Streamline oe-selftest startup time
"bitbake -e" executions from get_bb_var calls are slow and slow down oe-selftest
startup. Rationalise the code to avoid them and minimise the number of "parsing"
locations we use by caching key variables and passing them around more.

This was particularly problematic with oe-selftest -j usage since it would
have multiple bitbake -e executions per process making parallel usage
particularly slow.

(From OE-Core rev: 3689cadeb07d76e66f97d890e844f899f69666fe)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-09-22 07:45:17 +01:00
Richard Purdie
c2d0ac3f0d oeqa/ssh: Further improve process exit handling
It looks like there were further cases where orphaned processes may be left
behind since the .kill() calls may be unsuccessful if the process terminated
due to the terminate or through normal exit. In that situation .wait()
wouldn't have been called.

Further tweak the exit code paths to ensure .wait() is called to update the
returncode value before returning in all cases.

(From OE-Core rev: 0a0a1731e38edfa72a141e8fd8f2de52be562e94)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-07-30 07:54:44 +01:00
Richard Purdie
269479f6f4 target/ssh: Ensure exit code set for commands
As spotted by Joshua Watt, the returncode isn't set until .poll() or .wait()
is called so we need to call this after the .kill() call.

This fixes return code reporting so that timeouts for example now return an
exit code when they didn't before.

(From OE-Core rev: 3924e94214b5135369be2551d54fb92097d35e95)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-07-29 08:34:35 +01:00
Richard Purdie
aff6bc3249 oeqa/target/ssh: Ensure EAGAIN doesn't truncate output
We have a suspicion that the read() call may return EAGAIN on the non-blocking
fd and this may truncate test output leading to some of our intermittent failures.
Tweak the code to avoid this potential issue.

(From OE-Core rev: a8920c105725431e989cceb616bd04eaa52127ec)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-07-29 08:34:35 +01:00
Thomas Roos
f82c3bd37d testimage/oeqa: Drop testimage_dump_host functionality
The intent behind these functions was to dump the system state when issues occured
but it has never really worked as we'd planned. Regular monitoring as the build
runs has largely replaced this as that allows a trend to be seen rather than a spot
value which was never really useful. The code is bitrotting and not functioning
correctly so drop it.

[YOCTO #13872]

RP: Reword commit message
(From OE-Core rev: dea37ba49a236029da73d5cfbfc069bffc38b508)

Signed-off-by: Thomas Roos <throos@amazon.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-06-29 10:57:27 +01:00
Alexis Lothoré
cdac245fc2 oeqa/target/ssh: update options for SCP
By default scp expects files. Passing -r option allows to copy directories
too

(From OE-Core rev: f22e5af0c5f185463c6f4a7fd7f1376c7f22a4da)

Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-06-17 11:50:57 +01:00
Alexis Lothoré
1a2aa5e536 oeqa/core/runner: add helper to know about expected failures
Testing framework currently uses the unittest.expectedFailure decorator for
tests that can have intermittent failures (see PTEST_EXPECT_FAILURE = "1")
in core-image-ptest.bb. While it allows upper layers to run tests without
failing on "fragile" tests, it prevents those from knowing more about those
failing tests since they are not accounting as failures (for example we
could want to retrieve some logs about failed tests to improve them, and
eventually to drop expectFailure decorator)

Add a helper to allow upper layers to know about those failures which won't
make global testing session

(From OE-Core rev: 34595858b14f628a8282777b91c841add6ebe1ca)

Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-06-17 11:50:57 +01:00
Richard Purdie
f67258fcbf oeqa/loader: Ensure module names don't contain uppercase characters
Python modules aren't supposed to have uppercase characters in their names
according to python conventions. We have regexs in the code which work
on that assumption too. Rather than showing errors under some filtering
situations, make it clear and error if a problematic name is seen.

(From OE-Core rev: 7964a6ee54e881a6128707a7f2a42eec2ed63881)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-03-31 23:30:36 +01:00
Martin Jansa
7eef95d723 oeqa: loader.py: show warning when skipping selected module and abort if all are skipped
* skipped modules were triggering an ERROR before:

  poky $ oe-selftest -v -r eSDK.oeSDKExtSelfTest.test_install_libraries_headers imagefeatures.ImageFeatures.test_image_gen_debugfs -K -B /OE/build/poky/build-eSDK
  2023-03-13 15:07:53,430 - oe-selftest - ERROR - Not found eSDK.oeSDKExtSelfTest.test_install_libraries_headers in loaded test cases

* but didn't show the reason why it wasn't loaded and more importantly -r
  was ignored when all selected modules were silently skipped

* add a warning when skipping some module and abort if some modules were
  selected, but all ended being skipped:

  poky $ oe-selftest -v -r eSDK.oeSDKExtSelfTest.test_install_libraries_headers -K -B /OE/build/poky/build-eSDK
  2023-03-13 15:11:51,028 - oe-selftest - WARNING - module 'eSDK.oeSDKExtSelfTest.test_install_libraries_headers' was skipped from selected modules, because it doesn't match with module name assumptions: package and module names do not contain upper case characters, whereas class names do
  2023-03-13 15:11:51,028 - oe-selftest - ERROR - All selected modules were skipped, this would trigger selftest with all tests and -r ignored.

* I was hit by this in oe-selftest -r eSDK.oeSDKExtSelfTest.test_install_libraries_headers
  which is skipped due to upper case characters in module name and selftest started to run
  all tests (archiver.Archiver.test_archiver_allows_to_filter_on_recipe_name as first from 529)

  poky $ oe-selftest -v -r eSDK.oeSDKExtSelfTest.test_install_libraries_headers -K -B /OE/build/poky/build-eSDK
  2023-03-13 14:00:52,955 - oe-selftest - DEBUG - Selected tests with -r: ['eSDK.oeSDKExtSelfTest.test_install_libraries_headers']
  2023-03-13 14:00:55,531 - oe-selftest - INFO - Changing cwd to /OE/build/poky/build
  ..
  2023-03-13 14:00:58,128 - oe-selftest - INFO - test_archiver_allows_to_filter_on_recipe_name (archiver.Archiver.test_archiver_allows_to_filter_on_recipe_name)

  I'll rename eSDK to esdk in next commit to avoid this.

* also fix small typo in context I've noticed when debugging this

(From OE-Core rev: 15229c9abaf4cc398c31d97d171b9fac57141873)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-03-22 13:53:29 +00:00
Mikko Rapeli
c7b05d5657 oeqa ssh.py: fix hangs in run()
When qemu machine hangs, the ssh commands done by tests
are not timing out. do_testimage() task has last logs like this:

DEBUG: time: 1673531086.3155053, endtime: 1673531686.315502

The test process is stuck for hours, or for ever if the
executing command or test case did not set a timeout correctly.
The default 300 second timeout is not working when target hangs.
Note that timeout is really a "inactive timeout" since data returned
by the process will reset the timeout.

Make the process stdout non-blocking so read() will always return
right away using os.set_blocking() available in python 3.5 and later.

Then change from python codec reader to plain read() and make
the ssh subprocess stdout non-blocking. Even with select()
making sure the file had input to be read, the codec reader was
trying to find more stuff and blocking for ever when process hangs.

While at it, add a small timeout to read data in larger chunks if
possible. This avoids reading data one or few characters at a time
and makes the debug logs more readable.

close() the stdout file in all cases after read loop is complete.

Then make sure to wait or kill the ssh subprocess in all cases.
Just reading the output stream and receiving EOF there does not mean
that the process exited, and wait() needs a timeout if the process
is hanging. In the end kill the process and return the return value
and captured output utf-8 encoded, just like before these changes.

This fixes ssh run() related deadlocks when a qemu target hangs
completely.

(From OE-Core rev: 9c63970fce3a3d6029745252a6ec2bf9b9da862d)

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-02-23 12:11:29 +00:00
Mikko Rapeli
a0ccfba547 oeqa ssh.py: add connection keep alive options to ssh client
Configure ssh client to test that connection with server is up.
If the server does not respond within a minute then the connection,
target machine or sshd daemon are stuck and it's better to exit
the command execution with errors.

Some tests can execute a long time without returning stdout/stderror
data and it's difficult to adjust timers for those cases if
connection to target machine or the target machine itself hangs
and output is not expected in minutes or even hours.

(From OE-Core rev: ba68ff04c5786eca7cd8dd44056705867dea8ac4)

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-02-10 09:25:44 +00:00
Mikko Rapeli
487cb16119 oeqa ssh.py: move output prints to new line
The output from is garbled otherwise and it's not
easy to remove debug output form real command output on target.

(From OE-Core rev: 917a70cbc43ac1c70c477b220c4115735457ef04)

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-02-10 09:25:44 +00:00
Richard Purdie
eac47bff70 oeqa/concurrencytest: Add number of failures to summary output
When running oe-selftest and seeing the end of a running log, it is
extremely helpful to know if there have been failures or not to save
looking at the rest of the log. Add the number of failures to the summary
line so that people monitoring builds have an easier time before the end
totals are printed.

(From OE-Core rev: 6b23996911d91f7f99774646c6db9f3490b4cb62)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-12-22 23:09:00 +00:00
Ross Burton
be8de607a9 oeqa/core/decorator: add decorators to skip based on HOST_ARCH
There are already decorators to skip on the value of MACHINE, but for
flexibility it's better to skip based on the target architecture. This
means, for example, the ISO image tests could skip if the architecture
isn't x86.

(From OE-Core rev: 0c21ff0a92906b6b4820eb8beddf8762fe70653d)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-11-11 13:43:40 +00:00
Ross Burton
4a264f3695 oeqa/target/ssh: add ignore_status argument to run()
The underlying _run() method has an ignore_status argument and can
either return the exit code or raise an exception if it is non-zero.

Add the same argument to the run() method so that test cases can change
this value. It currently defaults to True as that is the existing
behaviour, but a follow-up patch will change this to False as test cases
should fail on errors unless told otherwise.

(From OE-Core rev: e244228730178d15a066a1428956de328cc09671)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-11-02 09:21:29 +00:00
Richard Purdie
ce08cf4825 lib: Add copyright statements to files without one
Where there isn't a copyright statement, add one to make it explicit.
Also add license identifiers as MIT if there isn't one.

(From OE-Core rev: bb731d1f3d2a1d50ec0aed864dbca54cf795b040)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-08-12 12:00:43 +01:00
Ross Burton
fcc9c0ab37 oeqa: rationalise skipifqemu decorators
(From OE-Core rev: 1a3a37cc2b16a8d5cd2258b0b35be43baa363f67)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-04-01 23:11:37 +01:00
Ross Burton
4e5f84902e oeqa/core/decorators/data: improve has_* logic
has_feature() should be splitting the feature string into substrings and
then looking for membership instead of looking for simple substrings.

has_machine() should be using equality instead of substrings.

(From OE-Core rev: a4c63819234e252c58e040af8bbdbfb96b6feccf)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-04-01 23:11:37 +01:00
Ross Burton
f4205dcf3d oeqa/core/utils/misc: remove redundant file
This file dates back to 2016. Half of the functions have never been used,
the rest are used in one place and have now been replaced.

(From OE-Core rev: 5a053b2a84e7a671925fb4a78005145786c57f6a)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-04-01 23:11:37 +01:00
Ross Burton
ccc03581f5 oeqa/core/decorator: remove redundant code
There's no need to wrap *tags in a potential list, as *tags will always
be a tuple.

(From OE-Core rev: 54210c518bcb76d80c8ec9564d1ddf344e9d8924)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-04-01 23:11:37 +01:00
Ross Burton
48587b5e63 oeqa/target/ssh: don't assume target_dumper is set
The target_dumper property is only set by the QemuTarget subclass, so
assign a default value and check it isn't None before calling it.

(From OE-Core rev: add36cf85380bf7dc5339a9d65f951923317440b)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-09-21 23:44:08 +01:00
Sakib Sajal
b44849c32c oeqa/core/target/qemu.py: display contents of dumped files
During do_testimage, if the target is not started within a certain
timeout, TEST_QEMUBOOT_TIMEOUT, host data is dumped to files for
each command in
${TMPDIR}/log/runtime-hostdump/<datetime>_qemu/host_<seq>_<command>.

Display the first 20 lines of top output and the last 20 lines of
bootlog to standard output for more context for the target not being
started up.

(From OE-Core rev: 441390b707bf681bc308c9ebd45ea2ae20c37d7c)

Signed-off-by: Sakib Sajal <sakib.sajal@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-06-12 08:38:29 +01:00
Alexander Kanavin
377a73d5b7 oeqa/core/tests/test_data.py: use weston image instead of sato
(From OE-Core rev: c2ccd8c8144cdda52b858589f7d5d3a15ab28b90)

Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-04-27 15:11:47 +01:00
Saul Wold
3acbec85b0 qemurunner: Add support for qmp commands
This adds support for the Qemu Machine Protocol [0] extending
the current dump process for Host and Target. The commands are
added in the testimage.bbclass.

Currently, we setup qemu to stall until qmp gets connected and
sends the initialization and continue commands, this works
correctly. If the UNIX Socket does not exist, we wait an timeout
to ensure to socket file is created.

With this version, the monitor_dumper is created in OEQemuTarget
but then set in OESSHTarget as that's where we get the SSH failure
happens. Python's @property is used to create a setter/getter type
of setup in OESSHTarget to get overridden by OEQemuTarget.

By default the data is currently dumped to files for each command in
TMPDIR/log/runtime-hostdump/<date>_qmp/unknown_<seq>_qemu_monitor as
this is the naming convenstion in the dump.py code.

We use the qmp.py from qemu, which needs to get installed in the
recipe-sysroot-native of the target image.

[0] https://github.com/qemu/qemu/blob/master/docs/interop/qmp-spec.txt

(From OE-Core rev: 42af4cd2df72fc8ed9deb3fde4312909842fcf91)

Signed-off-by: Saul Wold <saul.wold@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-04-27 15:11:47 +01:00
Alexander Kanavin
c13be2e1dc meta/lib/oeqa/core/tests/cases/timeout.py: add a testcase for the previous fix
This is the sequence that didn't properly operate:

- a test case that skips and isn't executed
- a second test case that is skipped via a dependency decorator, and sets a timeout
- a third test case that takes longer than the timeout from the second
test case

Without the fix, the timeout is not cleared, and the third test case is
erroneously aborted. With the fix, the timeout is cleared and the third
test case is able to complete.

(From OE-Core rev: 54ef07a9aa1af8f41cfb9a4802929c918efc43c8)

Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-04-23 10:12:10 +01:00
Alexander Kanavin
b40f78a5c7 oeqa: tear down oeqa decorators if one of them raises an exception in setup
Some of the decorators need proper cleanup, such as OETimeout
which sets a signal handler that needs to be cleared via teardown.
If this is not done then the signal gets called later with unpredictable effects.

This can be seen if there's a test that is skipped via a decorator and sets a timeout
at the same time: the timeout isn't cleared, and is invoked later in a
completely unrelated context. The test case for this is added in the
next commit.

(From OE-Core rev: f42a08e1aabf1ca57e0c09d69fb69cc717c7f156)

Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-04-23 10:12:10 +01:00
Richard Purdie
232cb7b055 oeqa/runqemu: Support RUNQEMU_TMPFS_DIR as a location to copy snapshot images to
We have a working theory that IO queues on the autobuilder are impacting
runtime testing under qemu, particularly async writes which inice does not
influence. We already pass the snapshot option to qemu which copies the
image and runs out of the copy. Add in the ability to copy the image to
a specificed location which can be a tmpfs. This means that writes to the
image would no longer be blocked by other writes to disk in the system.

Preliminary tests show that this does improve the qemu errors at the expense
of sometimes showing qemu startup timeouts as on a loaded system with a large
test image, it can take longer than 120s to copy the image to tmpfs. Having
a most consistent failure mode for loaded tests is probably desireable though.

(From OE-Core rev: fd1c26ab426c3699ffd8082b83d65a84c8eb8bff)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-04-06 09:30:10 +01:00
Richard Purdie
855fbb6f99 oeqa/concurrencytest: Fix display of test stdout/stderr
If oe-selftest is run with -j, the output to stdout/stderr is being
lost at present. Capture this and display it upon test failure. We
have code that previously tried to enable this but it wasn't functioning
correctly. This should give more usable error reports on the autobuilder.

This code will mix stdout and stderr as the output is streamed from the test
server without markup. This is most in keeping with subunit/testools though
and the easiest way to handle the various challenges here as far as I can
see.

(From OE-Core rev: 6a954ce5834c8026adecff8478c3d827640bc647)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-04-06 09:30:10 +01:00
Richard Purdie
f0c5a904d9 oeqa/concurrencytest: Rename variables to improve the code
Each time I look at this code I get confused about what the different
variables represent. Rename a few of them to better indicate what they
represent.

(From OE-Core rev: e39d97c0b191add9281bac463ca059685288c81a)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-04-06 09:30:10 +01:00
Konrad Weihmann
3c4147880e oeqa/core/context: initialize _run_end_time
with _run_start_time as value. For partial results of interrupted runs,
this info might be otherwise missing for at least one testcase

(From OE-Core rev: 1c5e8baf57fa2a33b9ef507b11d9ea9acaa77238)

Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-11-11 10:08:12 +00:00
Konrad Weihmann
02be651f88 oeqa/core/context: expose results as variable
register an unittest handler for testresults and expose it as
variable result.
With this even partial results from an interrupted test suite run
can be made available

(From OE-Core rev: a97ae47525157871b6c098ffc352293e365a4335)

Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-11-11 10:08:12 +00:00
Saul Wold
78b473e7f8 target/ssh.py: Add dump_target support
This adds the dump_target support when the ssh command fails with
a 'No route to host'. This is will provide additional data when a
Qemu target fails to respond during autobuilder testing. This does
not fix 14002 [0], but may help track down why qemu looses networking

[0] https://bugzilla.yoctoproject.org/show_bug.cgi?id=14002

(From OE-Core rev: cef1a2b03b359c018911abc29db1895d0f46814c)

Signed-off-by: Saul Wold <saul.wold@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-09-30 15:01:51 +01:00
Saul Wold
406857b019 testimage: Add testimage_dump_target to kwargs
This passes the list of commands to run on the OEQemuTarget when
the TargetDumper needs to run in a test context due to a failure
on the target.

This is added here as a kwargs because the 'd' dictionary is not
available in the staticmethod getTarget in the
OERuntimeTestContextExecutor class. The OEQemuTarget is different
from the QemuTarget which already uses the list of commands from
testimage_dump_target from 'd'. The create_dir() is needed to
initialize the TargetDumper's dump_dir variable.

(From OE-Core rev: a63675fab4d9f638570912b15a07932f549cc4d1)

Signed-off-by: Saul Wold <saul.wold@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-09-30 15:01:51 +01:00
Alexander Kanavin
3ee166c0dd oeqa: write @OETestTag content into json test reports for each case
This allows using these tags for classification and filtering of test results
according to various organization-specific criteria, such as teams
responsible for the test, internal test ids, feature domains and so on.

Test name itself meanwhile can stay short and human-readable.

(From OE-Core rev: 3801b126eb52cd46efe417111afcd27f05d8f72b)

Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-08-08 09:17:49 +01:00
Matthew
b6b6a39ee8 ltp: make copyFrom scp command non-fatal
[YOCTO #13802]

Make the scp failure non-fatal so the ltp tests continue to run and
the rest of the logs will be available to see afterwards.

(From OE-Core rev: 0f7d093038274f4f21f6cca39a96aac4f6c32ee3)

Signed-off-by: Mingde (Matthew) Zeng <matthew.zeng@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-08-06 15:12:39 +01:00
Vacek, Patrick
6474ff808b oeqa/core/loader: fix regex to include numbers
The previous version only included the numbers 1 and 2 in the allowed characters
for the module name. In the past, this was (\w+) so all numbers were allowed.
Now it explicitly includes all numbers again.

(From OE-Core rev: f241fa493536ac953c1dac303917c6e75b459e28)

Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-07-08 10:37:12 +01:00
Lee Chee Yang
ebfa049fc0 oeqa/core/loader: refine regex to find module
test case in format <module name>.<class name>.<test case name>
this is clear when test cases is only 3 item deep.

but confused when it is 4 item deep, eg,
oelib.types.TestList.test_list_nosep

in this case, oelib and oelib.types can both be treated as module
since module name contains only lower cases and class name should
contain atleast one upper case.
so, always treat leading item without upper case as module also allow
module name to contain dot.

[YOCTO #13941]

(From OE-Core rev: ad81ea90a815389e45ff302a85151724c71f71c3)

Signed-off-by: Lee Chee Yang <chee.yang.lee@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-07-03 11:38:24 +01:00
Richard Purdie
79856aaf93 oeqa/selftest: Clean up separate builddir in success case when non-threaded
If oe-selftest is run without -j, the separate build directory "build-st"
isn't cleaned up afterwards. Mirror the behaviour of the -j option to
handle this the same way, only preserve upon failure.

To do this, the remove function needs to be moved to the selftest
context module so that it can be accessed without requiring the
testtools and subunit modules the -j option requires.

A dummy wrapper class is used to wrap the tests and clean up afterwards.

[YOCTO #13953]

(From OE-Core rev: 1b376ade430d40d3cfe9c18f200c764d622710e5)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-06-28 08:36:00 +01:00
Paul Barker
18a69b1cd2 oe-selftest: Support verbose log output
(From OE-Core rev: 6a607da9a6aa05f86b0e77cccd066b9f286cfada)

Signed-off-by: Paul Barker <pbarker@konsulko.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-06-04 13:27:32 +01:00
Steve Sakoman
6b3b5ab4ba oeqa/concurrencytest: don't delete build directory for failed tests
(From OE-Core rev: 3d5aa170d2e88b852bd2a4452aab9311a24badef)

Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-05-24 23:56:03 +01:00
Alexander Kanavin
03bb031125 testresults.json: add duration of the tests as well
This is printed by testimage, but isn't actually saved.
It's a useful metric for tracking execution times.

(From OE-Core rev: 8fc19639f47b959a141dae231395bbababa644e1)

Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-05-21 12:35:39 +01:00
Konrad Weihmann
da0ab97f61 testimage: enable ovmf support
Add support for running wic images with EFI as testimage.
Introduces a variable called QEMU_USE_OVMF for configuration.

(From OE-Core rev: 3af8aaff68ed332d812ea7dc184d392700ad7882)

Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-04-24 14:10:08 +01:00
Stefan Kral
80c1002c2e oeqa: default runtime json results for testexport
Set the json result output dir in the oeqe runtime context to create
testresults.json file by default for exported runtime test runs.

Use current datetime for the json result property name (not DATETIME
from build) to allow multiple result entries.

(From OE-Core rev: e6c73ed8d3c5d45f387cab619ca73c21e850582f)

Signed-off-by: Stefan Kral <sk@typedivision.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-03-29 12:05:31 +01:00
Stefan Kral
b10131ea74 oeqa: enable testresults.json for testexport
Add the option --json-result-dir to oeqa core context to enable
testresults.json creation for test runs via testexport.

Eg. oe-test runtime --json-result-dir .

(From OE-Core rev: 9d8edf33d1f5d89b310923b0aa3cc967317c7c49)

Signed-off-by: Stefan Kral <sk@typedivision.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-03-12 22:49:28 +00:00
Richard Purdie
c569157d9d oeqa/selftest: Standardise seperate builddir for concurrent and non-concurrent selftest
Currently oe-selftest reuses the current build directory and the concurrent
version run with -j does not.

Standardise and use a separate new build directory in both cases. This will lead
to simpler code and more reliable user run tests.

(From OE-Core rev: 50238b0717b04e0a1fa69d618e8c8aa8445a80b0)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-02-21 09:39:00 +00:00
Trevor Gamblin
450688b010 concurrencytest.py: add outSideTestaddSkip for subunit
see: https://bugzilla.yoctoproject.org/show_bug.cgi?id=13663

When running oe-selftest in concurrency mode (e.g. with oe-selftest
--run-tests oescripts.OEPybootchartguyTests -j 4), if a skip occurred
during setUpClass() rather than within individual tests, the entire
suite would show "UNKNOWN" as each test's result. This is because
subunit doesn't know how to handle skips outside of individual tests.
An example of where this occurs is when running the above call to
oe-selftest in concurrency mode on a host machine that does not have
python3-cairo installed.

Patch subunit inside concurrencytest.py to provide a method called
outSideTestaddSkip, which will allow subunit to correctly detect the
skip in setUpClass().

(From OE-Core rev: 9b8734b584d6e8d9c32ff2a721b29f3f3e61cca7)

Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-02-18 23:53:55 +00:00
Alejandro Hernandez Samaniego
a3416a5933 testimage: Extend runtime testing infrastructure to allow unconventional booting processes to be tested
The current runtime infrastructure contains hardcoded values which Ill refer to
as patterns, these patterns are either searched through or sent via the serial
terminal to communicate between HOST and TARGET.

These patterns are required since they allow us to check when a device has
finished booting, to log in, and to check whether a command sent from our tests
has returned, this way we are able to check both the status of the commands that
were sent along with its output.

The testing process goes somewhat as follows:
1. Launch QEMU and start booting.
2. Check when the device has booted by looking for the pattern login:.
3. Log in as the root user (default for our images).
4. Check that we were able to log in succesfully.
5. Start running the runtime test cases defined by TEST_SUITES.
6. One of such test cases could send a command to the QEMU target.
7. Check whether that command returned.
8. Check its output and status, return whether the test case passed or failed.

This patch allows this set of patterns to be defined instead of being hardcoded,
but it also automatically sets the defaults that we have been using in the past
if they have not been manually defined, for this reason, the patch is less
invasive and should not affect in any way how tests are currently being run.

Cases that can be enabled with this patch:
- A customized image that does not use the root user (or maybe we want to check
what happens if we dont use the root user).
- An image where the PS1 env variable has been modified, and the prompt pattern
wouldnt match the default.
- Baremetal applications, which do not follow the conventional way of booting
Linux and would probably not show a prompt for a user to log in, same applies
for testing bootloaders.
- poky-tiny: Using DISTRO=poky-tiny and an image such as the core-image-tiny
from meta-intel, which boots directly to RAM, and does not show a log in prompt
since it does not contain a conventional init process.

The code itself contains comments that should be self explanatory but here is an
example on how these patterns can be defined in a hypothetical case where we
want to run test cases as the webserver user instead:

TESTIMAGE_BOOT_PATTERNS = "send_login_user search_login_succeeded"
TESTIMAGE_BOOT_PATTERNS[send_login_user] = "webserver\n"
TESTIMAGE_BOOT_PATTERNS[search_login_succeeded] = "webserver@[a-zA-Z0-9\-]+:~#"

The variable TESTIMAGE_BOOT_PATTERNS defines which patterns to override when
used to communicate with the target when booting, anyone familiar with the
PACKAGECONFIG syntax should have no trouble setting these.

Other patterns would still be set up as default, e.g.
search_reached_prompt would still be login:

The accepted flags for TESTIMAGE_BOOT_PATTERNS are the following:
search_reached_prompt, send_login_user, search_login_succeeded,
search_cmd_finished.

They are prefixed with either search/send, to differentiate if the pattern is
meant to be sent or searched to/from the target terminal.

A working example of this code that falls under the baremetal case mentioned
above along with a test case is present on the meta-freertos layer, which tests
an RTOS image built with OpenEmbedded and automatically runs a test case on it
after booting such image:

As usual, INHERIT += "testimage" needs to be present on local.conf
$ bitbake freertos-demo -c testimage

RESULTS:
RESULTS - freertos_echo.FreeRTOSTest.test_freertos_echo: PASSED (2.00s)
SUMMARY:
freertos-demo () - Ran 1 test in 2.006s
freertos-demo - OK - All required tests passed (successes=1, skipped=0,
failures=0, errors=0)

(From OE-Core rev: 3ab2cbfeff371e8791b031a2852eeef80101a831)

Signed-off-by: Alejandro Hernandez Samaniego <aehs29@gmail.com>
Signed-off-by: Alejandro Hernandez Samaniego <alejandro@enedino.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-02-13 12:19:14 +00:00
Alejandro Hernandez Samaniego
e597809307 testimage: Allow testing on QEMU machines with a single serial port
commmit 6cde67d0a8 enables the use of qemurunner on machines that
only have a single serial port, but still sets the default value
as serial_ports=2 if not provided.

The testimage class does not call qemurunner with a serial_ports
argument, hence always defaulting to two.

Pass the serial_ports argument from the testimage class to allow
tests to run on QEMU machines with a single serial port.

(From OE-Core rev: a50d0163770f0b405a8de8a8a9cccd48c1de4112)

Signed-off-by: Alejandro Hernandez Samaniego <alejandro@enedino.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-02-13 12:19:14 +00:00