test_cpu: Set number of verilator jobs

By default verilator will be built with -j with no arguments, spawning
many processors. This causes large designs to failure in CI (probably
due to exhausting the memory of the build box):

 Error: Process completed with exit code 143.

Set the number of jobs to the number of CPUs in the system. This allows
designs such as Microwatt to build in CI.

Signed-off-by: Joel Stanley <joel@jms.id.au>
This commit is contained in:
Joel Stanley 2022-11-14 22:01:25 +10:30
parent 05b0c59607
commit b340b86975
1 changed files with 5 additions and 3 deletions

View File

@ -7,10 +7,11 @@
import unittest import unittest
import pexpect import pexpect
import sys import sys
import os
class TestCPU(unittest.TestCase): class TestCPU(unittest.TestCase):
def boot_test(self, cpu_type, cpu_variant="standard"): def boot_test(self, cpu_type, jobs, cpu_variant="standard"):
cmd = f'litex_sim --cpu-type={cpu_type} --cpu-variant={cpu_variant} --opt-level=O0' cmd = f'litex_sim --cpu-type={cpu_type} --cpu-variant={cpu_variant} --opt-level=O0 --jobs {jobs}'
litex_prompt = [b'\033\[[0-9;]+mlitex\033\[[0-9;]+m>'] litex_prompt = [b'\033\[[0-9;]+mlitex\033\[[0-9;]+m>']
is_success = True is_success = True
with open("/tmp/test_boot_log", "wb") as result_file: with open("/tmp/test_boot_log", "wb") as result_file:
@ -65,6 +66,7 @@ class TestCPU(unittest.TestCase):
"zynq7000", # (arm / hardcore) -> Hardcore. "zynq7000", # (arm / hardcore) -> Hardcore.
"zynqmp", # (aarch64 / hardcore) -> Hardcore. "zynqmp", # (aarch64 / hardcore) -> Hardcore.
] ]
jobs = os.cpu_count()
for cpu in tested_cpus: for cpu in tested_cpus:
with self.subTest(target=cpu): with self.subTest(target=cpu):
self.assertTrue(self.boot_test(cpu)) self.assertTrue(self.boot_test(cpu, jobs))