Merge ~kissiel/checkbox-support:removable-watcher-zapper-additions into checkbox-support:master

Proposed by Maciej Kisielewski
Status: Merged
Approved by: Maciej Kisielewski
Approved revision: a30ba66f140a57ac4184cec02d7b903035288666
Merged at revision: 7e28939eacf58e204b66446966b7acc31415c327
Proposed branch: ~kissiel/checkbox-support:removable-watcher-zapper-additions
Merge into: checkbox-support:master
Diff against target: 57 lines (+24/-5)
1 file modified
checkbox_support/scripts/run_watcher.py (+24/-5)
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+421205@code.launchpad.net

Description of the change

This makes the USB insertion/removal tests zapper-aware. This patches the code that is run on core. Similar patch is proposed for PPC for classic images.

To post a comment you must log in.
Revision history for this message
Maciej Kisielewski (kissiel) wrote :
Revision history for this message
Paul Larson (pwlars) wrote :

Pretty much just the same comments from the previous branch about 'capapbilities'. I don't know if git will nag you. If you want to avoid that in the future, you can tell it that this branch depends on the other one and it'll only show the changes from this branch in the review.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/checkbox_support/scripts/run_watcher.py b/checkbox_support/scripts/run_watcher.py
2index ad0356a..db995a1 100644
3--- a/checkbox_support/scripts/run_watcher.py
4+++ b/checkbox_support/scripts/run_watcher.py
5@@ -18,6 +18,8 @@ import signal
6 import sys
7 from systemd import journal
8
9+from checkbox_support.scripts.zapper_proxy import ControlVersionDecider
10+
11
12 logger = logging.getLogger(__file__)
13 logger.setLevel(logging.INFO)
14@@ -59,14 +61,29 @@ class USBWatcher:
15 j.seek_tail()
16 p = select.poll()
17 p.register(j, j.get_events())
18- if self.args.testcase == "insertion":
19- print("\n\nINSERT NOW\n\n", flush=True)
20- elif self.args.testcase == "removal":
21- print("\n\nREMOVE NOW\n\n", flush=True)
22+ if self.args.zapper_usb_address:
23+ zapper_host = os.environ.get('ZAPPER_ADDRESS')
24+ if not zapper_host:
25+ raise SystemExit(
26+ "ZAPPER_ADDRESS environment variable not found!")
27+ zapper_control = ControlVersionDecider().decide(zapper_host)
28+ usb_address = self.args.zapper_usb_address
29+ if self.args.testcase == "insertion":
30+ print("Calling zapper to connect the USB device")
31+ zapper_control.usb_set_state(usb_address, 'dut')
32+ elif self.args.testcase == "removal":
33+ print("Calling zapper to disconnect the USB device")
34+ zapper_control.usb_set_state(usb_address, 'off')
35+ else:
36+ if self.args.testcase == "insertion":
37+ print("\n\nINSERT NOW\n\n", flush=True)
38+ elif self.args.testcase == "removal":
39+ print("\n\nREMOVE NOW\n\n", flush=True)
40 while p.poll():
41 if j.process() != journal.APPEND:
42 continue
43- self._callback([e['MESSAGE'] for e in j if e and 'MESSAGE' in e])
44+ self._callback(
45+ [e['MESSAGE'] for e in j if e and 'MESSAGE' in e])
46
47 def _callback(self, lines):
48 for line in lines:
49@@ -218,6 +235,8 @@ def main():
50 parser.add_argument('usb_type',
51 choices=['usb2', 'usb3', 'mediacard'],
52 help=("usb2 or usb3"))
53+ parser.add_argument('--zapper-usb-address', type=str,
54+ help="Zapper's USB switch address to use")
55 args = parser.parse_args()
56 watcher = USBWatcher(args)
57 watcher.run()

Subscribers

People subscribed via source and target branches