From d4bf60f2b005ff110c2cc096c4cf387f3a49c0d7 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 2 May 2019 23:32:46 +0100 Subject: [PATCH] replace run_test with run_fpunit to avoid nosetest auto-name-detect --- src/ieee754/add/test_state_add.py | 4 +-- src/ieee754/fpadd/test/test_add.py | 4 +-- src/ieee754/fpadd/test/test_add16.py | 4 +-- src/ieee754/fpadd/test/test_add64.py | 4 +-- src/ieee754/fpcommon/test/unit_test_double.py | 30 +++++++++---------- src/ieee754/fpcommon/test/unit_test_half.py | 30 +++++++++---------- src/ieee754/fpcommon/test/unit_test_single.py | 20 ++++++------- src/ieee754/fpdiv/test/test_div.py | 4 +-- src/ieee754/fpmul/test/test_mul.py | 4 +-- src/ieee754/fpmul/test/test_mul64.py | 4 +-- 10 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/ieee754/add/test_state_add.py b/src/ieee754/add/test_state_add.py index 8d1ccf59..e38e3e66 100644 --- a/src/ieee754/add/test_state_add.py +++ b/src/ieee754/add/test_state_add.py @@ -9,7 +9,7 @@ from fadd_state import FPADD from unit_test_single import (get_mantissa, get_exponent, get_sign, is_nan, is_inf, is_pos_inf, is_neg_inf, - match, get_case, check_case, run_test, + match, get_case, check_case, run_fpunit, run_edge_cases, run_corner_cases) def testbench(dut): @@ -59,7 +59,7 @@ def testbench(dut): 0x5e8ef81, 0x5c75da81, 0x2b017] stimulus_b = [0xadd79efa, 0xC0000000, 0x1c800000, 0xc038ed3a, 0xb328cd45, 0x114f3db, 0x2f642a39, 0xff3807ab] - yield from run_test(dut, stimulus_a, stimulus_b, add, get_case) + yield from run_fpunit(dut, stimulus_a, stimulus_b, add, get_case) count += len(stimulus_a) print (count, "vectors passed") diff --git a/src/ieee754/fpadd/test/test_add.py b/src/ieee754/fpadd/test/test_add.py index f09804cd..dd635e80 100644 --- a/src/ieee754/fpadd/test/test_add.py +++ b/src/ieee754/fpadd/test/test_add.py @@ -8,7 +8,7 @@ from ieee754.fpadd.nmigen_add_experiment import FPADD from ieee754.fpcommon.test.unit_test_single import (get_mantissa, get_exponent, get_sign, is_nan, is_inf, is_pos_inf, is_neg_inf, - match, get_rs_case, check_rs_case, run_test, + match, get_rs_case, check_rs_case, run_fpunit, run_edge_cases, run_corner_cases) def testbench(dut): @@ -66,7 +66,7 @@ def testbench(dut): stimulus_b = [0xff800001, 0xadd79efa, 0xC0000000, 0x1c800000, 0xc038ed3a, 0xb328cd45, 0x114f3db, 0x2f642a39, 0xff3807ab] - yield from run_test(dut, stimulus_a, stimulus_b, add, get_rs_case) + yield from run_fpunit(dut, stimulus_a, stimulus_b, add, get_rs_case) count += len(stimulus_a) print (count, "vectors passed") diff --git a/src/ieee754/fpadd/test/test_add16.py b/src/ieee754/fpadd/test/test_add16.py index f39ae8ae..a92ccda2 100644 --- a/src/ieee754/fpadd/test/test_add16.py +++ b/src/ieee754/fpadd/test/test_add16.py @@ -7,7 +7,7 @@ from nmigen_add_experiment import FPADD from unit_test_half import (get_mantissa, get_exponent, get_sign, is_nan, is_inf, is_pos_inf, is_neg_inf, - match, get_case, check_case, run_test, + match, get_case, check_case, run_fpunit, run_edge_cases, run_corner_cases) def testbench(dut): @@ -31,7 +31,7 @@ def testbench(dut): #regression tests stimulus_a = [ 0x8000, 0x8000 ] stimulus_b = [ 0x0000, 0xfc01 ] - yield from run_test(dut, stimulus_a, stimulus_b, add) + yield from run_fpunit(dut, stimulus_a, stimulus_b, add) count += len(stimulus_a) print (count, "vectors passed") diff --git a/src/ieee754/fpadd/test/test_add64.py b/src/ieee754/fpadd/test/test_add64.py index dcca12c6..ec16563e 100644 --- a/src/ieee754/fpadd/test/test_add64.py +++ b/src/ieee754/fpadd/test/test_add64.py @@ -11,7 +11,7 @@ from random import seed from unit_test_double import (get_mantissa, get_exponent, get_sign, is_nan, is_inf, is_pos_inf, is_neg_inf, - match, get_case, check_case, run_test, + match, get_case, check_case, run_fpunit, run_edge_cases, run_corner_cases) @@ -31,7 +31,7 @@ def testbench(dut): #regression tests stimulus_a = [0x3ff00000000000c5, 0xff80000000000000] stimulus_b = [0xbd28a404211fb72b, 0x7f80000000000000] - yield from run_test(dut, stimulus_a, stimulus_b, add) + yield from run_fpunit(dut, stimulus_a, stimulus_b, add) count += len(stimulus_a) print (count, "vectors passed") diff --git a/src/ieee754/fpcommon/test/unit_test_double.py b/src/ieee754/fpcommon/test/unit_test_double.py index feed8ffa..ac7ab7b6 100644 --- a/src/ieee754/fpcommon/test/unit_test_double.py +++ b/src/ieee754/fpcommon/test/unit_test_double.py @@ -67,7 +67,7 @@ def check_case(dut, a, b, z): assert out_z == z, "Output z 0x%x not equal to expected 0x%x" % (out_z, z) -def run_test(dut, stimulus_a, stimulus_b, op): +def run_fpunit(dut, stimulus_a, stimulus_b, op): expected_responses = [] actual_responses = [] @@ -138,7 +138,7 @@ def run_corner_cases(dut, count, op): 0x7ff0000000000000, 0xfff0000000000000 ], 2)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") @@ -147,73 +147,73 @@ def run_edge_cases(dut, count, op, maxcount=1000, num_loops=1000): #edge cases stimulus_a = [0x8000000000000000 for i in range(maxcount)] stimulus_b = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_a = [0x0000000000000000 for i in range(maxcount)] stimulus_b = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0x8000000000000000 for i in range(maxcount)] stimulus_a = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0x0000000000000000 for i in range(maxcount)] stimulus_a = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_a = [0x7FF8000000000000 for i in range(maxcount)] stimulus_b = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_a = [0xFFF8000000000000 for i in range(maxcount)] stimulus_b = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0x7FF8000000000000 for i in range(maxcount)] stimulus_a = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0xFFF8000000000000 for i in range(maxcount)] stimulus_a = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_a = [0x7FF0000000000000 for i in range(maxcount)] stimulus_b = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_a = [0xFFF0000000000000 for i in range(maxcount)] stimulus_b = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0x7FF0000000000000 for i in range(maxcount)] stimulus_a = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0xFFF0000000000000 for i in range(maxcount)] stimulus_a = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") @@ -221,7 +221,7 @@ def run_edge_cases(dut, count, op, maxcount=1000, num_loops=1000): for i in range(num_loops): stimulus_a = [randint(0, 1<<64) for i in range(maxcount)] stimulus_b = [randint(0, 1<<64) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += maxcount print (count, "random vectors passed") diff --git a/src/ieee754/fpcommon/test/unit_test_half.py b/src/ieee754/fpcommon/test/unit_test_half.py index 2f072905..50c9c24e 100644 --- a/src/ieee754/fpcommon/test/unit_test_half.py +++ b/src/ieee754/fpcommon/test/unit_test_half.py @@ -67,7 +67,7 @@ def check_case(dut, a, b, z): assert out_z == z, "Output z 0x%x not equal to expected 0x%x" % (out_z, z) -def run_test(dut, stimulus_a, stimulus_b, op): +def run_fpunit(dut, stimulus_a, stimulus_b, op): expected_responses = [] actual_responses = [] @@ -120,7 +120,7 @@ def run_corner_cases(dut, count, op): from itertools import permutations stimulus_a = [i[0] for i in permutations(corners, 2)] stimulus_b = [i[1] for i in permutations(corners, 2)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") @@ -130,73 +130,73 @@ def run_edge_cases(dut, count, op, maxcount=10, num_loops=1000): #edge cases stimulus_a = [0x8000 for i in range(maxcount)] stimulus_b = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_a = [0x0000 for i in range(maxcount)] stimulus_b = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0x8000 for i in range(maxcount)] stimulus_a = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0x0000 for i in range(maxcount)] stimulus_a = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_a = [0x7800 for i in range(maxcount)] stimulus_b = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_a = [0xF800 for i in range(maxcount)] stimulus_b = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0x7800 for i in range(maxcount)] stimulus_a = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0xF800 for i in range(maxcount)] stimulus_a = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_a = [0x7C00 for i in range(maxcount)] stimulus_b = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_a = [0xFC00 for i in range(maxcount)] stimulus_b = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0x7C00 for i in range(maxcount)] stimulus_a = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") stimulus_b = [0xFC00 for i in range(maxcount)] stimulus_a = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += len(stimulus_a) print (count, "vectors passed") @@ -204,7 +204,7 @@ def run_edge_cases(dut, count, op, maxcount=10, num_loops=1000): for i in range(num_loops): stimulus_a = [randint(0, maxint16-1) for i in range(maxcount)] stimulus_b = [randint(0, maxint16-1) for i in range(maxcount)] - yield from run_test(dut, stimulus_a, stimulus_b, op) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op) count += maxcount print (count, "random vectors passed") diff --git a/src/ieee754/fpcommon/test/unit_test_single.py b/src/ieee754/fpcommon/test/unit_test_single.py index 160ac5b1..8926bade 100644 --- a/src/ieee754/fpcommon/test/unit_test_single.py +++ b/src/ieee754/fpcommon/test/unit_test_single.py @@ -130,7 +130,7 @@ def check_case(dut, a, b, z, mid=None): assert out_mid == mid, "Output mid 0x%x != expected 0x%x" % (out_mid, mid) -def run_test(dut, stimulus_a, stimulus_b, op, get_case_fn): +def run_fpunit(dut, stimulus_a, stimulus_b, op, get_case_fn): expected_responses = [] actual_responses = [] @@ -191,13 +191,13 @@ def run_corner_cases(dut, count, op, get_case_fn): from itertools import permutations stimulus_a = [i[0] for i in permutations(corner_cases, 2)] stimulus_b = [i[1] for i in permutations(corner_cases, 2)] - yield from run_test(dut, stimulus_a, stimulus_b, op, get_case_fn) + yield from run_fpunit(dut, stimulus_a, stimulus_b, op, get_case_fn) count += len(stimulus_a) print (count, "vectors passed") -def run_test_2(dut, stimulus_a, stimulus_b, op, get_case_fn): - yield from run_test(dut, stimulus_a, stimulus_b, op, get_case_fn) - yield from run_test(dut, stimulus_b, stimulus_a, op, get_case_fn) +def run_fpunit_2(dut, stimulus_a, stimulus_b, op, get_case_fn): + yield from run_fpunit(dut, stimulus_a, stimulus_b, op, get_case_fn) + yield from run_fpunit(dut, stimulus_b, stimulus_a, op, get_case_fn) def run_cases(dut, count, op, fixed_num, maxcount, get_case_fn): if isinstance(fixed_num, int): @@ -208,35 +208,35 @@ def run_cases(dut, count, op, fixed_num, maxcount, get_case_fn): report = "random" stimulus_b = [randint(0, 1<<32) for i in range(maxcount)] - yield from run_test_2(dut, stimulus_a, stimulus_b, op, get_case_fn) + yield from run_fpunit_2(dut, stimulus_a, stimulus_b, op, get_case_fn) count += len(stimulus_a) print (count, "vectors passed 2^32", report) # non-canonical NaNs. stimulus_b = [set_exponent(randint(0, 1<<32), 128) \ for i in range(maxcount)] - yield from run_test_2(dut, stimulus_a, stimulus_b, op, get_case_fn) + yield from run_fpunit_2(dut, stimulus_a, stimulus_b, op, get_case_fn) count += len(stimulus_a) print (count, "vectors passed Non-Canonical NaN", report) # -127 stimulus_b = [set_exponent(randint(0, 1<<32), -127) \ for i in range(maxcount)] - yield from run_test_2(dut, stimulus_a, stimulus_b, op, get_case_fn) + yield from run_fpunit_2(dut, stimulus_a, stimulus_b, op, get_case_fn) count += len(stimulus_a) print (count, "vectors passed exp=-127", report) # nearly zero stimulus_b = [set_exponent(randint(0, 1<<32), -126) \ for i in range(maxcount)] - yield from run_test_2(dut, stimulus_a, stimulus_b, op, get_case_fn) + yield from run_fpunit_2(dut, stimulus_a, stimulus_b, op, get_case_fn) count += len(stimulus_a) print (count, "vectors passed exp=-126", report) # nearly inf stimulus_b = [set_exponent(randint(0, 1<<32), 127) \ for i in range(maxcount)] - yield from run_test_2(dut, stimulus_a, stimulus_b, op, get_case_fn) + yield from run_fpunit_2(dut, stimulus_a, stimulus_b, op, get_case_fn) count += len(stimulus_a) print (count, "vectors passed exp=127", report) diff --git a/src/ieee754/fpdiv/test/test_div.py b/src/ieee754/fpdiv/test/test_div.py index 3f192338..76790109 100644 --- a/src/ieee754/fpdiv/test/test_div.py +++ b/src/ieee754/fpdiv/test/test_div.py @@ -10,7 +10,7 @@ from nmigen_div_experiment import FPDIV from unit_test_single import (get_mantissa, get_exponent, get_sign, is_nan, is_inf, is_pos_inf, is_neg_inf, - match, get_case, check_case, run_test, + match, get_case, check_case, run_fpunit, run_edge_cases, run_corner_cases) @@ -33,7 +33,7 @@ def testbench(dut): #regression tests stimulus_a = [0xbf9b1e94, 0x34082401, 0x5e8ef81, 0x5c75da81, 0x2b017] stimulus_b = [0xc038ed3a, 0xb328cd45, 0x114f3db, 0x2f642a39, 0xff3807ab] - yield from run_test(dut, stimulus_a, stimulus_b, truediv, get_case) + yield from run_fpunit(dut, stimulus_a, stimulus_b, truediv, get_case) count += len(stimulus_a) print (count, "vectors passed") diff --git a/src/ieee754/fpmul/test/test_mul.py b/src/ieee754/fpmul/test/test_mul.py index 10fe5674..4f879ee1 100644 --- a/src/ieee754/fpmul/test/test_mul.py +++ b/src/ieee754/fpmul/test/test_mul.py @@ -10,7 +10,7 @@ from ieee754.fpmul.fmul import FPMUL from ieee754.fpcommon.test.unit_test_single import (get_mantissa, get_exponent, get_sign, is_nan, is_inf, is_pos_inf, is_neg_inf, - match, get_case, check_case, run_test, + match, get_case, check_case, run_fpunit, run_edge_cases, run_corner_cases) @@ -25,7 +25,7 @@ def tbench(dut, maxcount, num_loops): 0x5c75da81, 0x2b017] stimulus_b = [0xee1818c5, 0xc038ed3a, 0xb328cd45, 0x114f3db, 0x2f642a39, 0xff3807ab] - yield from run_test(dut, stimulus_a, stimulus_b, mul, get_case) + yield from run_fpunit(dut, stimulus_a, stimulus_b, mul, get_case) count += len(stimulus_a) print (count, "vectors passed") diff --git a/src/ieee754/fpmul/test/test_mul64.py b/src/ieee754/fpmul/test/test_mul64.py index 81c5b5a4..5f8eb305 100644 --- a/src/ieee754/fpmul/test/test_mul64.py +++ b/src/ieee754/fpmul/test/test_mul64.py @@ -11,7 +11,7 @@ from random import seed from unit_test_double import (get_mantissa, get_exponent, get_sign, is_nan, is_inf, is_pos_inf, is_neg_inf, - match, get_case, check_case, run_test, + match, get_case, check_case, run_fpunit, run_edge_cases, run_corner_cases) @@ -23,7 +23,7 @@ def testbench(dut): #regression tests stimulus_a = [0xff80000000000000, 0x3351099a0528e138] stimulus_b = [0x7f80000000000000, 0xd651a9a9986af2b5] - yield from run_test(dut, stimulus_a, stimulus_b, mul) + yield from run_fpunit(dut, stimulus_a, stimulus_b, mul) count += len(stimulus_a) print (count, "vectors passed") -- 2.30.2