devtools: Improve *-check.py tool detection
Summary:
This is important to make sure that we're not testing tools different from the one we're building with.
Introduce determine_wellknown_cmd, which encapsulates how we should handle well-known tools specification (IFS splitting, env override, etc.).
This is a partial backport of core#22381
https://github.com/bitcoin/bitcoin/pull/22381/commits/9fdc8afe117b7b1ea845f8acae9e831922b8f92b
Test Plan: gitian builds
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D13611