-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use tox to handle virtual env and pytest to as test runner. Add a task in cirrus CI to run them. Signed-off-by: Adrian Moreno <[email protected]>
- Loading branch information
Showing
7 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
|
@@ -33,9 +33,3 @@ maintainers = [ | |
{name = "Retis team", email = "[email protected]"} | ||
] | ||
repository = "https://github.com/retis-org/retis" | ||
|
||
[project.optional-dependencies] | ||
test = [ | ||
"pytest", | ||
"tox", | ||
] |
This file contains 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,35 @@ | ||
from retis import Event, EventReader, EventSeries | ||
|
||
def verify_event(e): | ||
"""Verify the event is valid""" | ||
assert e.__class__ == Event | ||
assert isinstance(e.raw(), dict) | ||
assert isinstance(e.show(), str) | ||
assert "userspace" in e or "kernel" in e | ||
|
||
def test_event_reader() : | ||
"""Test event reader is capable of reading valid events""" | ||
r = EventReader("test_data/test_events.json") | ||
assert not r.sorted() | ||
|
||
for e in r: | ||
assert e.__class__ == Event | ||
assert isinstance(e.raw(), dict) | ||
assert isinstance(e.show(), str) | ||
|
||
def test_event_reader() : | ||
"""Test event reader is capable of reading sorted events""" | ||
r = EventReader("test_data/test_events_sorted.json") | ||
|
||
assert r.sorted() | ||
|
||
for s in r: | ||
assert s.__class__ == EventSeries | ||
length = len(s) | ||
i = 0 | ||
|
||
for e in s: | ||
verify_event(e) | ||
i += 1 | ||
|
||
assert i == length |
This file contains 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 @@ | ||
[{"common":{"smp_id":0,"task":{"comm":"napi/phy0-8197","pid":1360,"tgid":1360},"timestamp":23868643385999},"kernel":{"probe_type":"kprobe","symbol":"tcp_v4_rcv"},"skb":{},"skb-tracking":{"orig_head":18446616568293939200,"skb":18446616546229617920,"timestamp":23868643385999},"tracking":{"idx":0,"skb":{"orig_head":18446616568293939200,"skb":18446616546229617920,"timestamp":23868643385999}}}] | ||
[{"common":{"smp_id":2,"task":{"comm":"napi/phy0-8197","pid":1360,"tgid":1360},"timestamp":23868955262984},"kernel":{"probe_type":"raw_tracepoint","symbol":"openvswitch:ovs_dp_upcall"},"ovs":{"cmd":1,"cpu":1,"event_type":"upcall","port":3366920467},"skb":{},"skb-tracking":{"orig_head":18446616576100907520,"skb":18446616546107689472,"timestamp":23868955262984},"tracking":{"idx":0,"skb":{"orig_head":18446616576100907520,"skb":18446616546107689472,"timestamp":23868955262984}}},{"common":{"smp_id":3,"task":{"comm":"napi/phy0-8197","pid":1360,"tgid":1360},"timestamp":23868955276361},"kernel":{"probe_type":"kretprobe","symbol":"ovs_dp_upcall"},"ovs":{"event_type":"upcall_return","ret":0,"upcall_cpu":1,"upcall_ts":23868955262984},"skb":{},"skb-tracking":{"orig_head":18446616576100907520,"skb":18446616546107689472,"timestamp":23868955262984},"tracking":{"idx":1,"skb":{"orig_head":18446616576100907520,"skb":18446616546107689472,"timestamp":23868955262984}}}] | ||
[{"common":{"smp_id":0,"task":{"comm":"napi/phy0-8197","pid":1360,"tgid":1360},"timestamp":23868955449721},"kernel":{"probe_type":"raw_tracepoint","symbol":"skb:kfree_skb"},"skb":{},"skb-drop":{"drop_reason":"NO_SOCKET"},"skb-tracking":{"orig_head":18446616575285769216,"skb":18446616552502694400,"timestamp":23868955437572},"tracking":{"idx":0,"skb":{"orig_head":18446616575285769216,"skb":18446616552502694400,"timestamp":23868955437572}}}] |
This file contains 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,12 @@ | ||
[tox] | ||
requires = | ||
tox>=4 | ||
env_list = py{38,39,310,311,312} | ||
|
||
[testenv] | ||
description = Run unit tests | ||
deps = | ||
pytest>=7 | ||
maturin>=1.7 | ||
commands = | ||
pytest {posargs:pytests} |