Verified Commit 1d74c1dc authored by Karel Koci's avatar Karel Koci 🤘
Browse files

selftests/target: improve check for interface being up

This changes check from carrier being up to just interface being up.
That is actually the correct check we want to do. The carrier might be
down if we are connected directly to board (not trough switch) and thus
this test might fail even if everything is all right. In reality we want
to check that interface is set to be up and thus is going to be up once
carrier is up. This information is encoded in flags as lowest bit (this
was discovered by checking flag value rather not from documentation). So
this test now only checks if this bit is set or not.
parent bf74a307
......@@ -19,5 +19,5 @@ def test_network_up(target, interface):
if not target.is_configured(interface):
pytest.skip(f"Interface '{interface}' is not configured for this target.")
pth = Path("/sys/class/net")
with open(pth / target.device_map()[f"net:{interface}"] / "carrier", "r") as file:
assert file.readline() == "1\n"
with open(pth / target.device_map()[f"net:{interface}"] / "flags", "r") as file:
assert int(file.readline(), base=16) & 0x1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment