From: Luke Kenneth Casson Leighton Date: Tue, 20 Sep 2022 16:43:32 +0000 (+0100) Subject: add quick test and loooong test of pysvp64dis - branches split out X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f0c443b9f7577e39a2b82199bf2c1e8aa767688c;p=openpower-isa.git add quick test and loooong test of pysvp64dis - branches split out --- diff --git a/src/openpower/sv/trans/test_pysvp64dis.py b/src/openpower/sv/trans/test_pysvp64dis.py index 874efac1..1ffc775e 100644 --- a/src/openpower/sv/trans/test_pysvp64dis.py +++ b/src/openpower/sv/trans/test_pysvp64dis.py @@ -257,26 +257,8 @@ class SVSTATETestCase(unittest.TestCase): self._do_tst(expected) def test_16_bc(self): - # hilarious. this should be autogenerated from a sequence - # of lists of options. it's a lot of frickin options. - lists = [[None, 'all'], - [None, 'm=r3/sz', 'm=r3/snz'], - #[None, 'vs', 'vsi', 'vsb', 'vsbi'], - [None, 'ctr', 'cti'], - #[None, 'sl'], - #[None, 'slu'], - #[None, 'lru'], - ] - expected = [] - for options in itertools.product(*lists): - options = list(filter(lambda x:x, options)) - options.sort() # otherwise chaos! - if len(options) != 0: - options = [''] + options # trick to make a "/" at the front - print ("option", options) - option = "sv.bc%s 12,*1,0xc" % "/".join(options) - expected.append(option) - #_old_handcrafted_expected = [ + """bigger list in test_pysvp64dis_branch.py, this one's "quick" + """ expected = [ "sv.bc/all 12,*1,0xc", "sv.bc/snz 12,*1,0xc", diff --git a/src/openpower/sv/trans/test_pysvp64dis_branch.py b/src/openpower/sv/trans/test_pysvp64dis_branch.py new file mode 100644 index 00000000..104330cb --- /dev/null +++ b/src/openpower/sv/trans/test_pysvp64dis_branch.py @@ -0,0 +1,62 @@ +from openpower.simulator.program import Program +from openpower.sv.trans.pysvp64dis import load, dump +from openpower.sv.trans.svp64 import SVP64Asm +from openpower.decoder.power_insn import Database, Verbosity +from openpower.decoder.power_enums import find_wiki_dir +from openpower.sv import sv_binutils_fptrans +import unittest +import itertools +import sys + +class SVSTATETestCase(unittest.TestCase): + + def _do_tst(self, expected): + isa = SVP64Asm(expected) + lst = list(isa) + with Program(lst, bigendian=False) as program: + print ("ops", program._instructions) + program.binfile.seek(0) + insns = load(program.binfile) + #for insn in insns: + #print ("insn", insn) + insns = list(insns) + print ("insns", insns) + for i, line in enumerate(dump(insns, verbosity=Verbosity.SHORT)): + name = expected[i].split(" ")[0] + with self.subTest("%d:%s" % (i, name)): + print("instruction", repr(line), repr(expected[i])) + self.assertEqual(expected[i], line, + "instruction does not match " + "'%s' expected '%s'" % (line, expected[i])) + + + def test_0_bc(self): + # hilarious. this should be autogenerated from a sequence + # of lists of options. it's a lot of frickin options. + lists = [[None, 'all'], + [None, 'm=r3', 'sz', 'snz'], # see below on this one... + [None, 'vs', 'vsi', 'vsb', 'vsbi'], + [None, 'ctr', 'cti'], + [None, 'sl'], + [None, 'slu'], + [None, 'lru'], + ] + expected = [] + for options in itertools.product(*lists): # permutations of list-options + options = list(filter(lambda x:x, options)) # filter Nones + # /sz or /snz must have /m=r3 added but then sorted + if 'sz' in options or 'snz' in options: + options.append("m=r3") + options.sort() # otherwise chaos! + if len(options) != 0: + options = [''] + options # trick to make a "/" at the front + print ("option", options) + # ahhhhhahahaha and sv.bcctr and sv.bcl ahahahahaah.... + option = "sv.bc%s 12,*1,0xc" % "/".join(options) + expected.append(option) + + self._do_tst(expected) + +if __name__ == "__main__": + unittest.main() +