The test currently leads to a failure if in general wallet support is compiled, but the library for the specified type (BDB/SQLite) is not, i.e. if started with the --legacy-wallet parameter, but bitcoind is compiled without BDB support, see e.g. #23682 (comment)
Fix this by checking if the specified wallet type (BDB for legacy wallet, SQLite for descriptor wallet) is available.
Also move the helper is_specified_wallet_compiled() to the
test framework's class BitcoinTestFramework first, so it can be reused.
Should further pave the way for #23682. On my local instance without BDB compiled, all targets in test_runner pass now.