[Libre-soc-bugs] [Bug 1173] provide an option to switch ISACaller to use a different Mem class that uses mmap.mmap instead of a dict

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Tue Oct 24 19:38:34 BST 2023


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

--- Comment #14 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Jacob Lifshay from comment #13)
> I just remembered use_mmap_mem is a parameter of TestRunnerBase.__init__,
> not TestAccumulatorBase.add_case, because it's can be thought of as
> configuring the cpu features like svp64=True does

I'll post this anyway, since i already wrote it all out:
i'm proposing:
class TestAccumulatorBase:
    __test__ = False  # pytest should ignore this class

    def __init__(self, flags=(), defaults=None):
        self.__subtest_args = {}
        self.flags = frozenset(flags)
        if defaults is None:
            defaults = {}
        else:
            defaults = dict(defaults)  # copy and/or convert
        self.defaults = defaults

        ...

    ...

    def add_case(self, all, the, current, args, *, src_loc_at=0, **kwargs):
        args = {
            "all": all,
            "the": the,
            "current": current,
            "args": args,
            **kwargs
        }
        for k in args.keys() | self.defaults.keys():
            v = args.get(k)
            if v is None:
                v = self.defaults.get(k)
            if v is None:
                args.pop(k)
            else:
                args[k] = v

        c = sys._getframe(1 + src_loc_at).f_code
        # name of caller of this function
        test_name = c.co_name
        # name of file containing test case
        test_file = os.path.splitext(os.path.basename(c.co_filename))[0]
        tc = TestCase(name=test_name,
                      test_file=test_file,
                      subtest_args=self.__subtest_args.copy(),
                      **args)

        self.test_data.append(tc)


class TestCase:
    __test__ = False  # pytest should ignore this class

    def __init__(self, program, name, regs=None, sprs=None, cr=0, mem=None,
                 msr=0,
                 do_sim=True,
                 extra_break_addr=None,
                 svstate=0,
                 expected=None,
                 stop_at_pc=None,
                 test_file=None,
                 subtest_args=None,
                 fpregs=None,
                 initial_fpscr=None,
                 **kwargs):

        self.program = program
        self.name = name

        if regs is None:
            regs = [0] * 32
        if sprs is None:
            sprs = {}
        if mem is None:
            mem = {}
        if fpregs is None:
            fpregs = [0] * 32
        self.regs = regs
        self.fpregs = fpregs
        self.sprs = sprs
        self.cr = cr
        self.mem = mem
        self.msr = msr
        self.do_sim = do_sim
        self.extra_break_addr = extra_break_addr
        self.svstate = svstate
        self.expected = expected # expected results from the test
        self.stop_at_pc = stop_at_pc # hard-stop address (do not attempt to
run)
        self.test_file = test_file
        self.subtest_args = {} if subtest_args is None else dict(subtest_args)
        if initial_fpscr is None:
            initial_fpscr = 0
        self.initial_fpscr = initial_fpscr
        self.rest = kwargs

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


More information about the libre-soc-bugs mailing list