summaryrefslogtreecommitdiff
diff options
-rwxr-xr-xbin/net_if_watcher.py43
-rw-r--r--units/usb/test-plan.pxu1
-rw-r--r--units/usb/usb-c.pxu16
3 files changed, 60 insertions, 0 deletions
diff --git a/bin/net_if_watcher.py b/bin/net_if_watcher.py
new file mode 100755
index 0000000..0ba61df
--- /dev/null
+++ b/bin/net_if_watcher.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+# Copyright 2018 Canonical Ltd.
+# All rights reserved.
+#
+# Written by:
+# Maciej Kisielewski <maciej.kisielewski@canonical.com>
+"""
+Detect insertion of a new network interface.
+"""
+
+from pathlib import Path
+import time
+
+
+def get_ifaces():
+ return set([i.name for i in Path("/sys/class/net").iterdir()])
+
+
+def main():
+ print("INSERT NOW")
+ starting_ifaces = get_ifaces()
+ attempts = 20
+ while attempts > 0:
+ now_ifaces = get_ifaces()
+ # check if something disappeared
+ if not starting_ifaces == now_ifaces & starting_ifaces:
+ raise SystemExit("Interface(s) disappeared: {}".format(
+ ", ".join(list(starting_ifaces - now_ifaces))))
+ new_ifaces = now_ifaces - starting_ifaces
+ if new_ifaces:
+ print()
+ print("New interface(s) detected: {}".format(
+ ", ".join(list(new_ifaces))))
+ return
+ time.sleep(1)
+ print('.', end='', flush=True)
+ attempts -= 1
+ print()
+ raise SystemExit("Failed to detect new network interface")
+
+
+if __name__ == '__main__':
+ main()
diff --git a/units/usb/test-plan.pxu b/units/usb/test-plan.pxu
index 27a0616..63c62b8 100644
--- a/units/usb/test-plan.pxu
+++ b/units/usb/test-plan.pxu
@@ -69,6 +69,7 @@ include:
usb-c/insert certification-status=blocker
usb-c/storage-automated certification-status=blocker
usb-c/remove certification-status=blocker
+ usb-c/c-to-ethernet-adapter-insert
id: after-suspend-usb-cert-full
unit: test plan
diff --git a/units/usb/usb-c.pxu b/units/usb/usb-c.pxu
index d2004c2..cf7c5f6 100644
--- a/units/usb/usb-c.pxu
+++ b/units/usb/usb-c.pxu
@@ -187,3 +187,19 @@ requires:
manifest.has_usb_type_c == 'True'
estimated_duration: 30
+id: usb-c/c-to-ethernet-adapter-insert
+plugin: user-interact
+category_id: com.canonical.plainbox::usb
+imports: from com.canonical.plainbox import manifest
+requires: manifest.has_usb_type_c == 'True'
+command:
+ net_if_watcher.py
+_summary: Check if USB Type-C to Ethernet adapter works
+_purpose:
+ This test will check if system detects network interface of the Type-C to
+ ethernet adapter.
+_steps:
+ 1. Prepare USB Type-C to Ethernet adapter
+ 2. Start the test
+ 3. When the message "INSERT NOW" is shown, plug in the adapter to Type-C port
+estimated_duration: 20