Commit Graph

25 Commits

Author SHA1 Message Date
Richard Purdie 3b39971748 classes/lib: Complete transition to python3
This patch contains all the other misc pieces of the transition to
python3 which didn't make sense to be broken into individual patches.

(From OE-Core rev: fcd6b38bab8517d83e1ed48eef1bca9a9a190f57)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-06-02 08:24:01 +01:00
Richard Purdie 8587bce564 classes/lib: Update to match python3 iter requirements
python3 standardises its use of iteration operations. Update
the code to match the for python3 requires.

(From OE-Core rev: 2476bdcbef591e951d11d57d53f1315848758571)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-06-02 08:24:00 +01:00
Richard Purdie bb44e5b99d oeqa/decorators: Use wraps consistently
We want the decorator to leave the function names of the test unchanged. Some
decorators are already using wraps for this but not all. Fix this to be consistent
allowing inspection of the test to give the wanted values.

(From OE-Core rev: 9e4d60b29ff5667d23a89953ce7139b34c11d40b)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-15 09:06:00 +01:00
Paul Eggleton fdfdfc8ccb oeqa/utils/decorators: fix missing keyword arguments on decorators
We need to handle keyword arguments here or sending a keyword argument
to a decorated function that accepts keyword arguments will trigger an
error. (This showed up when testcase decorators were added to the
recipetool.RecipetoolTests.test_recipetool_appendsrcfiles_basic_subdir
test).

(From OE-Core rev: f787b688f2884ce3fa888b4041030538c7d2bf55)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-10-27 07:24:30 +00:00
Leonardo Sandoval ec504e0ff6 oeqa/utils/decorators: Append the testname without the full path
When getting the failures/errors/skipped lists, include the
unit test without the full path.

This issue was found on this scenario

    | test_1_logrotate_setup (oeqa.runtime.logrotate.LogrotateTest) ... FAIL
    | test_2_logrotate (oeqa.runtime.logrotate.LogrotateTest) ... ok

Where test_1_logrotate failed and test_2_logrotate should not have
run because

    @skipUnlessPassed("test_1_logrotate_setup")
    def test_2_logrotate(self):

(From OE-Core rev: 8715beff7b910209627da3726b18b7abf801b557)

Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-10-01 07:43:35 +01:00
Lucian Musat 9549f57c80 oeqa/decorators: Fixed a problem with decorator logs link.
When not doing actual tests with testimage, like for example
exporting tests, the link to the log file was still created
although the actual log file was not existent. Fixed it by
moving the link creation part into the run() method.

(From OE-Core rev: 6950a5b1220d1ff81dae15195fe0d8e06977fec8)

Signed-off-by: Lucian Musat <george.l.musat@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-10-01 07:43:33 +01:00
Lucian Musat 3fb464f6af oeqa/decorators: Add timestamp to decorator logs.
To avoid logs being overwriten when running the automated
tests multiple times, log files include timestamps in
their names and a link is created to point to the latest one.

(From OE-Core rev: 0aa6af4aec6f9773ec2aea929deb3a1ed049cbb9)

Signed-off-by: Lucian Musat <george.l.musat@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-28 12:00:22 +01:00
Lucian Musat d8eb9d41b0 oeqa/decorators: Added decorator to restart the DUT in case of test hang.
Once the DUT is hanged during testing, currently all the following test
cases have to wait for default timeout to exit. Using this decorator the
user can choose a timeout at case by case basis and what happens when the
timeout is reached by overwriting the self.target.restart method.

