-
Notifications
You must be signed in to change notification settings - Fork 2k
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
riotctrl_shell: initial import of shell interaction spawn #11406
Conversation
Without looking at the implementation, I am more thinking about a wrapper around
One of the reason is it could allow having different wrappers for the same instance. Which is way better for namespacing.
Otherwise every method must be namespaced This still allows to do composed objects with a separate class, that would here be the
I am just not sure where to put the
|
@cladmi like this (see last commits). I'm not sure about the decorator myself though (neither correctness nor appropriateness 😅) |
res = term.expect([r"\d+ bytes from (?P<source>[0-9a-f:]+): " | ||
r"icmp_seq=(?P<seq>\d+) ttl=(?P<ttl>\d+) " | ||
r"(rssi=(?P<rssi>-?\d+) dBm )?" | ||
r"time=(?P<rtt>\d+.\d+) ms", |
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.
Note to self: rtt
can also be omitted (when packet_size < sizeof(uint32_t)
).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Ping? I still think that this can help streamline the tests a lot and automate the release testings. |
If @cladmi agrees I could take over his commits. |
With @fjmolinas, we also have the plan to take over this PR. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Needs adaptation for https://github.com/RIOT-OS/riotctrl/ |
b9bce3e
to
b341d39
Compare
Rebased to current master, adapted for https://github.com/RIOT-OS/riotctrl/, and removed dependency of |
Yepp. Using Mixins is now not required anymore with the current approach. It is however still possible, if the test implementor prefers so :-). |
IMO you can split |
In the last round of commits I
|
May I squash @aabadie @fjmolinas? It's getting out of hand again ^^" |
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.
I tried to run the tests locally but had issues.
Can you add a tox.ini
file in riotctrl_shell
with the following content:
[tox]
envlist = test,flake8
skipsdist = True
[testenv]
commands =
test: {[testenv:test]commands}
flake8: {[testenv:flake8]commands}
[testenv:test]
deps =
pytest
-rrequirements.txt
commands =
pytest -v
[testenv:flake8]
deps = flake8
commands =
flake8 .
Also add __init__.py
in riotctrl_shell
and riotctrl_shell/tests
And finally apply the comments below. Then the tests can be run automatically using tox
. You can squash the issues reported by flake8 directly (minor unused imports) :)
b2a8351
to
d11b5b2
Compare
Applied your latest round of comments and squashed. |
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.
All good for me.
I was able to run the tests locally and they are all green:
tox --recreate
test recreate: /work/riot/RIOT/dist/pythonlibs/riotctrl_shell/.tox/test
test installdeps: pytest, -rrequirements.txt
test installed: attrs==19.3.0,more-itertools==8.4.0,packaging==20.4,pexpect==4.8.0,pluggy==0.13.1,psutil==5.7.0,ptyprocess==0.6.0,py==1.9.0,pyparsing==2.4.7,pytest==5.4.3,riotctrl @ git+ssh://git@github.com/RIOT-OS/riotctrl@dcca00a88e04c19661b60a1e574a869ca9a915bf,six==1.15.0,wcwidth==0.2.5
test run-test-pre: PYTHONHASHSEED='3279086202'
test run-test: commands[0] | pytest -v
============================================================ test session starts ============================================================
platform linux -- Python 3.8.2, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- /work/riot/RIOT/dist/pythonlibs/riotctrl_shell/.tox/test/bin/python
cachedir: .tox/test/.pytest_cache
rootdir: /work/riot/RIOT/dist/pythonlibs/riotctrl_shell
collected 12 items
tests/test_gnrc.py::test_ping6 PASSED [ 8%]
tests/test_gnrc.py::test_ping6_parser_success PASSED [ 16%]
tests/test_gnrc.py::test_ping6_parser_empty PASSED [ 25%]
tests/test_gnrc.py::test_ping6_parser_missing_rtts PASSED [ 33%]
tests/test_gnrc.py::test_pktbuf PASSED [ 41%]
tests/test_gnrc.py::test_pktbuf_parser_success_empty PASSED [ 50%]
tests/test_gnrc.py::test_pktbuf_parser_success_not_empty PASSED [ 58%]
tests/test_gnrc.py::test_pktbuf_parser_empty PASSED [ 66%]
tests/test_gnrc.py::test_pktbuf_parser_2nd_header_not_found PASSED [ 75%]
tests/test_sys.py::test_help PASSED [ 83%]
tests/test_sys.py::test_reboot PASSED [ 91%]
tests/test_sys.py::test_version PASSED [100%]
============================================================ 12 passed in 0.03s =============================================================
flake8 recreate: /work/riot/RIOT/dist/pythonlibs/riotctrl_shell/.tox/flake8
flake8 installdeps: flake8
flake8 installed: flake8==3.8.3,mccabe==0.6.1,pycodestyle==2.6.0,pyflakes==2.2.0
flake8 run-test-pre: PYTHONHASHSEED='3279086202'
flake8 run-test: commands[0] | flake8 .
__________________________________________________________________ summary __________________________________________________________________
test: commands succeeded
flake8: commands succeeded
congratulations :)
Let's move forward. ACK
Yay 🎉, thanks for the review and the patience with my impatience 😅 |
Awesome to see this in! |
Contribution description
One thing I really like about the test utils in RIOT-OS/Release-Specs#79 are the mixins to activate functionality to interact with a shell command. Based on that I provide
ShellInteraction
class here that is supposed to be used as a base class for these kind of mixins. As an example I provided a shell interaction implementation forping6
andreboot
. They allow for something likeTesting procedure
I provided some pytest tests
If it fails you might just need to initialize the TAP interface first:
Issues/PRs references
Depends on
#10949(now on the currently still private but visible for maintainers repo).