-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added integration test, first real test
- Loading branch information
1 parent
d00855f
commit 1f0363c
Showing
3 changed files
with
43 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
python3.6 -m venv --clear .venv | ||
if [ "$1" = 'clean' ]; then | ||
python3.6 -m venv --clear .venv | ||
fi | ||
|
||
. ./.venv/bin/activate | ||
pip3 install -U pip | ||
pip3 install -U poetry | ||
poetry update | ||
|
||
if [ "$1" = 'clean' ]; then | ||
pip3 install -U pip | ||
pip3 install -U poetry | ||
poetry update | ||
fi | ||
poetry build | ||
poetry install | ||
pytest --cov-report term-missing:skip-covered --cov=tracex_parser tests/ |
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,33 @@ | ||
from typing import NamedTuple | ||
|
||
from tracex_parser.file_parser import parse_tracex_buffer | ||
|
||
|
||
class TrxDemoStats(NamedTuple): | ||
total_events: int | ||
total_ticks: int | ||
obj_registry_size: int | ||
num_unique_events: int | ||
|
||
|
||
def test_demo_trx_files(): | ||
demo_stats = { | ||
'demo_filex.trx': TrxDemoStats(950, 949000, 7, 25), | ||
'demo_netx_tcp.trx': TrxDemoStats(950, 949000, 19, 36), | ||
'demo_netx_udp.trx': TrxDemoStats(950, 949000, 17, 23), | ||
'demo_threadx.trx': TrxDemoStats(974, 156206, 16, 11), | ||
} | ||
|
||
for trx_filename, tested_stats in demo_stats.items(): | ||
events, obj_map = parse_tracex_buffer(f'./{trx_filename}') | ||
|
||
assert len(events) == tested_stats.total_events | ||
|
||
total_ticks = events[-1].timestamp - events[0].timestamp | ||
assert total_ticks == tested_stats.total_ticks | ||
|
||
obj_reg_size = len(obj_map.keys()) | ||
assert obj_reg_size == tested_stats.obj_registry_size | ||
|
||
unique_events = set(e.id for e in events) | ||
assert len(unique_events) == tested_stats.num_unique_events |
This file was deleted.
Oops, something went wrong.