[tests] Better stderr testing
Summary:
This PR tightens our checking of stderr and will cause tests to fail if there is any unexpected message in stderr: - commit Write stdout/stderr to datadir instead of temp file writes stderr to a file in the datadir instead of a temporary file. This helps with debugging in the case of failure. - commit Use LIBC_FATAL_STDERR=1 in tests ensures that libc failures are logged to stderr instead of the terminal.
Backport of core PR12755
https://github.com/bitcoin/bitcoin/pull/12755/files
Test Plan:
./test/functional/test_runner.py --extended
Reviewers: #bitcoin_abc, deadalnix, jasonbcox
Reviewed By: #bitcoin_abc, jasonbcox
Maniphest Tasks: T540
Differential Revision: https://reviews.bitcoinabc.org/D3274