Skip to content

Commit

Permalink
Better debuggability and error reporting support for shell - this is …
Browse files Browse the repository at this point in the history
…to debug cast failures
  • Loading branch information
andreilitvin committed Jul 24, 2024
1 parent 262d08f commit 6019d0e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 5 additions & 2 deletions scripts/tests/linux/log_line_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import select
import subprocess
import threading
import time
from typing import List


Expand Down Expand Up @@ -57,12 +58,13 @@ def _io_thread(self):
reading
"""
out_wait = select.poll()
out_wait.register(self.process.stdout, select.POLLIN)
out_wait.register(self.process.stdout, select.POLLIN | select.POLLHUP)

err_wait = select.poll()
err_wait.register(self.process.stderr, select.POLLIN)
err_wait.register(self.process.stderr, select.POLLIN | select.POLLHUP)

with open(self.output_path, "wt") as f:
f.write("PROCESS START: %s\n" % time.ctime())
while not self.done:
changes = out_wait.poll(0.1)
if changes:
Expand All @@ -80,6 +82,7 @@ def _io_thread(self):
# stderr closed (otherwise readline should have at least \n)
continue
f.write(f"!!STDERR!! : {err_line}")
f.write("PROCESS END: %s\n" % time.ctime())

def __enter__(self):
self.done = False
Expand Down
8 changes: 1 addition & 7 deletions src/lib/shell/MainLoopDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,7 @@ void ProcessShellLine(intptr_t args)

if (retval != CHIP_NO_ERROR)
{
char errorStr[160];
bool errorStrFound = FormatCHIPError(errorStr, sizeof(errorStr), retval);
if (!errorStrFound)
{
errorStr[0] = 0;
}
streamer_printf(streamer_get(), "Error %s: %s\r\n", argv[0], errorStr);
streamer_printf(streamer_get(), "Error %s: %" CHIP_ERROR_FORMAT "\r\n", argv[0], retval.Format());
}
else
{
Expand Down

0 comments on commit 6019d0e

Please sign in to comment.