Skip to content

Commit

Permalink
Merge pull request #1168 from riscv-collab/march-to-cpu-opt-unittest
Browse files Browse the repository at this point in the history
Add unittest to march-to-cpu-opt
  • Loading branch information
cmuellner authored Dec 16, 2022
2 parents b410695 + cb8f1a0 commit 51c7370
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion scripts/march-to-cpu-opt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import argparse
import sys
import unittest

EXT_OPTS = {
"zba": "zba=true",
Expand Down Expand Up @@ -138,8 +139,22 @@ def conver_arch_to_qemu_cpu_opt(march):
cpu_opt.append("d=false")
return ",".join(cpu_opt)


class TestArchStringParse(unittest.TestCase):
def _test(self, arch, expected_arch_list, expected_vlen=0):
exts = parse_march(arch)
vlen = get_vlen(exts)
self.assertEqual(expected_vlen, vlen)
self.assertEqual(set(expected_arch_list), set(exts.keys()))

def test_rv64gc(self):
self._test("rv64gc", ['i', 'm', 'a', 'f', 'd', 'c'])
self._test("rv32imc_zve32x", ['i', 'm', 'c', 'zve32x'], expected_vlen=32)
self._test("rv32imc_zve32x_zvl128b", ['i', 'm', 'c', 'zve32x', 'zvl128b'], expected_vlen=128)


def selftest():
print(parse_march("rv64gc"))
unittest.main(argv=sys.argv[1:])

def main(argv):
opt = parse_opt(argv)
Expand Down

0 comments on commit 51c7370

Please sign in to comment.