[Libre-soc-bugs] [Bug 730] adapt ALU test cases to include expected results

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Tue Oct 26 04:47:00 BST 2021


https://bugs.libre-soc.org/show_bug.cgi?id=730

Jacob Lifshay <programmerjake at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |programmerjake at gmail.com

--- Comment #17 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to klehman9 from comment #15)
> https://git.libre-soc.org/?p=openpower-isa.git;a=commit;
> h=1b2f031b2a2cc3b6473f4965345f21547164c5c3
> 
> https://git.libre-soc.org/?p=openpower-isa.git;a=commit;
> h=0e32ffeccef54c27f8d7300260fd75eecb4dde2e
> 
> Sub directories now created based on the test cases filename.

You can use get_test_path from nmutil, it handles creating a unique path each
time it's called that is derived from the test case's name as well as the
current test method's name:

https://git.libre-soc.org/?p=nmutil.git;a=blob;f=src/nmutil/get_test_path.py;h=52bd53066d2254f87888a9c2b549ee3d5776b36d;hb=HEAD

example code (in src/demo.py):

class MyTest(unittest.TestCase):
    def test_fn(self):
        # code below should be put in common function:
        path = get_test_path(test_case, "test_outputs")
        # path is a pathlib.Path instance
        path.mkdir(parents=True, exist_ok=True)
        file_path = path / "file.py"
        with open(file_path, "wt") as file:
            pass # write to file

that creates a file:
test_outputs/src.demo.MyTest.test_fn/0/file.py

where the 0 is automatically incremented if you call get_test_path more than
once in the same unit test function.

/test_outputs should be added to .gitignore

I did a very similar thing in:
https://git.libre-soc.org/?p=ieee754fpu.git;a=blob;f=src/ieee754/partitioned_signal_tester.py;h=2986ee440e334cf2dd700db050fd76bbca323674;hb=HEAD#l352

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list