~ruther/verilog-riscv-semestral-project

ref: 79c7be5c1c8ae2aea07f48d32abca650d24e8045 verilog-riscv-semestral-project/tests/official/official_tests.py -rw-r--r-- 1.4 KiB
79c7be5c — Rutherther chore: remove unnecessary executable flags 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import sys
import subprocess

sys.path.append('../')

from test_types import *
from pathlib import Path

def find_tests(out_dir: Path) -> list[TestGroup]:
    here = Path(__file__).parent
    result = subprocess.run(
        [ "make", "-C", here, "-s", "list" ],
        check = True,
        capture_output = True,
    )

    test_names = result.stdout.decode("utf-8").strip().split(' ')

    groups = []
    for test_name in test_names:
        tests = []
        group = TestGroup(
            tests = tests,
            directory = here,
            name = "rv32ui",
            c_test_file = out_dir / f"rv32ui_{test_name}.c",
            dat_test_file = out_dir / f"rv32ui_{test_name}.dat",
        )
        tests.append(Test(
            group = group,
            name = test_name,
            memory_in_file = out_dir / f"rv32ui_{test_name}.dat",
            memory_out_file = out_dir / f"rv32ui_{test_name}_output.dat",
            memory_exp_file = here / "expected.dat",
            register_dump_file = out_dir / f"rv32ui_{test_name}_registers.dat"
        ))

        groups.append(group)

    return groups

def compile_program(make_dir: Path, test: Test) -> bool:
    return subprocess.run(
        ["make", "-C", Path(__file__).parent, f"./out/{test.group.name}_{test.name}.dat"],
        check = True,
        stdout = subprocess.DEVNULL,
        stderr = subprocess.DEVNULL,
    ) == 0
Do not follow this link