Conversation
eb1c8c9 to
dc3c265
Compare
52d08d7 to
9616f35
Compare
866560d to
4e13429
Compare
4aac9fa to
146a39e
Compare
016d94e to
fbb9e93
Compare
11556e5 to
d100fa7
Compare
a2706b4 to
893be2e
Compare
cceda4f to
9ff1e37
Compare
9ff1e37 to
77e2062
Compare
893453e to
0e753e4
Compare
- introduce basic Shell class - refactor ShellHarness - add TestHarness - change prompt checks to assert after each action instead of before JIRA: CI-343
network/network_unity.py
Outdated
| if idx == 0: | ||
| if parsed["status"] in ["FAIL", "IGNORE"]: | ||
| last_assertion = parsed | ||
|
|
||
| elif idx in (1, 2): | ||
| if last_assertion.get("msg"): | ||
| parsed["msg"] = last_assertion["msg"] | ||
| last_assertion = {} | ||
|
|
||
| status = Status.from_str(parsed["status"]) | ||
| subname = f"{parsed['group']}.{parsed['name']}" | ||
| if "path" in parsed and "line" in parsed: | ||
| parsed["msg"] = f"[{parsed['path']}:{parsed['line']}] " + parsed.get("msg", "") | ||
| result.add_subresult(subname, status, parsed.get("msg", "")) | ||
|
|
||
| stats[parsed["status"]] += 1 | ||
| results.append(parsed) | ||
|
|
||
| elif idx == 3: | ||
| for k, v in parsed.items(): | ||
| if k != "result": | ||
| parsed[k] = int(v) | ||
|
|
||
| assert ( | ||
| parsed["total"] == sum(stats.values()) | ||
| and parsed["fail"] == stats["FAIL"] | ||
| and parsed["ignore"] == stats["IGNORE"] | ||
| ), "".join(("There is a mismatch between the number of parsed tests and overall results!\n", | ||
| "Parsed results from the final Unity message (total, failed, ignored): ", | ||
| f"{parsed['total']}, {parsed['fail']}, {parsed['ignore']}\n", | ||
| "Found test summary lines (total, failed, ignored): ", | ||
| f"{sum(stats.values())}, {stats['FAIL']}, {stats['IGNORE']}")) | ||
|
|
||
| break | ||
|
|
||
| elif idx == 4: | ||
| network_test_responder.do_cmd(parsed["cmd"]) |
There was a problem hiding this comment.
match ... case could be used instead, but this is a purely stylistic decision
There was a problem hiding this comment.
match case was introduced in python 3.10 and some of our raspberries use still python 3.9
There was a problem hiding this comment.
we should be running inside gh-runner container (ubuntu 24.04 based) - so the python version should be at least 3.12.
There was a problem hiding this comment.
Yes, but I was running these tests locally during development, and debugging is also done locally. Despite that, I prefer using if statements rather than match case when there are only a few cases
There was a problem hiding this comment.
as I said: stylistic decision, fair to me
There was a problem hiding this comment.
@damianloew given our previous discussion in the PR about compatibility that resulted in the decision to upgrade the OS on our rasp pi's, should we stop keeping the code compatible with python 3.9?
If so, I too would be in favour of turning the if/elif/else into match ... case here
JIRA: CI-343
JIRA: CI-343
| - name: tcp | ||
| execute: test_tcp en1 | ||
| network_setup: True | ||
| targets: | ||
| value: [armv7a7-imx6ull-evk, armv7m7-imxrt106x-evk] | ||
|
|
||
| - name: tcp | ||
| execute: test_tcp en2 | ||
| network_setup: True | ||
| targets: | ||
| value: [armv7m7-imxrt117x-evk] |
There was a problem hiding this comment.
why no im6ull en2 and imxrt117x en1 tests?
There was a problem hiding this comment.
I only used the interfaces that had a cable plugged in inside the rack units. I know the other interfaces differ in hardware on those targets, are they supported?
There was a problem hiding this comment.
Yes, they both are supported:
- on imxrt117x: ENET is a 10/100M with rtl8201fi chip, ENET_1G is a 10/100/1000M with rtl8211fdi
- on imx6ull: ENET1 and ENET2 are 10/100M with the same PHY ksz8081rnb
| raise ParserError(f"network_setup must be a boolean value (true/false) not {network_setup}") | ||
|
|
||
| if network_setup: | ||
| self.test.iface_config = os.environ.get("IFACE_CONFIG", "") |
There was a problem hiding this comment.
Question, is IFACE_CONFIG meant to be set by the CI (or user if run locally)?
| suppress_dmesg: bool = True, | ||
| prompt: str | ||
| ): | ||
| super().__init__() |
There was a problem hiding this comment.
I see no reason to have it here, this class doesn't have a parent class
| # Setup environment for tests | ||
| def build_test(self, test: TestOptions) -> Callable[[TestResult], TestResult]: | ||
| builder = HarnessBuilder() | ||
| shell = Shell(self.dut, self.shell_prompt) |
There was a problem hiding this comment.
We import Shell only to create an object and parse it back to a harness. Perhaps, we should let the individual harnesses to handle it internally to reduce unnecessary imports.
I see the value in wrapping self.dut and self.shell_prompt into a single object, but if we don't use that object anywhere else, then I don't think we should be using it here at all
| prompt_timeout: Optional timeout to wait before prompt will show up. | ||
|
|
||
| """ | ||
| class Shell(): |
There was a problem hiding this comment.
Maybe instead of adding a shell object to each, we could make it an IntermediateShellHarness, a parent class of the harnesses below, that would inherit from IntermediateHarness as they do now.
There was a problem hiding this comment.
Either way, it looks like a change that is out of scope for this PR. We are making architectural changes with TestHarness and ShellHarness, which should be in a separate PR. Then, with those changes merged, we could implement NetworkSetupHarness as part of this PR
JIRA: CI-343
Description
Motivation and Context
Types of changes
How Has This Been Tested?
Checklist:
Special treatment