Skip to content

Commit 3622f3a

Browse files
Fix and re-enable Linux tv CI test for commissioner-generated-passcode flow
1 parent e2ffa2d commit 3622f3a

File tree

3 files changed

+36
-21
lines changed

3 files changed

+36
-21
lines changed

.github/workflows/examples-linux-tv-casting-app.yaml

+7-10
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,13 @@ jobs:
7272
"python3 ./scripts/tests/run_tv_casting_test.py"
7373
timeout-minutes: 2 # Comment this out to debug if GitHub Action times out.
7474

75-
# TODO: this test is flaky and was disabled
76-
# https://github.com/project-chip/connectedhomeip/issues/34598
77-
#
78-
# - name:
79-
# Test casting from Linux tv-casting-app to Linux tv-app -
80-
# Commissioner Generated Passcode
81-
# run: |
82-
# ./scripts/run_in_build_env.sh \
83-
# "python3 ./scripts/tests/run_tv_casting_test.py --commissioner-generated-passcode=True"
84-
# timeout-minutes: 2 # Comment this out to debug if GitHub Action times out.
75+
- name:
76+
Test casting from Linux tv-casting-app to Linux tv-app -
77+
Commissioner Generated Passcode
78+
run: |
79+
./scripts/run_in_build_env.sh \
80+
"python3 ./scripts/tests/run_tv_casting_test.py --commissioner-generated-passcode=True"
81+
timeout-minutes: 2 # Comment this out to debug if GitHub Action times out.
8582

8683
- name: Uploading Size Reports
8784
uses: ./.github/actions/upload-size-reports

scripts/tests/linux/log_line_processing.py

+23-7
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,30 @@ def _io_thread(self):
6363
err_wait = select.poll()
6464
err_wait.register(self.process.stderr, select.POLLIN | select.POLLHUP)
6565

66-
with open(self.output_path, "wt") as f:
66+
with open(self.output_path, "wt", buffering=1) as f:
6767
f.write("PROCESS START: %s\n" % time.ctime())
68+
f.flush()
6869
while not self.done:
6970
changes = out_wait.poll(0.1)
7071
if changes:
7172
out_line = self.process.stdout.readline()
72-
if not out_line:
73+
if not out_line or out_line == "\n":
7374
# stdout closed (otherwise readline should have at least \n)
7475
continue
7576
f.write(out_line)
77+
f.flush()
7678
self.output_lines.put(out_line)
7779

7880
changes = err_wait.poll(0)
7981
if changes:
8082
err_line = self.process.stderr.readline()
81-
if not err_line:
83+
if not err_line or err_line == "\n":
8284
# stderr closed (otherwise readline should have at least \n)
8385
continue
8486
f.write(f"!!STDERR!! : {err_line}")
87+
f.flush()
8588
f.write("PROCESS END: %s\n" % time.ctime())
89+
f.flush()
8690

8791
def __enter__(self):
8892
self.done = False
@@ -92,6 +96,7 @@ def __enter__(self):
9296
stdout=subprocess.PIPE,
9397
stderr=subprocess.PIPE,
9498
text=True,
99+
bufsize=1,
95100
)
96101
self.io_thread = threading.Thread(target=self._io_thread)
97102
self.io_thread.start()
@@ -116,10 +121,21 @@ def __exit__(self, exception_type, exception_value, traceback):
116121

117122
def next_output_line(self, timeout_sec=None):
118123
"""Fetch an item from the output queue, potentially with a timeout."""
119-
try:
120-
return self.output_lines.get(timeout=timeout_sec)
121-
except queue.Empty:
122-
return None
124+
end_time = time.time() + (timeout_sec if timeout_sec is not None else 0)
125+
sleep_duration = 0.1
126+
while True:
127+
remaining_time = end_time - time.time()
128+
if remaining_time <= 0:
129+
return None
130+
131+
if not self.output_lines.empty():
132+
return self.output_lines.get_nowait()
133+
else:
134+
out_line = self.process.stdout.readline()
135+
if out_line:
136+
self.output_lines.put(out_line)
137+
time.sleep(sleep_duration)
138+
sleep_duration = min(10.0, sleep_duration * 2)
123139

124140
def send_to_program(self, input_cmd):
125141
"""Sends the given input command string to the program.

scripts/tests/run_tv_casting_test.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,28 @@ def stop_app(test_sequence_name: str, app_name: str, app: ProcessOutputCapture):
8787

8888
if app.process.poll() is None:
8989
raise TestStepException(
90-
f"{test_sequence_name}: Failed to stop running {app_name}. Process is still running.",
90+
f"{test_sequence_name} - Failed to stop running {app_name}. Process is still running.",
9191
test_sequence_name,
9292
None,
9393
)
9494

9595
if app_exit_code >= 0:
9696
raise TestStepException(
97-
f"{test_sequence_name}: {app_name} exited with unexpected exit code {app_exit_code}.",
97+
f"{test_sequence_name} - {app_name} exited with unexpected exit code {app_exit_code}.",
9898
test_sequence_name,
9999
None,
100100
)
101101

102102
signal_number = -app_exit_code
103103
if signal_number != signal.SIGTERM.value:
104104
raise TestStepException(
105-
f"{test_sequence_name}: {app_name} stopped by signal {signal_number} instead of {signal.SIGTERM.value} (SIGTERM).",
105+
f"{test_sequence_name} - {app_name} stopped by signal {signal_number} instead of {signal.SIGTERM.value} (SIGTERM).",
106106
test_sequence_name,
107107
None,
108108
)
109109

110110
logging.info(
111-
f"{test_sequence_name}: {app_name} stopped by {signal_number} (SIGTERM) signal."
111+
f"{test_sequence_name} - {app_name} stopped by {signal_number} (SIGTERM) signal."
112112
)
113113

114114

@@ -205,6 +205,8 @@ def send_input_cmd_to_subprocess(
205205
f"{test_sequence_name} - Sent `{input_cmd}` to the {app_name} subprocess."
206206
)
207207

208+
time.sleep(0.5)
209+
208210

209211
def handle_input_cmd(
210212
processes: RunningProcesses, test_sequence_name: str, test_sequence_step: Step

0 commit comments

Comments
 (0)