Closed aap-sc closed 1 year ago
Oh, and by the way. I think the reason I can reproduce it reliably is that we always run these tests with "-d3" passed to OpenOCD. So the amount of debug logs is increased. This may be the reason why people could have difficulties with reproducing this.
FWIW, even with -d3
this doesn't reproduce for me locally.
The patch with the suggested fixes: https://github.com/riscv-software-src/riscv-tests/pull/522
Looks like the patch fixes this issue, so closing the ticket
@timsifive , @en-sc , @AnastasiyaChernikova FYI.
The effects of the issue can be observed in https://github.com/riscv/riscv-openocd/pull/928 (though this commit has nothing to do with the issue, the root cause seems to be in the test suite itself).
Basically, If I take current riscv-openocd TOT most Unavailable... tests begin to fail in my environment. I've debugged the issue for a while now and I think I understand the root cause.
The problem is with
def command(self, cmd)
function fromdebug/testlib.py
. What this function does is it tries to obtain results of OpenOCD command by parsing OpenOCD log instead of fetching the result directly (more on that later). Moreover, instead of sending only one command - we actually send 2 "commands". One real command and another is an artificial "command-like" comment to enforce OpenOCD to print prompt-like construct. The issue is that this approach does not always work.Here are some examples (taken from log files after the failure).
Example 1
Prompt for
# 7x
never matched.Example 2
Another, more hilarious example is the following:
Here the prompt is matched. But the output is not parsed correctly, leading to the following error:
This happens because targets state is parsed like this:
Note: these are but a few examples. The number of situations resulting in test failure is quite large. Though it all comes down to incorrect parsing of the result.
TLDR
Proposed solution:
Instead of parsing OpenOCD log files (and connecting to a pipe for an input) I suggest to communicate with OpenOCD via TCL-rpc server. TCL-RPC server is almost the same that ordinary telnet server, but it is more suitable for machine-machine interaction (we have a special watermark to indicate message end). We don't need to parse OpenOCD logs to get instruction results - we can fetch the result string directly.
P.S: I'll try to propose a patch to address the issue. This may take some time, though. So if anyone has an urgent desire to fix this - don't be shy ).