test_that: Write HostInfo in results directory

BUG=chromium:1026422
TEST=test_that --pretend ...

Change-Id: I129ec643c64fad7dfe5cc7a2474288fb0b2f6388
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1986944
Tested-by: Prathmesh Prabhu <[email protected]>
Reviewed-by: Katherine Threlkeld <[email protected]>
Reviewed-by: Alex Zamorzaev <[email protected]>
Commit-Queue: Prathmesh Prabhu <[email protected]>
diff --git a/server/autoserv_utils.py b/server/autoserv_utils.py
index 3889233..869144c 100644
--- a/server/autoserv_utils.py
+++ b/server/autoserv_utils.py
@@ -25,7 +25,8 @@
                              use_packaging=True,
                              in_lab=False,
                              host_attributes=None,
-                             use_virtualenv=False):
+                             use_virtualenv=False,
+                             host_info_subdir=''):
     """
     Construct an autoserv command from a job or host queue entry.
 
@@ -63,6 +64,8 @@
                            lab, and probably False in most other use cases
                            (moblab, local testing) until we rollout virtualenv
                            support everywhere. Default: False.
+    @param host_info_subdir: When set, a sub-directory of the results directory
+                             where host info file(s) are stored.
 
     @returns The autoserv command line as a list of executable + parameters.
 
@@ -75,6 +78,9 @@
 
     if results_directory:
         command += ['-r', results_directory]
+    if host_info_subdir:
+        command += ['--local-only-host-info']
+        command += ['--host-info-subdir', host_info_subdir]
 
     if machines:
         command += ['-m', machines]