Harrison Mutai | 6ac31f3 | 2024-05-10 16:54:29 +0000 | [diff] [blame^] | 1 | #!/usr/bin/env python3 |
| 2 | # type: ignore[attr-defined] |
| 3 | |
| 4 | # |
| 5 | # Copyright (c) 2024, Arm Limited. All rights reserved. |
| 6 | # |
| 7 | # SPDX-License-Identifier: BSD-3-Clause |
| 8 | # |
| 9 | |
| 10 | """ Common configurations and fixtures for test environment.""" |
| 11 | |
| 12 | import pytest |
| 13 | from click.testing import CliRunner |
| 14 | |
| 15 | from tlc.cli import cli |
| 16 | |
| 17 | |
| 18 | @pytest.fixture |
| 19 | def tmptlstr(tmpdir): |
| 20 | return tmpdir.join("tl.bin").strpath |
| 21 | |
| 22 | |
| 23 | @pytest.fixture |
| 24 | def tmpfdt(tmpdir): |
| 25 | fdt = tmpdir.join("fdt.dtb") |
| 26 | fdt.write_binary(b"\x00" * 100) |
| 27 | return fdt |
| 28 | |
| 29 | |
| 30 | @pytest.fixture |
| 31 | def tlcrunner(tmptlstr): |
| 32 | runner = CliRunner() |
| 33 | with runner.isolated_filesystem(): |
| 34 | runner.invoke(cli, ["create", tmptlstr]) |
| 35 | return runner |
| 36 | |
| 37 | |
| 38 | @pytest.fixture |
| 39 | def tlc_entries(tmpfdt): |
| 40 | return [(0, "/dev/null"), (1, tmpfdt.strpath), (0x102, tmpfdt.strpath)] |