Skip to content

Commit

Permalink
feat(log_echo): include setting to enable/disable framework logging echo
Browse files Browse the repository at this point in the history
Signed-off-by: Diogo Costa <[email protected]>
  • Loading branch information
Diogo21Costa committed Oct 27, 2023
1 parent 19c59b8 commit 2ec9ba5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
11 changes: 6 additions & 5 deletions framework/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def diff_ports(ports_init, ports_end):
return diff


def connect_to_platform_port(ports_list):
def connect_to_platform_port(ports_list, log_echo):
"""
Establishes connections to multiple serial ports concurrently and starts a
listener thread for each port.
Expand All @@ -44,7 +44,7 @@ def connect_to_platform_port(ports_list):

for port in ports_list:
ser_port = open_connection(port)
new_thread = threading.Thread(target=listener, args=[ser_port])
new_thread = threading.Thread(target=listener, args=[ser_port, log_echo])
threads.append(new_thread)

for thread in threads:
Expand All @@ -56,7 +56,7 @@ def connect_to_platform_port(ports_list):
for thread in threads:
thread.join()

def listener(ser_port):
def listener(ser_port, log_echo):
"""
Listener to receive test results
"""
Expand All @@ -78,7 +78,7 @@ def listener(ser_port):
new_line = new_line.replace(old, new)
res_log.append(new_line)

if b"[INFO]" in res:
if (b"[INFO]" in res) and (log_echo):
print(new_line, end="")

if stop_event.is_set():
Expand All @@ -87,7 +87,8 @@ def listener(ser_port):
for line in res_log:
#print("line: " + line)
if "[TESTF-C]" in line:
print(line)
if log_echo:
print(line)
cons.TEST_RESULTS = line
thread_finished.set()

Expand Down
12 changes: 10 additions & 2 deletions framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import connection

test_config = {
'platform': '',
'log_echo': '',
'nix_file': '',
'suites': '',
'tests': '',
Expand Down Expand Up @@ -53,6 +55,13 @@ def parse_dts_file(file_path):
tree = Devicetree.parseFile(file_path)
test_config['platform'] = \
tree.children[0].properties[0].values[0]

try:
test_config['log_echo'] = \
tree.children[0].properties[1].values[0]
except (IndexError, AttributeError):
test_config['log_echo'] = 0

test_config['nix_file'] = \
tree.children[0].children[0].children[0].properties[0].values[0]
test_config['suites'] = \
Expand Down Expand Up @@ -112,8 +121,7 @@ def deploy_test(platform):
ports_end = connection.scan_pts_ports()

diff_ports = connection.diff_ports(ports_init, ports_end)
connection.connect_to_platform_port(diff_ports)

connection.connect_to_platform_port(diff_ports, test_config['log_echo'])
terminate_children_processes(process)

if __name__ == '__main__':
Expand Down

0 comments on commit 2ec9ba5

Please sign in to comment.