[autotest] Add serial flag for adb_host support in cli/atest.
User should be able to specify serials to pass to adb_host and
the board label will be autodetected and the serial will be
added as a host attribute. Currently only works only for 1
serial, a later cl will enable multiple serials.
Also refactored the label decorator logic into site_utils
and remote.RemoteHost.
BUG=chromium:535352
TEST=manually added hosts using the serial flag using cli/atest
and checking the host was correctly detected on a moblab.
Change-Id: I4c95377eaee4529ea99add4387be6dcf56a529fb
Reviewed-on: https://chromium-review.googlesource.com/303214
Commit-Ready: Kevin Cheng <kevcheng@chromium.org>
Tested-by: Kevin Cheng <kevcheng@chromium.org>
Reviewed-by: Kevin Cheng <kevcheng@chromium.org>
diff --git a/server/site_utils.py b/server/site_utils.py
index a0df249..a4ca13c 100644
--- a/server/site_utils.py
+++ b/server/site_utils.py
@@ -600,3 +600,28 @@
except ParseBuildNameException:
pass
return info
+
+
+def add_label_detector(label_function_list, label_list=None, label=None):
+ """Decorator used to group functions together into the provided list.
+
+ This is a helper function to automatically add label functions that have
+ the label decorator. This is to help populate the class list of label
+ functions to be retrieved by the get_labels class method.
+
+ @param label_function_list: List of label detecting functions to add
+ decorated function to.
+ @param label_list: List of detectable labels to add detectable labels to.
+ (Default: None)
+ @param label: Label string that is detectable by this detection function
+ (Default: None)
+ """
+ def add_func(func):
+ """
+ @param func: The function to be added as a detector.
+ """
+ label_function_list.append(func)
+ if label and label_list is not None:
+ label_list.append(label)
+ return func
+ return add_func