diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b88987caf1..ed5b657a89b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,7 @@ if(WITH_USDT) find_package(USDT MODULE REQUIRED) endif() -cmake_dependent_option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON "NOT WIN32" OFF) +option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON) cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF) if(WITH_QRENCODE) diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh index a71565ba98e..3394c50b8bd 100755 --- a/ci/test/03_test_script.sh +++ b/ci/test/03_test_script.sh @@ -118,7 +118,7 @@ BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_SCRATCH_DIR/build-$HOST} mkdir -p "${BASE_BUILD_DIR}" cd "${BASE_BUILD_DIR}" -BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DENABLE_EXTERNAL_SIGNER=ON -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR" +BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR" if [[ "${RUN_TIDY}" == "true" ]]; then BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp index a5d9be07d52..dec4d418290 100644 --- a/src/test/system_tests.cpp +++ b/src/test/system_tests.cpp @@ -25,7 +25,11 @@ BOOST_AUTO_TEST_CASE(run_command) BOOST_CHECK(result.isNull()); } { +#ifdef WIN32 + const UniValue result = RunCommandParseJSON("cmd.exe /c echo {\"success\": true}"); +#else const UniValue result = RunCommandParseJSON("echo {\"success\": true}"); +#endif BOOST_CHECK(result.isObject()); const UniValue& success = result.find_value("success"); BOOST_CHECK(!success.isNull()); @@ -33,12 +37,20 @@ BOOST_AUTO_TEST_CASE(run_command) } { // An invalid command is handled by cpp-subprocess +#ifdef WIN32 + const std::string expected{"CreateProcess failed: "}; +#else const std::string expected{"execve failed: "}; +#endif BOOST_CHECK_EXCEPTION(RunCommandParseJSON("invalid_command"), subprocess::CalledProcessError, HasReason(expected)); } { // Return non-zero exit code, no output to stderr +#ifdef WIN32 + const std::string command{"cmd.exe /c exit 1"}; +#else const std::string command{"false"}; +#endif BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) { const std::string what{e.what()}; BOOST_CHECK(what.find(strprintf("RunCommandParseJSON error: process(%s) returned 1: \n", command)) != std::string::npos); @@ -47,7 +59,11 @@ BOOST_AUTO_TEST_CASE(run_command) } { // Return non-zero exit code, with error message for stderr +#ifdef WIN32 + const std::string command{"cmd.exe /c \"echo err 1>&2 && exit 1\""}; +#else const std::string command{"sh -c 'echo err 1>&2 && false'"}; +#endif const std::string expected{"err"}; BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) { const std::string what(e.what()); @@ -58,17 +74,23 @@ BOOST_AUTO_TEST_CASE(run_command) } { // Unable to parse JSON +#ifdef WIN32 + const std::string command{"cmd.exe /c echo {"}; +#else const std::string command{"echo {"}; +#endif BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, HasReason("Unable to parse JSON: {")); } - // Test std::in +#ifndef WIN32 { + // Test stdin const UniValue result = RunCommandParseJSON("cat", "{\"success\": true}"); BOOST_CHECK(result.isObject()); const UniValue& success = result.find_value("success"); BOOST_CHECK(!success.isNull()); BOOST_CHECK_EQUAL(success.get_bool(), true); } +#endif } #endif // ENABLE_EXTERNAL_SIGNER