Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trunner: assert jffs2 via output instead of time #283

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions trunner/harness/plo.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,24 @@ def erase(self, device: str, offset: int, size: int, timeout: Optional[int] = No
e.cmd = cmd
raise e

def jffs2(self, device: str, erase: bool, cleanmarkers: PloJffs2CleanmarkerSpec, timeout: Optional[int] = None):
def jffs2(self, device: str, erase: bool, cleanmarkers: PloJffs2CleanmarkerSpec, block_timeout: int):
"""Performs jffs2 command."""

block_count = cleanmarkers.number_of_blocks

cmd = f"jffs2 -d {device} -c {cleanmarkers}"
if erase:
cmd += " -e"

self.cmd(cmd, timeout)
self.send_cmd(cmd)

for i in range(0, block_count):
try:
self.dut.expect_exact(f"jffs2: block {i}/{block_count}", timeout=block_timeout)
except pexpect.TIMEOUT as e:
raise PloError("Wrong jffs2 command output!", cmd=cmd, output=self.dut.before) from e
maska989 marked this conversation as resolved.
Show resolved Hide resolved

self._assert_prompt()

def app(
self, device: str, file: str, imap: str, dmap: str, exec: bool = False
Expand Down Expand Up @@ -220,7 +230,8 @@ class PloJffsImageProperty(PloImageProperty):

flash_device_id: str
cleanmarkers_args: PloJffs2CleanmarkerSpec
timeout: int
# optimal timeout for erasing 1 block using jffs2 command
block_timeout: Optional[int] = 1


class PloImageLoader(TerminalHarness, PloInterface):
Expand Down Expand Up @@ -258,7 +269,7 @@ def __call__(self):
self.plo_loader()

if isinstance(self.image, PloJffsImageProperty):
self.jffs2(self.image.flash_device_id, True, self.image.cleanmarkers_args, self.image.timeout)
self.jffs2(self.image.flash_device_id, True, self.image.cleanmarkers_args, self.image.block_timeout)

with self.phoenixd.run():
self.copy_file2mem(
Expand Down
1 change: 0 additions & 1 deletion trunner/target/armv7a7.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class IMX6ULLEvkTarget(ARMv7A7Target):
block_size=0x10000,
cleanmarker_size=0x10,
),
timeout=275,
)
name = "armv7a7-imx6ull-evk"

Expand Down
1 change: 0 additions & 1 deletion trunner/target/armv7a9.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class Zynq7000ZedboardTarget(ARMv7A9Target):
block_size=0x10000,
cleanmarker_size=0x10,
),
timeout=140,
maska989 marked this conversation as resolved.
Show resolved Hide resolved
)
name = "armv7a9-zynq7000-zedboard"

Expand Down
22 changes: 13 additions & 9 deletions trunner/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def resolve_project_path():

class LogWrapper(StringIO):
"""Wrapper for saving all logs into StringIO and also streaming directly to stream"""

def __init__(self, stream: TextIO):
super().__init__("")
self.stream = stream
Expand Down Expand Up @@ -152,7 +153,8 @@ def flash(self) -> TestResult:
self.target.flash_dut()
result.set_stage(TestStage.DONE)
except (FlashError, HarnessError) as exc:
print(bold("ERROR WHILE FLASHING THE DEVICE"))
# the newline is needed to avoid printing exception in the same line as plo prompt
print(bold("\nERROR WHILE FLASHING THE DEVICE"))
print(exc)
result.fail_harness_exception(exc)

Expand Down Expand Up @@ -185,7 +187,7 @@ def _export_results_csv(self, results: Sequence[TestResult]):

fname = self.ctx.output + ".csv"

with open(fname, 'w', encoding='utf-8') as out_csv:
with open(fname, "w", encoding="utf-8") as out_csv:
out_csv.write(TestResult.get_csv_header() + "\n")
for res in results:
out_csv.write(res.to_csv() + "\n")
Expand All @@ -206,8 +208,8 @@ def _export_results_xml(self, results: Sequence[TestResult]):
suite = res.to_junit_testsuite(self.ctx.target.name)
suite.hostname = self.ctx.host.name
if is_github_actions():
suite.add_property('url', get_ci_url())
suite.add_property('SHA', os.environ['GITHUB_SHA'])
suite.add_property("url", get_ci_url())
suite.add_property("SHA", os.environ["GITHUB_SHA"])

xml.add_testsuite(suite)

Expand All @@ -220,7 +222,7 @@ def _export_results_xml(self, results: Sequence[TestResult]):
from lxml import etree
except ImportError:
from xml.etree import ElementTree as etree
with open(fname, 'wb') as out_xml:
with open(fname, "wb") as out_xml:
text = etree.tostring(xml._elem)
out_xml.write(text)

Expand Down Expand Up @@ -321,10 +323,12 @@ def run(self) -> bool:

sums = Counter(res.status for res in results)

print(f"TESTS: {len(results)} "
f"{green('PASSED')}: {sums.get(Status.OK, 0)} "
f"{red('FAILED')}: {sums.get(Status.FAIL, 0)} "
f"{yellow('SKIPPED')}: {sums.get(Status.SKIP, 0)}")
print(
f"TESTS: {len(results)} "
f"{green('PASSED')}: {sums.get(Status.OK, 0)} "
f"{red('FAILED')}: {sums.get(Status.FAIL, 0)} "
f"{yellow('SKIPPED')}: {sums.get(Status.SKIP, 0)}"
)

self._export_results_csv(results)
self._export_results_xml(results)
Expand Down
Loading