mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 12:14:32 +02:00
bugfix:fix the multi device stop thread bug
This commit is contained in:
@@ -257,6 +257,7 @@ def run_unit_test_cases(env, extra_data):
|
|||||||
raise AssertionError("Unit Test Failed")
|
raise AssertionError("Unit Test Failed")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Handler(threading.Thread):
|
class Handler(threading.Thread):
|
||||||
|
|
||||||
WAIT_SIGNAL_PATTERN = re.compile(r'Waiting for signal: \[(.+)\]!')
|
WAIT_SIGNAL_PATTERN = re.compile(r'Waiting for signal: \[(.+)\]!')
|
||||||
@@ -275,6 +276,7 @@ class Handler(threading.Thread):
|
|||||||
self.output = ""
|
self.output = ""
|
||||||
self.fail_name = None
|
self.fail_name = None
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
self.force_stop = threading.Event() # it show the running status
|
||||||
threading.Thread.__init__(self, name="{} Handler".format(dut))
|
threading.Thread.__init__(self, name="{} Handler".format(dut))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
@@ -323,12 +325,14 @@ class Handler(threading.Thread):
|
|||||||
|
|
||||||
self.dut.reset()
|
self.dut.reset()
|
||||||
self.dut.write("-", flush=False)
|
self.dut.write("-", flush=False)
|
||||||
self.dut.expect_any(UT_APP_BOOT_UP_DONE, "0 Tests 0 Failures 0 Ignored")
|
try:
|
||||||
time.sleep(1)
|
self.dut.expect_any(UT_APP_BOOT_UP_DONE, "0 Tests 0 Failures 0 Ignored")
|
||||||
self.dut.write("\"{}\"".format(self.parent_case_name))
|
time.sleep(1)
|
||||||
self.dut.expect("Running " + self.parent_case_name + "...")
|
self.dut.write("\"{}\"".format(self.parent_case_name))
|
||||||
|
self.dut.expect("Running " + self.parent_case_name + "...")
|
||||||
while not self.finish:
|
except ExpectTimeout:
|
||||||
|
Utility.console_log("No case detected!", color="orange")
|
||||||
|
while not self.finish and not self.force_stop.isSet():
|
||||||
try:
|
try:
|
||||||
self.dut.expect_any((re.compile('\(' + str(self.child_case_index) + '\)\s"(\w+)"'), get_child_case_name),
|
self.dut.expect_any((re.compile('\(' + str(self.child_case_index) + '\)\s"(\w+)"'), get_child_case_name),
|
||||||
(self.WAIT_SIGNAL_PATTERN, device_wait_action), # wait signal pattern
|
(self.WAIT_SIGNAL_PATTERN, device_wait_action), # wait signal pattern
|
||||||
@@ -340,6 +344,9 @@ class Handler(threading.Thread):
|
|||||||
one_device_case_finish(False)
|
one_device_case_finish(False)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self.force_stop.set()
|
||||||
|
|
||||||
|
|
||||||
def get_case_info(one_case):
|
def get_case_info(one_case):
|
||||||
parent_case = one_case["name"]
|
parent_case = one_case["name"]
|
||||||
@@ -364,6 +371,7 @@ def run_one_multiple_devices_case(duts, ut_config, env, one_case, failed_cases,
|
|||||||
failed_device = []
|
failed_device = []
|
||||||
result = True
|
result = True
|
||||||
parent_case, case_num = get_case_info(one_case)
|
parent_case, case_num = get_case_info(one_case)
|
||||||
|
|
||||||
for i in range(case_num):
|
for i in range(case_num):
|
||||||
dut = get_dut(duts, env, "dut%d" % i, ut_config)
|
dut = get_dut(duts, env, "dut%d" % i, ut_config)
|
||||||
threads.append(Handler(dut, send_signal_list, lock,
|
threads.append(Handler(dut, send_signal_list, lock,
|
||||||
@@ -377,7 +385,8 @@ def run_one_multiple_devices_case(duts, ut_config, env, one_case, failed_cases,
|
|||||||
result = result and thread.result
|
result = result and thread.result
|
||||||
output += thread.output
|
output += thread.output
|
||||||
if not thread.result:
|
if not thread.result:
|
||||||
failed_device.append(thread.fail_name)
|
[thd.stop() for thd in threads]
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
Utility.console_log("Success: " + one_case["name"], color="green")
|
Utility.console_log("Success: " + one_case["name"], color="green")
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user