mirror of
https://github.com/espressif/openthread.git
synced 2026-08-09 20:27:47 +00:00
[thread-cert] print elapsed time of each test when running cert suite (#10593)
This is helpful to know the exact time that each test take when running bunch of tests in cert suite.
This commit is contained in:
@@ -31,6 +31,7 @@ import multiprocessing
|
||||
import os
|
||||
import queue
|
||||
import subprocess
|
||||
import time
|
||||
import traceback
|
||||
from collections import Counter
|
||||
from typing import List
|
||||
@@ -158,29 +159,36 @@ def run_tests(scripts: List[str], multiply: int = 1, run_directory: str = None):
|
||||
script_ids = [(script, i) for script in scripts for i in range(multiply)]
|
||||
port_offset_pool = PortOffsetPool(MAX_JOBS)
|
||||
|
||||
def error_callback(port_offset, script, err):
|
||||
def error_callback(port_offset, script, err, start_time):
|
||||
port_offset_pool.release(port_offset)
|
||||
|
||||
elapsed_time = round(time.time() - start_time)
|
||||
script_fail_count[script] += 1
|
||||
if script_succ_count[script] + script_fail_count[script] == multiply:
|
||||
color = _COLOR_PASS if script_fail_count[script] == 0 else _COLOR_FAIL
|
||||
print(f'{color}PASS {script_succ_count[script]} FAIL {script_fail_count[script]}{_COLOR_NONE} {script}')
|
||||
print(
|
||||
f'{color}PASS {script_succ_count[script]} FAIL {script_fail_count[script]}{_COLOR_NONE} {script} in {elapsed_time}s'
|
||||
)
|
||||
|
||||
def pass_callback(port_offset, script):
|
||||
def pass_callback(port_offset, script, start_time):
|
||||
port_offset_pool.release(port_offset)
|
||||
|
||||
elapsed_time = round(time.time() - start_time)
|
||||
script_succ_count[script] += 1
|
||||
if script_succ_count[script] + script_fail_count[script] == multiply:
|
||||
color = _COLOR_PASS if script_fail_count[script] == 0 else _COLOR_FAIL
|
||||
print(f'{color}PASS {script_succ_count[script]} FAIL {script_fail_count[script]}{_COLOR_NONE} {script}')
|
||||
print(
|
||||
f'{color}PASS {script_succ_count[script]} FAIL {script_fail_count[script]}{_COLOR_NONE} {script} in {elapsed_time}s'
|
||||
)
|
||||
|
||||
for script, i in script_ids:
|
||||
port_offset = port_offset_pool.allocate()
|
||||
pool.apply_async(
|
||||
run_cert, [i, port_offset, script, run_directory],
|
||||
callback=lambda ret, port_offset=port_offset, script=script: pass_callback(port_offset, script),
|
||||
error_callback=lambda err, port_offset=port_offset, script=script: error_callback(
|
||||
port_offset, script, err))
|
||||
start_time = time.time()
|
||||
pool.apply_async(run_cert, [i, port_offset, script, run_directory],
|
||||
callback=lambda ret, port_offset=port_offset, script=script, start_time=start_time:
|
||||
pass_callback(port_offset, script, start_time),
|
||||
error_callback=lambda err, port_offset=port_offset, script=script, start_time=start_time:
|
||||
error_callback(port_offset, script, err, start_time))
|
||||
|
||||
pool.close()
|
||||
pool.join()
|
||||
|
||||
Reference in New Issue
Block a user