Merge "Allow adjust rolling output window height through env var" into main am: 5b205969d9 am: 35c3245dfd

Original change: https://android-review.googlesource.com/c/platform/tools/asuite/+/3394786

Change-Id: I88d3823e9ae777c44b082ae2f28e74030656537e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/atest/test_runners/atest_tf_test_runner.py b/atest/test_runners/atest_tf_test_runner.py
index 2482c9c..ea010c9 100644
--- a/atest/test_runners/atest_tf_test_runner.py
+++ b/atest/test_runners/atest_tf_test_runner.py
@@ -59,6 +59,9 @@
 SOCKET_BUFFER = 4096
 SELECT_TIMEOUT = 0.5
 
+# Env key for rolling subprocess output window height.
+_ROLLING_OUTPUT_WINDOW_HEIGHT_ENV_KEY = 'ATEST_ROLLING_OUTPUT_WINDOW_HEIGHT'
+
 # Socket Events of form FIRST_EVENT {JSON_DATA}\nSECOND_EVENT {JSON_DATA}
 # EVENT_RE has groups for the name and the data. "." does not match \n.
 EVENT_RE = re.compile(
@@ -416,9 +419,20 @@
     )
 
     if is_rolling_output:
+      height = os.environ.get(_ROLLING_OUTPUT_WINDOW_HEIGHT_ENV_KEY, None)
+      if height:
+        try:
+          height = int(height)
+        except ValueError:
+          atest_utils.print_and_log_warning(
+              'Invalid rolling output window height: %s', height
+          )
       threading.Thread(
           target=atest_utils.stream_io_output,
-          args=(subproc.stdout, atest_utils.DEFAULT_OUTPUT_ROLLING_LINES),
+          args=(
+              subproc.stdout,
+              height if height else atest_utils.DEFAULT_OUTPUT_ROLLING_LINES,
+          ),
       ).start()
 
     self.handle_subprocess(