-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix a few bugs in the functional backend and refactor the testing
- Loading branch information
Showing
6 changed files
with
367 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
import pytest | ||
from rtlil_cells import generate_test_cases | ||
import random | ||
|
||
random_seed = random.getrandbits(32) | ||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--per-cell", type=int, default=None, help="run only N tests per cell" | ||
) | ||
parser.addoption("--per-cell", type=int, default=None, help="run only N tests per cell") | ||
parser.addoption("--steps", type=int, default=1000, help="run each test for N steps") | ||
parser.addoption("--seed", type=int, default=random_seed, help="seed for random number generation, use random seed if unspecified") | ||
|
||
def pytest_collection_finish(session): | ||
print('random seed: {}'.format(session.config.getoption("seed"))) | ||
|
||
@pytest.fixture | ||
def num_steps(request): | ||
return request.config.getoption("steps") | ||
|
||
@pytest.fixture | ||
def rnd(request): | ||
seed1 = request.config.getoption("seed") | ||
return lambda seed2: random.Random('{}-{}'.format(seed1, seed2)) | ||
|
||
def pytest_generate_tests(metafunc): | ||
if "cell" in metafunc.fixturenames: | ||
print(dir(metafunc.config)) | ||
per_cell = metafunc.config.getoption("per_cell", default=None) | ||
names, cases = generate_test_cases(per_cell) | ||
seed1 = metafunc.config.getoption("seed") | ||
rnd = lambda seed2: random.Random('{}-{}'.format(seed1, seed2)) | ||
names, cases = generate_test_cases(per_cell, rnd) | ||
metafunc.parametrize("cell,parameters", cases, ids=names) |
Oops, something went wrong.