mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-31 13:03:02 +02:00
test: USB: Add new test to test systems with two USB ports
Break out this from the general USB test. Test if you can modify the ports independent of eachother.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
---
|
||||
- name: usb
|
||||
case: usb/test.py
|
||||
|
||||
- name: usb two ports
|
||||
case: usb_two_ports/test.py
|
||||
|
||||
@@ -38,27 +38,6 @@ with infamy.Test() as test:
|
||||
for port in available:
|
||||
until(lambda: usb.get_usb_state(target, port) == "unlocked")
|
||||
|
||||
if len(available) > 1:
|
||||
with test.step("Lock one port"):
|
||||
components = []
|
||||
component = {
|
||||
"name": available[1],
|
||||
"class": "infix-hardware:usb",
|
||||
"state": {
|
||||
"admin-state": "locked"
|
||||
}
|
||||
}
|
||||
components.append(component)
|
||||
|
||||
target.put_config_dict("ietf-hardware", {
|
||||
"hardware": {
|
||||
"component": components
|
||||
}
|
||||
})
|
||||
with test.step("Verify one port is locked and one unlocked"):
|
||||
until(lambda: usb.get_usb_state(target, available[1]) == "locked")
|
||||
until(lambda: usb.get_usb_state(target, available[0]) == "unlocked")
|
||||
|
||||
with test.step("Lock USB ports"):
|
||||
components = []
|
||||
for port in available:
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
@name USB configuration with USB ports
|
||||
@description Test that the configuration is consistent
|
||||
when having two USB ports.
|
||||
"""
|
||||
import infamy
|
||||
import copy
|
||||
import infamy.usb as usb
|
||||
import time
|
||||
import infamy.netconf as netconf
|
||||
from infamy.util import until,wait_boot
|
||||
|
||||
with infamy.Test() as test:
|
||||
with test.step("Initialize"):
|
||||
env = infamy.Env()
|
||||
target = env.attach("target", "mgmt")
|
||||
available=usb.get_usb_ports(target)
|
||||
|
||||
if len(available) < 2:
|
||||
test.skip()
|
||||
|
||||
with test.step("Lock the first USB port, and unlock the second USB port"):
|
||||
components = []
|
||||
component = {
|
||||
"name": available[0],
|
||||
"class": "infix-hardware:usb",
|
||||
"state": {
|
||||
"admin-state": "locked"
|
||||
}
|
||||
}
|
||||
components.append(component)
|
||||
component = {
|
||||
"name": available[1],
|
||||
"class": "infix-hardware:usb",
|
||||
"state": {
|
||||
"admin-state": "unlocked"
|
||||
}
|
||||
}
|
||||
components.append(component)
|
||||
|
||||
target.put_config_dict("ietf-hardware", {
|
||||
"hardware": {
|
||||
"component": components
|
||||
}
|
||||
})
|
||||
with test.step("Verify that the correct port is locked and the correct one is unlocked"):
|
||||
until(lambda: usb.get_usb_state(target, available[0]) == "locked")
|
||||
until(lambda: usb.get_usb_state(target, available[1]) == "unlocked")
|
||||
|
||||
with test.step("Unlock the first USB port, and lock the second USB port"):
|
||||
components = []
|
||||
component = {
|
||||
"name": available[0],
|
||||
"class": "infix-hardware:usb",
|
||||
"state": {
|
||||
"admin-state": "unlocked"
|
||||
}
|
||||
}
|
||||
components.append(component)
|
||||
component = {
|
||||
"name": available[1],
|
||||
"class": "infix-hardware:usb",
|
||||
"state": {
|
||||
"admin-state": "locked"
|
||||
}
|
||||
}
|
||||
components.append(component)
|
||||
|
||||
target.put_config_dict("ietf-hardware", {
|
||||
"hardware": {
|
||||
"component": components
|
||||
}
|
||||
})
|
||||
with test.step("Verify that the correct port is locked and the correct one is unlocked"):
|
||||
until(lambda: usb.get_usb_state(target, available[0]) == "unlocked")
|
||||
until(lambda: usb.get_usb_state(target, available[1]) == "locked")
|
||||
test.succeed()
|
||||
@@ -0,0 +1,23 @@
|
||||
graph "1x1" {
|
||||
layout="neato";
|
||||
overlap="false";
|
||||
esep="+20";
|
||||
|
||||
node [shape=record, fontname="monospace"];
|
||||
edge [color="cornflowerblue", penwidth="2"];
|
||||
|
||||
host [
|
||||
label="host | { <tgt> tgt }",
|
||||
pos="0,12!",
|
||||
kind="controller",
|
||||
];
|
||||
|
||||
target [
|
||||
label="{ <mgmt> mgmt } | target",
|
||||
pos="10,12!",
|
||||
|
||||
kind="infix",
|
||||
];
|
||||
|
||||
host:tgt -- target:mgmt [kind=mgmt]
|
||||
}
|
||||
Reference in New Issue
Block a user