twister: ignore serial device SerialException. #44976
@PerMac I think no matter what exceptions we got from serial, we shouldn't close serial directly in the monitor serial thread, it will be closed by main thread anyway finally,
because if we closed serial in monitor serial thread when met an exception, but now only got half results of test instance A, the main thread won't wait at
I think I start following. So the issue is that we start serial connection at higher level than monitoring serial thread. Therefore serial connection should be managed on this higher level, and shouldn't be closed inside the thread. Shouldn't then instead of ignoring the serial exception, have the exception passed to the higher level and make it be handled there?
TBH I have some problems understanding the logic of the twister code responsible for serial connection. I am worried it might require some more thoughtful refactoring. E.g. I believe that serial connection should be open using context menager (
@chen-png Will you join the upcoming testing wg meeting? Maybe we could discuss the issue there?
For some boards, like up_squared and ehl_crb, they need do a power off/on operation and use bios to load and execute zephyr test binary, during the power off, it may meet this SerialException, but the serial object still works well after power on, we can continue to get all results from serial, so we don't need to close it, it's ok to ignore this exception. BTW, even if we ignore this exception here, it doesn't influence twister function, because if it was really caused by disconnection, the test would still be judged as failed due to timeout and serial would be closed later in main thread, it doesn't impact results. On the contrary, close serial directly in the monitor serial thread, it will cause later tests failed due to mismatch errors. Signed-off-by: Chen Peng1 <firstname.lastname@example.org>