-
Notifications
You must be signed in to change notification settings - Fork 7
Added initial support for test plans #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xross
wants to merge
1
commit into
xmos:develop
Choose a base branch
from
xross:feat/testplan
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,78 +1,66 @@ | ||
| :orphan: | ||
|
|
||
| Test Support | ||
| ============ | ||
| ######################################### | ||
| test_support: XMOS test support helpers | ||
| ######################################### | ||
|
|
||
| This repo contains helpers for testing XMOS xCORE applictions and includes the following: | ||
| :vendor: XMOS | ||
| :version: 2.0.0 | ||
| :scope: General Use | ||
| :description: Reusable pytest, simulator, coverage, and test-plan helpers for XMOS software repositories | ||
| :category: Test | ||
| :keywords: pytest, xsim, pyxsim, xcoverage, testplan | ||
| :devices: xcore-200, xcore.ai | ||
|
|
||
| - Python wrapper for the xCORE simulator (xsim) | ||
| - Python access functions for XE files | ||
| - Python code coverage measurement (xcov) for pytest | ||
| ******* | ||
| Summary | ||
| ******* | ||
|
|
||
| Basic usage: xcoverage | ||
| ---------------------- | ||
| ``test_support`` provides reusable Python helpers for testing XMOS xCORE | ||
| applications. It includes wrappers for running tests on the xCORE simulator, | ||
| code coverage processing utilities, and pytest helpers for generating structured | ||
| test-plan result documentation. | ||
|
|
||
| This only suit for xsim. | ||
| ******** | ||
| Features | ||
| ******** | ||
|
|
||
| It requires disassembly and elf file which dumped from binary file (.xe file) by: | ||
| * Python wrapper for the xCORE simulator, ``xsim``. | ||
| * Python access functions for XE files. | ||
| * Python code coverage measurement helpers for pytest. | ||
| * Reusable pytest test-plan generation helpers for central parametrization, | ||
| generated result summaries, and optional executable sequence tables. | ||
|
|
||
| * xobjdump --split [.xe]. | ||
| * xobjdump -S [.xe] -o [output_file_name.dump]. | ||
| * run the above 2 step by youself or run method from xcov: generate_elf_disasm("/path_to/(name-of-xe).xe", "/path_where_store_elf_and_disasm", "/path_to/(name-of-disasm).dump") | ||
| ************ | ||
| Known issues | ||
| ************ | ||
|
|
||
| .xe must make with -g flag to enable the gdb bugger otherwise xcoverage won't work!. | ||
|
|
||
| It also needs a tracing file from xsim by running: | ||
|
|
||
| * xsim --trace-to [output_file_name.txt] [.xe]. | ||
|
|
||
| ``xcov_process`` | ||
| ....................... | ||
|
|
||
| This is the main function to be called in your test. | ||
| It returns the average coverage and save the data in .xcov file in xcov dir. | ||
| .xcov file is necessary for the below "xcov_combine" function. | ||
|
|
||
| xcov_process(disasm, trace, xcov_dir). | ||
|
|
||
| * @param disam: path to disasm file. | ||
| * @param trace: path to trace file. | ||
| * @param xcov_dir : path where xcov directory locates. | ||
| * @return average coverage of all src file. | ||
| * @output generate xcov file for xcov_combine and save in xcov dir. | ||
|
|
||
| ``xcov_combine`` | ||
| ....................... | ||
|
|
||
| see example in examples/code_coverage | ||
|
|
||
| ``combine_process`` | ||
| ....................... | ||
|
|
||
| see example in examples/code_coverage | ||
|
|
||
| ``Mark the source code as not expected to be hit`` | ||
| ........................................................ | ||
|
|
||
| Add a comment "//NOCOVER" or "//NOCOVERSTART" and "//NOCOVEREND" beside you source code. It wouldn't be counted in coverage. | ||
|
|
||
| see example in test/test_xcoverage | ||
|
|
||
| ``Excluded File`` | ||
| ........................................................ | ||
| Passing an excluded_file arg in xcov_process(), eg: | ||
|
|
||
| xcov_process(disasm, trace, xcov_dir, excluded_file=["/tests/shared/test_main.xc","/tests/shared/shared.h" ]) | ||
|
|
||
| Software version and dependencies | ||
| ................................. | ||
|
|
||
| The CHANGELOG contains information about the current and previous versions. | ||
| For a list of direct dependencies, look for DEPENDENT_MODULES in test_support/module_build_info. | ||
| * None | ||
|
|
||
| **************** | ||
| Development repo | ||
| **************** | ||
|
|
||
| * ``test_support`` is maintained as part of XMOS software infrastructure. | ||
|
|
||
| ************** | ||
| Required tools | ||
| ************** | ||
|
|
||
| * XMOS XTC Tools | ||
| * Python 3 | ||
| * pytest | ||
|
|
||
| ********************************* | ||
| Required libraries (dependencies) | ||
| ********************************* | ||
|
|
||
| * ``colorama`` | ||
| * ``PyYAML`` | ||
|
|
||
| ******* | ||
| Support | ||
| ******* | ||
|
|
||
| This package is supported by XMOS Ltd. Issues can be raised against the software at | ||
| `www.xmos.com/support <https://www.xmos.com/support>`_. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| CHANGELOG.rst | ||
| LICENSE.rst | ||
| examples/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| ############# | ||
| Code Coverage | ||
| ############# | ||
|
|
||
| ``test_support`` includes Python code coverage measurement helpers for pytest | ||
| tests that run on ``xsim``. | ||
|
|
||
| ************ | ||
| Requirements | ||
| ************ | ||
|
|
||
| Coverage processing requires a disassembly file and ELF file extracted from the | ||
| ``.xe`` binary: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| xobjdump --split app.xe | ||
| xobjdump -S app.xe -o app.dump | ||
|
|
||
| The same files can be generated from Python by calling | ||
| ``generate_elf_disasm(xe_path, output_dir, dump_path)``. | ||
|
|
||
| The ``.xe`` file must be built with debug information enabled using ``-g`` so | ||
| that coverage can be mapped back to source lines. | ||
|
|
||
| Coverage also requires a trace file from ``xsim``: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| xsim --trace-to trace.txt app.xe | ||
|
|
||
| ************ | ||
| xcov_process | ||
| ************ | ||
|
|
||
| ``xcov_process(disasm, trace, xcov_dir)`` processes a disassembly file and xsim | ||
| trace, returns the average source coverage, and writes an ``.xcov`` file under | ||
| ``xcov_dir``. The generated ``.xcov`` file is used by the combine helpers. | ||
|
|
||
| Arguments: | ||
|
|
||
| * ``disasm``: path to the disassembly file. | ||
| * ``trace``: path to the xsim trace file. | ||
| * ``xcov_dir``: directory where ``.xcov`` files are stored. | ||
|
|
||
| ************ | ||
| xcov_combine | ||
| ************ | ||
|
|
||
| ``xcov_combine`` combines coverage data from multiple ``.xcov`` files. See | ||
| ``examples/code_coverage`` for example usage. | ||
|
|
||
| *************** | ||
| combine_process | ||
| *************** | ||
|
|
||
| ``combine_process`` provides a higher-level combine flow. See | ||
| ``examples/code_coverage`` for example usage. | ||
|
|
||
| ******************* | ||
| Coverage Exclusions | ||
| ******************* | ||
|
|
||
| Add ``//NOCOVER`` beside a source line to exclude it from coverage. Use | ||
| ``//NOCOVERSTART`` and ``//NOCOVEREND`` to exclude a block. | ||
|
|
||
| An excluded file list can also be passed to ``xcov_process``: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| xcov_process( | ||
| disasm, | ||
| trace, | ||
| xcov_dir, | ||
| excluded_file=["/tests/shared/test_main.xc", "/tests/shared/shared.h"], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| ######################################### | ||
| test_support: XMOS test support helpers | ||
| ######################################### | ||
|
|
||
| ************ | ||
| Introduction | ||
| ************ | ||
|
|
||
| ``test_support`` contains reusable helpers for testing XMOS xCORE software from | ||
| pytest. The package is intended to be installed into consuming repositories and | ||
| used by their local test suites. | ||
|
|
||
| The package includes simulator wrappers, coverage processing helpers, and a | ||
| generic pytest test-plan plugin that can generate documentation-ready result | ||
| includes for projects using ``sphinx-needs``. | ||
|
|
||
| ************ | ||
| Installation | ||
| ************ | ||
|
|
||
| Consuming repositories commonly install ``test_support`` as an editable Python | ||
| dependency from their development environment: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| pip install -e ../test_support | ||
|
|
||
| The exact path depends on the repository layout used by the project under test. | ||
|
|
||
| ******** | ||
| Contents | ||
| ******** | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 2 | ||
|
|
||
| code_coverage | ||
| testplan | ||
|
|
||
| ****** | ||
| Pyxsim | ||
| ****** | ||
|
|
||
| ``Pyxsim`` provides Python helpers for running xCORE simulator based tests from | ||
| pytest. Tests can execute XE files under ``xsim`` and compare simulator output | ||
| using the provided tester classes. | ||
|
|
||
| For examples, see ``examples/pyxsim`` in this package. | ||
|
|
||
| ********* | ||
| Changelog | ||
| ********* | ||
|
|
||
| Release notes are recorded in ``CHANGELOG.rst`` at the package root. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make this just "_build. Is there anything under _build that is committed?