Skip to content

Commit

Permalink
trunner: add armv8r52-mps3an536-qemu target
Browse files Browse the repository at this point in the history
JIRA: CI-468
  • Loading branch information
adamdebek committed Oct 11, 2024
1 parent 0733d9f commit 506449a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 7 deletions.
13 changes: 7 additions & 6 deletions psh/test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test:
targets:
include: [sparcv8leon3-generic-qemu]
include: [sparcv8leon3-generic-qemu, armv8r52-mps3an536-qemu]

tests:
- name: gibber
Expand All @@ -11,12 +11,13 @@ test:

- name: auth
harness: test-auth.py


#FIXME - test-pshlogin.py is only for targets with root
- name: pshlogin
harness: test-pshlogin.py
targets:
exclude: [armv7m7-imxrt106x-evk, armv7m7-imxrt117x-evk, armv7m4-stm32l4x6-nucleo, sparcv8leon3-generic-qemu]
exclude: [armv7m7-imxrt106x-evk, armv7m7-imxrt117x-evk, armv7m4-stm32l4x6-nucleo, sparcv8leon3-generic-qemu, armv8r52-mps3an536-qemu]

- name: echo
harness: test-echo.py
Expand All @@ -39,7 +40,7 @@ test:
- name: cat-shells
harness: test-cat-shells.py
targets:
exclude: [armv7m7-imxrt106x-evk, armv7m7-imxrt117x-evk, armv7m4-stm32l4x6-nucleo, sparcv8leon3-generic-qemu]
exclude: [armv7m7-imxrt106x-evk, armv7m7-imxrt117x-evk, armv7m4-stm32l4x6-nucleo, sparcv8leon3-generic-qemu, armv8r52-mps3an536-qemu]

- name: kill
harness: test-kill.py
Expand All @@ -53,21 +54,21 @@ test:
- name: touch-rootfs
harness: test-touch-rootfs.py
targets:
exclude: [armv7m7-imxrt106x-evk, armv7m7-imxrt117x-evk, armv7m4-stm32l4x6-nucleo, sparcv8leon3-generic-qemu]
exclude: [armv7m7-imxrt106x-evk, armv7m7-imxrt117x-evk, armv7m4-stm32l4x6-nucleo, sparcv8leon3-generic-qemu, armv8r52-mps3an536-qemu]

- name: ls
harness: test-ls.py

- name: ls-rootfs
harness: test-ls-rootfs.py
targets:
exclude: [armv7m7-imxrt106x-evk, armv7m7-imxrt117x-evk, armv7m4-stm32l4x6-nucleo, sparcv8leon3-generic-qemu]
exclude: [armv7m7-imxrt106x-evk, armv7m7-imxrt117x-evk, armv7m4-stm32l4x6-nucleo, sparcv8leon3-generic-qemu, armv8r52-mps3an536-qemu]

- name: runfile
harness: test-runfile.py
targets:
# runfile applet is not intended for non-rootfs targets
exclude: [armv7m7-imxrt106x-evk, armv7m7-imxrt117x-evk, armv7m4-stm32l4x6-nucleo, sparcv8leon3-generic-qemu]
exclude: [armv7m7-imxrt106x-evk, armv7m7-imxrt117x-evk, armv7m4-stm32l4x6-nucleo, sparcv8leon3-generic-qemu, armv8r52-mps3an536-qemu]

- name: history
harness: test-history.py
Expand Down
2 changes: 2 additions & 0 deletions runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
RISCV64GenericQemuTarget,
SPARCV8Leon3GenericQemuTarget,
ARMv7A9Zynq7000QemuTarget,
ARMv8R52MPS3AN536QemuTarget,
STM32L4x6Target,
Zynq7000ZedboardTarget,
IMX6ULLEvkTarget,
Expand Down Expand Up @@ -232,6 +233,7 @@ def resolve_targets_and_hosts() -> Tuple[Dict[str, Type[TargetBase]], Dict[str,
IA32GenericQemuTarget,
RISCV64GenericQemuTarget,
ARMv7A9Zynq7000QemuTarget,
ARMv8R52MPS3AN536QemuTarget,
STM32L4x6Target,
IMXRT106xEvkTarget,
IMXRT117xEvkTarget,
Expand Down
37 changes: 37 additions & 0 deletions trunner/dut.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,43 @@ def open(self):
# on proper guest OSes this results in `\r\r\n` which might be incorrectly interpreted by CI log viewers
# use custom preexec_fn to setup termios of child PTY
self.pexpect_proc = pexpect.spawn(*self.args, preexec_fn=self._set_termios_raw, **self.kwargs)
time.sleep(0.2)
self._set_logfiles()


class fdspawncustom(pexpect.spawn):
"""
The current UART implementation on the ARMv8R52MPS3AN536 breaks when bytes are sent too fast.
To alleviate this problem, we override the pexpect class and introduce a delay in the send function.
"""

def send(self, s):
ret = 0
for c in s:
ret += super().send(c)
time.sleep(0.03)

return ret


class ARMv8R52MPS3AN536_Dut(ProcessDut):
@staticmethod
def _set_termios_raw():
"""set current tty not to process newlines"""
attr = termios.tcgetattr(STDOUT_FILENO)

# disable any newline manilpulations in c_oflag
attr[1] &= ~(termios.ONLCR | termios.OCRNL | termios.ONOCR | termios.ONLRET)

termios.tcsetattr(STDOUT_FILENO, termios.TCSANOW, attr)

def open(self):
# qemu when using stdio serial enforces ONLCR termios flag (converting `\n` to `\r\n`)
# on proper guest OSes this results in `\r\r\n` which might be incorrectly interpreted by CI log viewers
# use custom preexec_fn to setup termios of child PTY
self.pexpect_proc = fdspawncustom(
*self.args, preexec_fn=self._set_termios_raw, **self.kwargs
)
self._set_logfiles()


Expand Down
2 changes: 2 additions & 0 deletions trunner/target/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
RISCV64GenericQemuTarget,
ARMv7A9Zynq7000QemuTarget,
SPARCV8Leon3GenericQemuTarget,
ARMv8R52MPS3AN536QemuTarget
)
from .host import HostPCGenericTarget

Expand All @@ -19,6 +20,7 @@
"RISCV64GenericQemuTarget",
"SPARCV8Leon3GenericQemuTarget",
"ARMv7A9Zynq7000QemuTarget",
"ARMv8R52MPS3AN536QemuTarget",
"HostPCGenericTarget",
"STM32L4x6Target",
"Zynq7000ZedboardTarget",
Expand Down
17 changes: 16 additions & 1 deletion trunner/target/emulated.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Callable

from trunner.ctx import TestContext
from trunner.dut import QemuDut
from trunner.dut import QemuDut, ARMv8R52MPS3AN536_Dut
from trunner.harness import HarnessBuilder, RebooterHarness, ShellHarness, TestStartRunningHarness
from trunner.types import TestOptions, TestResult
from .base import TargetBase
Expand Down Expand Up @@ -107,3 +107,18 @@ def __init__(self):
@classmethod
def from_context(cls, _: TestContext):
return cls()


class ARMv8R52MPS3AN536QemuTarget(QemuTarget):
name = "armv8r52-mps3an536-qemu"
rootfs = False
experimental = True

def __init__(self):
super().__init__("armv8r52-mps3an536-qemu.sh")
self.dut = ARMv8R52MPS3AN536_Dut(f"{self.project_dir}/scripts/{self.script}", encoding="utf-8")
self.rebooter = QemuDutRebooter(self.dut)

@classmethod
def from_context(cls, _: TestContext):
return cls()

0 comments on commit 506449a

Please sign in to comment.