[YOCTO #7853]

(From OE-Core rev: ce9a7501ea29ddba61ef7c297223b3f7eca5a2a1)

Signed-off-by: Lucian Musat <george.l.musat@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-18 09:05:21 +01:00
Lucian Musat 4925fa08e1 oeqa/decorators: Fixed a problem with tests having the same names.
When two or more tests had the same name but different classes then
the decorator log whould have the output all wrong. This was because
a comparison which was made only between method names but now it
compares classes too.

[YOCTO #8029]

(From OE-Core rev: 2b475f82d13b5c04d0c483d11a7df5e9352caa75)

Signed-off-by: Lucian Musat <george.l.musat@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-06 15:26:22 +01:00
zjh fac0d67ec2 testimage: filter proper test cases by tags
If a test case is decorate by oeqa.utils.decorators.tag, this case will
by add a tag, testrunner will filter these tags by TEST_SUITES_TAGS
[YOCTO #7849]

(From OE-Core rev: 085589b1018ba4d950baf7bcfb499be02c1b29fc)

Signed-off-by: zjh <junhuix.zhang@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-04 16:23:52 +01:00
Lucian Musat ad0aa8d548 oeqa/utils: Added timeout decorator for testcases.
(From OE-Core rev: c6fe26ade5734efb5250e00c56fdbb4095b0018b)

Signed-off-by: Lucian Musat <george.l.musat@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-06-11 23:59:17 +01:00
Nathan Rossi 71db5767a8 oeqa/utils/decorators: Fix up frame selection
Use threading to get the current threads ident to select the current
executing frame to ensure that the scanned stack is the expected stack.

This allows for the decorators to be used within a process that has
multiple threads executing.

(From OE-Core rev: a44d27b92baba4ab51f432ec01cdc473436ce406)

Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-04-21 07:20:25 +01:00
Patrick Ohly f626c58c32 testimage: sort modules based on dependencies
TEST_SUITES="auto" is useful to run all suitable tests without
having to hard-code the list. However, it did not take test
dependencies into account, which can be an issue for tests
which really depend on some other test to run first.

To fix this, modules get loaded in the order determined by
TESTS_SUITES, but then get re-ordered based on dependencies
derived from @skipUnlessPassed before running them. The original
order is used to break ties when there are no dependencies, so
reordering only occurs when really necessary.

@skipUnlessPassed gets extended such that it makes the test name
a method depends on available for inspection by the test loader
in oetest.py.

Unfortunately Python's unittest offers no API to inspect tests
in a TestSuite, so the code has to rely on implementation details
to find all tests. The worst that can happen when the implementation
changes is that tests are not found and reordering does not happen.

(From OE-Core rev: 6e4543a35836c572b23b9f8162b19d1e038d3ed2)

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-04-10 18:10:25 +01:00
Richard Purdie 5b985fd364 oeqa/utils/decorators: Try and improve ugly _ErrorHandler tracebacks
Currently, if one module is skipped, any other module calling skipModule
causes tracebacks about _ErrorHandler not having a _testMethodName
method.

This reworks the code in a way to avoid some of the problems by using
the id() method of the objects. It also maps to the correct name
format rather than "setupModule" or just skiping the item entirely.

(From OE-Core rev: 78d3bf2e4c88779df32b9dfbe8362dc24e9ad080)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-23 11:36:29 +00:00
Paul Eggleton 7d9b5fb69a oeqa/utils: fix testcase decorator to allow calling tests individually
Without this, running tests individually failed with a traceback:

$ oe-selftest --run-test
buildoptions.ImageOptionsTests.test_incremental_image_generation
2014-12-23 14:40:37,636 - selftest - INFO - Checking that everything is in order before running the tests
2014-12-23 14:40:38,408 - selftest - INFO - Running bitbake -p
2014-12-23 14:40:40,235 - selftest - INFO - Loading tests from:
oeqa.selftest.buildoptions.ImageOptionsTests.test_incremental_image_generation
Traceback (most recent call last):
  File "/home/user/poky/scripts/oe-selftest", line 179, in <module>
    ret = main()
  File "/home/user/poky/scripts/oe-selftest", line 164, in main
    suite.addTests(loader.loadTestsFromName(test))
  File "/usr/lib64/python2.7/unittest/loader.py", line 91, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "/home/user/poky/meta/lib/oeqa/selftest/buildoptions.py", line 12, in <module>
    class ImageOptionsTests(oeSelfTest):
  File "/home/user/poky/meta/lib/oeqa/selftest/buildoptions.py", line 14, in ImageOptionsTests
    @testcase(761)
NameError: global name 'func' is not defined

(From OE-Core rev: 8e3fbb0bb2c0eabfb39752c25e7c3f5d77881f64)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-12-25 08:27:12 +00:00
Paul Eggleton d4d73b0139 oeqa/utils: replace some tabs with spaces
Python code should use spaces only for indentation.

(From OE-Core rev: a1e22121e521aabf454a850cd7c8be60b7b1adc3)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-12-25 08:27:12 +00:00
Lucian Musat 576cb358d7 oeqa/utils: Added filter to LogResults decorator to enforce custom log level.
(From OE-Core rev: 65c97d4abd26f38917cd89b5f50f7299221b2123)

Signed-off-by: Lucian Musat <georgex.l.musat@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-09-29 12:12:44 +01:00
Corneliu Stoicescu c02d6b4c8d oeqa/utils/decorators.py: add import os
An 'import os' was omitted here while testing the previous decorators using runtime tests that import the os module before this one. Unfortunately oe-selftest fails because of this missing import.

(From OE-Core rev: 5381e6cf6bf7143074800b2949bfa5331fdb6d47)

Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-08-02 09:26:15 +01:00
Lucian Musat 0c4dd0ad16 oeqa: Refactor test skipping decorators to use the unittest result object
In order to make the test skipping decorators independent of the oeTest object we rely on the unittest result object to construct skip, fail and error lists used by these decorators.
Created a new object getResults that analyses upper frames and retrieves the unittest result object instance, then return a list of failed, skipped and error tests.
Also removed the oetest import from decorators.py because it was no longer required.

(From OE-Core rev: 4d2d201158236bd4c72546cf8db88681ff921b11)

Signed-off-by: Lucian Musat <georgex.l.musat@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-25 15:34:00 +01:00
Lucian Musat ae03111791 Added testcase decorator to use in logging. Added class decorator LogResults that outputs test results in separate log file.
(From OE-Core rev: 7e2b73f1ccfe2968ef780fef2edfaa31c3dae853)

Signed-off-by: Lucian Musat <georgex.l.musat@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-03 17:41:17 +01:00
Stefan Stanacar 19aeca1cac lib/oeqa: add oeTest superclass
Add oeTest superclass, make oeRuntimeTest inherit that and
make the necesarry adjustments. Tests in lib/oeqa/runtime don't
change, they still inherit oeRuntimeTest.
We should do this because oetest.py in the future can be a base module
for more stuff than oeRuntimeTest.

(From OE-Core rev: cd4ed41a070bd52c446ac3df8337f17ab9421145)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-11-05 22:04:28 +00:00
Mihai Lindner 2c83398940 lib/oeqa/utils: decorators: return the decorated method
Decorators should return whatever the decorated methods return.

(From OE-Core rev: c92513d6ff3f8f06d937a5cdf4d94708f27c3850)

Signed-off-by: Mihai Lindner <mihaix.lindner@linux.intel.com>
Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-26 11:47:21 +01:00
Stefan Stanacar 3dee534f1e lib/oeqa: fix dependecy check
Adds missing skip for smart test and fix the check (which I somehow broke
a while ago).

(From OE-Core rev: cf1790d992f067be8d5f9894458f55f6f1bdc61f)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-07-16 10:04:17 +01:00
Stefan Stanacar 656a8b97c1 testimage.bbclass, lib/oeqa: add headers and comments
Adds some comments to testimage.bbclass and the files it calls,
just to give an ideea of what it does.

(From OE-Core rev: 8bbb7116cf02466dfc59a17dc7bb51287aeea55b)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-07-16 10:04:17 +01:00
Radu Moisan 54f3848397 lib/oeqa/utils/decorators.py: decorators for test methods
Some skip decorators meant only for test methods, providing
some kind of test methods dependency.
They are used together with a test method name not a condition.
These are complementary to python's unittest skip decorators.

(From OE-Core rev: 79cb89648702aa80ec986e0026c62948de905b87)

Signed-off-by: Radu Moisan <radu.moisan@intel.com>
Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-07-09 10:53:45 +01:00