From e0f084e4ada4508f0901bdc7c8a9b813d82fe517 Mon Sep 17 00:00:00 2001 From: Ivan Yurchenko Date: Sun, 6 Nov 2022 08:44:09 +0200 Subject: [PATCH] integration-tests: stricter e2e test Test heap reading --- integration_tests/manual_test_e2e.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/integration_tests/manual_test_e2e.py b/integration_tests/manual_test_e2e.py index 10be274..7254e64 100644 --- a/integration_tests/manual_test_e2e.py +++ b/integration_tests/manual_test_e2e.py @@ -13,15 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import mmap import os import subprocess import sys import time -from contextlib import contextmanager +from contextlib import contextmanager, closing from pathlib import Path from typing import Iterator - import pytest +from pyheap_ui.heap_reader import HeapReader def test_e2e(test_heap_path: str) -> None: @@ -32,6 +33,14 @@ def test_e2e(test_heap_path: str) -> None: assert dp.returncode == 0 assert os.path.exists(test_heap_path) + with open(test_heap_path, "rb") as f: + mm = mmap.mmap(f.fileno(), length=0, access=mmap.ACCESS_READ) + with closing(mm): + reader = HeapReader(mm) + reader.read() + # Check that we have read everything. + assert reader._offset == mm.size() + @pytest.fixture def test_heap_path(tmp_path: Path) -> str: @@ -80,6 +89,7 @@ def _dumper_process( try: yield dumper_proc finally: - print(dumper_proc.stdout.read().decode("utf-8")) - print(dumper_proc.stderr.read().decode("utf-8")) dumper_proc.kill() + out, err = dumper_proc.communicate(timeout=5) + print(out.decode("utf-8")) + print(err.decode("utf-8"))