aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/oe-selftest
AgeCommit message (Collapse)Author
2016-12-22oe-selftest: fix behaviour if oe-selftest.log is a dangling symlinkPaul Eggleton
If you delete the log file that the oe-selftest.log symlink points to but not the symlink itself, because we were using os.path.exists() here the code assumed that the symlink didn't exist when in fact it still did. Use os.path.lexists() instead. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2016-12-19oe-selftest: import git module only when neededEd Bartosh
git module is not included into standard Python library and therefore causes import errors on the systems where PythonGit is not installed. As git module only used in the code implementing --repository functionality it's better to import git only in the scope that requires it. [YOCTO #10821] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-12-13oe-selftest: Add option to submit test result to a git repository.Mariano Lopez
This new option allows to commit the result to a git repository, along with the results it will add a metadata file for information of the current selftest run, such as: hostname, machine, distro, distro version, host version, and layers. This implementation will have a branch per different hostname, testing branch, and machine. To use this feature use: oe-selftest <options> --repository <repository_link> [YOCTO #9954] Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-11-23oe-selftest: enforce en_US.UTF-8 localeMaciej Borzecki
Replicate bitbake and eforce en_US.UTF-8 locale so that ouptut of locale-aware tools remains stable. Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-11-15oe-selftest: fix handling of test cases without ID in --list-tests-byMaciej Borzecki
Running `oe-selftest --list-tests-by module wic` will produce the following backtrace: Traceback (most recent call last): File "<snip>/poky/scripts/oe-selftest", line 668, in <module> ret = main() File "<snip>/poky/scripts/oe-selftest", line 486, in main list_testsuite_by(criteria, keyword) File "<snip>/poky/scripts/oe-selftest", line 340, in list_testsuite_by ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule) for tc in get_testsuite_by(criteria, keyword) ]) TypeError: unorderable types: int() < NoneType() The root cause is that a test case does not necessarily have an ID assigned, hence its value is None. Since Python 3 does not allow comparison of heterogeneous types, TypeError is raised. Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-09-15oe-selftest: check for coverage version before starting testsHumberto Ibarra
python coverage versions lower than 4.x have problems with some distros. Adding the 4.x version as requirement to continue with coverage tracking. [YOCTO #10207] Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-07-28oe-selftest: simplifying log filenamesBenjamin Esquivel
avoiding characters like ':' and making a clearer separation of the fields that compose the filename. Changing from: oe-selftest-2016-07-20_16:05:27.log to: oe-selftest-20160720-160527.log Signed-off-by: Benjamin Esquivel <benjamin.esquivel@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-07-28oe-selftest: export test results via xmlrunnerBenjamin Esquivel
if available, use the xmlrunner for exporting the test results to a dir named the same than the log where the text results are stored. this means creating a dir with the name of the log (without the .log) and dumping there the xml files that indicate the results of each of the tests. if xmlrunner is not available then it will behave the same as before, no xml exports. [YOCTO#9682] Signed-off-by: Benjamin Esquivel <benjamin.esquivel@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-07-20oe-selftest: print errors when failed to find testRobert Yang
For example: $ oe-selftest --run-tests-by name hello world 2016-07-12 00:33:28,678 - selftest - ERROR - Failed to find test: hello 2016-07-12 00:33:28,679 - selftest - ERROR - Failed to find test: world Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-06-02scripts: python3: decode subprocess outputEd Bartosh
stdeout and stderr content returned by subprocess API has different types in Python 3(bytes) and Python 2(string). Decoding it to 'utf-8' makes it unicode on both pythons. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-06-02classes/lib: Complete transition to python3Richard Purdie
This patch contains all the other misc pieces of the transition to python3 which didn't make sense to be broken into individual patches. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-06-02classes/lib: Update to explictly create lists where neededRichard Purdie
Iterators now return views, not lists in python3. Where we need lists, handle this explicitly. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-22scripts/oe-selftest: Remove inadvertant python3 specific changeRichard Purdie
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-21meta/selftest/scripts: Use print function for python3 compatibilityRichard Purdie
Used print function instead of print statement to make the code work in python 3. [Changes from both Ed and Richard] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-19scripts/oe-selftest: Improve listing by reducing unneeded spacingHumberto Ibarra
The --list-tests option assumes a terminal of 150 characters wide, which is clearly wrong. The output for this command is messy and hard to understand for lower widths. Every command should look good in a 80 characters terminal. Unfortunately, this can't be done at the moment. The bad naming of testcases have made the test names incredibly long. This patch reduces spacing between columns and shows the tests names in a concise and understandable way. The format is even the same one required for running a testcase. Once the testcase naming improves, this output will look even better. [Yocto #9534] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-04-18oe-selftest: Correct the usage examplesPeter Kjellerstedt
Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-04-05scripts/oe-selftest: avoid the creation of coverage file when coverage not ↵Humberto Ibarra
installed Coverage subprocessing file is being created even when coverage is not installed, which causes errors of "module not found" to be send to the oe-selftest output. This patch adds indent to the block of code creating this coverage file, so it can only be executed when coverage is actually installed. [Yocto #9334] Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-04-05scripts/oe-selftest: remove coverage file if any coverage option is givenHumberto Ibarra
Coverage temporal file for sub-processing is being removed only when the --coverage option was found. This is wrong since the file is created when any coverage option (source, include or omit) is given, even if --coverage is not one of them. This patch makes sure to remove the file if any coverage option was given. Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-04-05scripts/oe-selftest: remove unneeded coverage warningHumberto Ibarra
There is a message that warns the user about enabling subprocessing for coverage to work. After the fix for Yocto #8930, this task is done automatically, so the warning is not needed anymore. Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-03-31scripts, lib: Don't limit traceback lengths to arbitrary valuesRichard Purdie
There appears to have been a lot of copy and pasting of the code which prints tracebacks upon failure and limits the stack trace to 5 entries. This obscures the real error and is very confusing to the user it look me an age to work out why some tracebacks weren't useful. This patch removes the limit, making tracebacks much more useful for debugging. [YOCTO #9230] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-03-28scripts:/oe-selftest: Use timestamp instead of test names in coverage data fileHumberto Ibarra
This fixes the problem by changing the name to the coverage data file, using the timestamp as an identifier. The name for the coverage data file is constructed based on the tests ran; this has created a couple of issues so far, affecting coverage report. If --run-tests-by option is given, the data file name won't have any identifier, causing following runs to overwrite themselves. On the other hand, if too many tests are given, the file name exceeds linux limits and fails to store the coverage data all together. [Yocto #9253] Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-03-20oe-selftest: Fixed --list-tests-by tag optionDaniel Istrate
Commit 35be67951305950ba797dc2efddbc7d88fc0556a broke the --list-tests-by tag option. This patch fixes that. Having a module in lib/oeqa/selftest named testmodule: class TestClass(oeSelfTest): @tag(feature='tag1') def test_func1(self): pass @tag(feature=('tag1', 'tag2')) def test_func2(self): pass @tag(feature=('tag2', 'tag3')) def test_func3(self): pass @tag(feature=('tag1', 'tag2', 'tag3')) def test_func4(self): pass $ oe-selftest --list-tests-by tag tag1 ID TAG(s) NAME CLASS MODULE ---- ---------------- ---------- --------- -------- tag1 test_func1 TestClass testmodule tag1, tag2 test_func2 TestClass testmodule tag1, tag2, tag3 test_func4 TestClass testmodule ______________________________ Filtering by: tag Looking for: tag1 Total found: 3 $ oe-selftest --list-tests-by tag tag1 tag2 ID TAG(s) NAME CLASS MODULE ---- ---------------- ---------- --------- -------- tag1 test_func1 TestClass testmodule tag1, tag2 test_func2 TestClass testmodule tag1, tag2, tag3 test_func4 TestClass testmodule tag2, tag3 test_func3 TestClass testmodule ______________________________ Filtering by: tag Looking for: tag1, tag2 Total found: 4 $ oe-selftest --list-tests-by tag tag* ID TAG(s) NAME CLASS MODULE ---- ---------------- ---------- --------- -------- tag1 test_func1 TestClass testmodule tag1, tag2 test_func2 TestClass testmodule tag1, tag2, tag3 test_func4 TestClass testmodule tag2, tag3 test_func3 TestClass testmodule ______________________________ Filtering by: tag Looking for: tag* Total found: 4 Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-03-12scripts/oe-selftest: Add short names to most common optionsHumberto Ibarra
Add short names to most common options in oe-selftest. The options changed were --run-tests, --run-all-tests, --list-tests and --list-modules. [Yocto #9079] Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-03-12scripts/oe-selftest: Add search expression matching to run/list optionsHumberto Ibarra
The oe-selftest script required an exact matching for the parameters passed to its run-tests-by and list-tests-by options. Many tests can be retrieved here and filtering is a must. This patch add this filtering functionality by enabling the use of wildcards such as "*". [Yocto #8916] Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-28oe-selftest: Add support for lib/oeqa/selftest subdirectoriesCostin Constantin
This patch adds functionality to allow creating subdirectories inside lib/oeqa/selftest for all layers present in BBLAYERS. Like this, test cases can be grouped into organized directories. Addresses [YOCTO #7865] Signed-off-by: Costin Constantin <costin.c.constantin@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-02-28scripts/oe-selftest: Use site.USER_SITE to run coverage configuration code ↵Humberto Ibarra
for sub-process Coverage in oe-selftest currently requires to create or modify a sitecustomize.py file according the coverage tool setup instructions (http://coverage.readthedocs.org/). This file has to be located in the system's python folder, which is not a good solution since this folder is not accesible to non-privileged users. The best solution so far is to create this file in the home directory. This is implemented by creating the temporal file in the user site default folder. [Yocto #8930] Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-02-28scripts/oe-selftest: Add filtering to the coverage data gathered by oe-selftestHumberto Ibarra
When --coverage is used, oe-selftest gathers coverage data from the testcases executed. The command lacks a way of filtering which files to gather coverage data from. This patch adds three options to specify which files should be considered. The --coverage-source option specifies folders, while --coverage-include and --coverage-omit specify patterns to have an extra level of filtering. Some examples: 1. oe-selftest --run-all-tests --coverage Gathers coverage data from the default poky folders 2. oe-selftest --run-all-tests --coverage --coverage-include /home/me/poky/scripts/* Gathers coverage data only for the files located under '/home/me/poky/scripts' 3. oe-selftest --run-all-tests -coverage --coverage-omit /home/me/poky/meta* Gathers coverage data. Files inside all the folders starting with 'meta' under '/home/me/poky' are omited 4. oe-selftest --run-all-tests --coverage --coverage-source /home/me/poky/bitbake Gathers coverage data only from files inside the folder: '/home/me/poky/bitbake' [Yocto #8920] Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-01-07scripts/oe-selftest: Allow to run tests on random/all MACHINEsDaniel Istrate
Add an option for random MACHINE into oe-selftest: --machine [random/all] 1. random: will set a random MACHINE for each test 2. all: will run tests for all machines Custom machine sets only weak default values (??=) for MACHINE in machine.inc. This let test cases that require a specific MACHINE to be able to override it, using (?= or =). e.g.: oe-selftest --run-tests signing --machine random --> will run all tests switching MACHINE randomly for each test oe-selftest --run-tests signing --machine all --> for each machine will run all tests oe-selftest --run-all-tests --machine random Also update oeqa/selftest/base.py to accomodate this feature. Fix for [YOCTO #5880]. Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-01-07oe-selftest: New option --list-testsDaniel Istrate
This option will list all available tests in a comprehensive manner. Fix for [YOCTO #8868] Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-01-07oe-selftest: Improved --list-classes when determining test namesDaniel Istrate
--list-classes does a weak validation when determining test names: (if method.startswith("test_") which could report any class attribute that starts with 'test_' as a valid test case. This fix checks that the class attribute that starts with 'test_' is also callable (is a method). Fix for [YOCTO #8862] Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-01-07scripts/oe-selftest: Remove extra coverage data added to unittestsHumberto Ibarra
Coverage data tracking initiates too early, causing coverage data from the oe-selftest environment setting to be added to each run. Even when no tests are run oe-selftest reports around 24% of coverage due to this extra data. Change the custom resultclass used by the TextTestRunner to one generated from the command arguments. The generated class processes coverage when needed, running coverage setup just before the first testcase is run and reporting after the last one finished. [Yocto #8846] Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-12-27scripts/oe-selftest: Add support for selftest log with timestampCostin Constantin
Each time oe-selftest runs, the oe-selftest.log file is overwritten. This patch solves it by adding time stamp to each selftest log file and doing a symlink named as oe-selftest.log to the last one created. Signed-off-by: Costin Constantin <costin.c.constantin@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-12-22scripts: print usage in argparse-using scripts when a command-line error occursPaul Eggleton
For scripts that use Python's standard argparse module to parse command-line arguments, create a subclass which will show the usage the usage information when a command-line parsing error occurs. The most common case would be when the script is run with no arguments; at least then the user immediately gets to see what arguments they might need to pass instead of just an error message. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-12-12scripts: oe-selftest Added new features.Daniel Istrate
[YOCTO #8750] Allow oe-selftest to run custom test suites based on different criteria 1. Can run custom lists of tests based on different criteria: --run-tests-by <name|class|module|id|tag> <list of tests|classes|modules|ids|tags> eg: --run-tests-by module imagefeatures signing recipetool --run-tests-by id 1377 1273 935 --run-tests-by tag wic sstate bitbake 2. Can list tests based on different criteria: --list-tests-by <name|class|module|id|tag> <list of tests|classes|modules|ids|tags> eg: --list-tests-by module imagefeatures signing recipetool --list-tests-by id 1377 1273 935 --list-tests-by tag wic sstate bitbake 3. Can list all tags that have been set to test cases: --list-tags The list of tags should be kept as minimal as possible. This helps preview the tags used so far. To take advantage of the 'tag' feature: - add @tag(feature=<>) to testcases eg: @tag(feature='signing') for a single tag @tag(feature=(('signing', 'sstate')) or @tag(feature=['signing', 'sstate']) for multiple tags Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-12-01oe-selftest: Enable code coverage on unit testsLeonardo Sandoval
Enable code coverage through the library 'python coverage'. In case the environment variable COVERAGE_PROCESS_START is present (one of the requisites for measuring sub-processes; the second one is including some coverage statements into the python sitecustomize.py file) it will be taken into account, otherwise it is exported with value '.coveragerc'. The latter value is a configuration file (also automatically created) with some default settings. Once tests are executed, a coverage report is shown on the log and the coverage output data is stored with name '.coverage.<args>' where '<args>' is the name of the unit tests executed or 'all_tests' when running with --run-all-tests. This output data can be latter used for better reporting using the same tool (coverage). As briefly indicate before, measuring sub-process implies setting the env variable COVERAGE_PROCESS_START (done automatically by the oe-selftest code with this patch if not already set) and creating a sitecustomize.py as explained on [1]. If either one of these is missing, complete coverage will be incomplete. Current measurements for 'oe-selftest --run-all-tests' indicate that current coverage is around 42 % taking into account BBLAYERS, bitbake and scripts folders. More details on [2], indicating the coverage per file/module. This tasks has been done together with Humberto Ibarra <humberto.ibarra.lopez@linux.intel.com> [YOCTO #8679] [1] http://coverage.readthedocs.org/en/latest/subprocess.html [2] https://bugzilla.yoctoproject.org/attachment.cgi?id=2854 Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-07-27oe-selftest: add scripts/lib and bitbake/lib to pathPaul Eggleton
In particular, this allows us to use code from bitbake's bb module (such as tinfoil). Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-27oe-selftest: add libdirs from BBPATH to sys.pathChristopher Larson
This ensures that oeqa.selftest.* from layers are found. [YOCTO #7625] Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-07-27oe-selftest: obey oeqa.selftest.__path__Christopher Larson
This ensures that all paths that hold selftest tests will be checked (oeqa.selftest is a namespace package). [YOCTO #7625] Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-07-07scripts/oe-selftest: Added mechanism for including/removing bblayers.incDaniel Istrate
When oe-selftest starts it includes bblayers.inc into bblayers.conf When oe-selftest ends it deletes bblayers.inc and the included line from bblayers.conf Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-06-26oe-selftest: timestamp the test runsRoss Burton
The selftest can take a couple of hours to run, so add a custom result class to timestamp the output to make it easy to spot any slow tests. Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-02-07scripts/oe-selftest: add command line option to list test classesAlexandru DAMIAN
While trying to discover what tests are available, I felt the need to be able to list all individual tests so I can run specific tests. This patch adds the "--list-classes" command line option that lists the unit test classes and methods available. Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-02-07scripts/oe-selftest: fix startup backtraceAlexandru DAMIAN
Fixing a backtrace dump that happens if the script is started without sourcing the oe-init-build-env first. Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2014-07-19scripts/oe-selftest: add command-line parsing and optionsCorneliu Stoicescu
[YOCTO #6453] Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-02-08scripts/oe-selftest: return based on the test resultsStefan Stanacar
Regardless if the tests passed or not the script returned 0, which isn't what one would expect. Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-12-04lib/oeqa/selftest/base, scripts/oe-selftest: fix wrong remove path and do a ↵Stefan Stanacar
complete cleanup at the end The script should clean-up all the .inc files that might have been created by tests regardless of the outcome or if the script is interrupted. (currently the last test will leave a conf/selftest.inc around, even if it's not included anywhere) Also fix delete_recipeinc to actually delete what's supposed to. Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-12-03scripts/oe-selftest: script to run builds as unittest against bitbake or ↵Stefan Stanacar
various scripts The purpose of oe-selftest is to run unittest modules added from meta/lib/oeqa/selftest, which are tests against bitbake tools. Right now the script it's useful for simple tests like: - "bitbake --someoption, change some metadata, bitbake X, check something" type scenarios (PR service, error output, etc) - or "bitbake-layers <...>" type scripts and yocto-bsp tools. This commit also adds some helper modules that the tests will use and a base class. Also, most of the tests will have a dependency on a meta-selftest layer which contains specially modified recipes/bbappends/include files for the purpose of the tests. The tests themselves will usually write to ".inc" files from the layer or in conf/selftest.inc (which is added as an include in local.conf at the start and removed at the end) It's a simple matter or sourcing the enviroment, adding the meta-selftest layer to bblayers.conf and running: oe-selftest to get some results. It would finish faster if at least a core-image-minimal was built before. [ YOCTO #4740 ] Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>