Skip to content

Commit

Permalink
Added integration test, first real test
Browse files Browse the repository at this point in the history
  • Loading branch information
julianneswinoga committed Jan 8, 2023
1 parent d00855f commit 1f0363c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
14 changes: 10 additions & 4 deletions scripts/run_tests.sh
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/
33 changes: 33 additions & 0 deletions tests/test_full_integration.py
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
2 changes: 0 additions & 2 deletions tests/test_temp.py

This file was deleted.

0 comments on commit 1f0363c

Please sign in to comment.