Skip to content

Commit

Permalink
Use tempfile for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Oct 19, 2024
1 parent 3bb29fc commit 067d48e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
11 changes: 7 additions & 4 deletions examples/riscv_mini/tests/test_alu.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import tempfile
import pytest

import fault
Expand Down Expand Up @@ -33,7 +34,9 @@ def test_alu_basic(alu):
tester.eval()
tester.circuit.O.expect(py_op(A, B))

tester.compile_and_run("verilator", flags=["-Wno-unused"],
magma_opts={"disallow_local_variables": True,
"check_circt_opt_version": False},
magma_output="mlir-verilog")
with tempfile.TemporaryDirectory() as tempdir:
tester.compile_and_run("verilator", flags=["-Wno-unused"],
directory=tempdir,
magma_opts={"disallow_local_variables": True,
"check_circt_opt_version": False},
magma_output="mlir-verilog")
36 changes: 20 additions & 16 deletions examples/riscv_mini/tests/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import itertools
import random
import tempfile

from hwtypes import BitVector
import magma as m
from magma.mantle.counter import Counter
Expand Down Expand Up @@ -597,19 +599,21 @@ class TestState(m.Enum):
tester = ResetTester(DUT, DUT.CLK)
tester.reset()
tester.wait_until_high(DUT.done)
tester.compile_and_run(
"verilator",
magma_opts={
"flatten_all_tuples": True,
"disallow_local_variables": True,
"check_circt_opt_version": False,
},
flags=[
'-Wno-unused',
'-Wno-PINCONNECTEMPTY',
'--assert',
'-Wno-width',
],
disp_type="realtime",
magma_output="mlir-verilog",
)
with tempfile.TemporaryDirectory() as tempdir:
tester.compile_and_run(
"verilator",
directory=tempdir,
magma_opts={
"flatten_all_tuples": True,
"disallow_local_variables": True,
"check_circt_opt_version": False,
},
flags=[
'-Wno-unused',
'-Wno-PINCONNECTEMPTY',
'--assert',
'-Wno-width',
],
disp_type="realtime",
magma_output="mlir-verilog",
)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"staticfg",
"networkx",
"uinspect",
"circt==1.66.0",
# "circt==1.66.0",
],
python_requires='>=3.6',
long_description=long_description,
Expand Down

0 comments on commit 067d48e

Please sign in to comment.