Skip to content

Commit 0f9baba

Browse files
committed
Merge bitcoin/bitcoin#29868: Reintroduce external signer support for Windows
3a18075 ci: Drop `-DENABLE_EXTERNAL_SIGNER=ON` configure option (Hennadii Stepanov) 719fa9f build: Re-enable external signer support for Windows (Hennadii Stepanov) 6e5fc2b test: Reintroduce Windows support in `system_tests/run_command` test (Hennadii Stepanov) Pull request description: This PR partially reverts: - bitcoin/bitcoin#28967 - bitcoin/bitcoin#29489 After this PR, we can proceed to actually remove the [unused code](bitcoin/bitcoin#28981 (review)) from `src/util/subprocess.h`. ACKs for top commit: Sjors: ACK 3a18075. theStack: Light ACK 3a18075 laanwj: Code review and lightly tested ACK 3a18075 Tree-SHA512: 00d200685906e716750aae7cffa0794cca451653738ea590f50dfa28e1f3c5762a9be0ae0917aa0cf7436f00fe1e565236bff2853896530a5879466f7f45cb25
2 parents cf2cbfa + 3a18075 commit 0f9baba

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ if(WITH_USDT)
130130
find_package(USDT MODULE REQUIRED)
131131
endif()
132132

133-
cmake_dependent_option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON "NOT WIN32" OFF)
133+
option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON)
134134

135135
cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF)
136136
if(WITH_QRENCODE)

ci/test/03_test_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_SCRATCH_DIR/build-$HOST}
118118
mkdir -p "${BASE_BUILD_DIR}"
119119
cd "${BASE_BUILD_DIR}"
120120

121-
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DENABLE_EXTERNAL_SIGNER=ON -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR"
121+
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR"
122122

123123
if [[ "${RUN_TIDY}" == "true" ]]; then
124124
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"

src/test/system_tests.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,32 @@ BOOST_AUTO_TEST_CASE(run_command)
2525
BOOST_CHECK(result.isNull());
2626
}
2727
{
28+
#ifdef WIN32
29+
const UniValue result = RunCommandParseJSON("cmd.exe /c echo {\"success\": true}");
30+
#else
2831
const UniValue result = RunCommandParseJSON("echo {\"success\": true}");
32+
#endif
2933
BOOST_CHECK(result.isObject());
3034
const UniValue& success = result.find_value("success");
3135
BOOST_CHECK(!success.isNull());
3236
BOOST_CHECK_EQUAL(success.get_bool(), true);
3337
}
3438
{
3539
// An invalid command is handled by cpp-subprocess
40+
#ifdef WIN32
41+
const std::string expected{"CreateProcess failed: "};
42+
#else
3643
const std::string expected{"execve failed: "};
44+
#endif
3745
BOOST_CHECK_EXCEPTION(RunCommandParseJSON("invalid_command"), subprocess::CalledProcessError, HasReason(expected));
3846
}
3947
{
4048
// Return non-zero exit code, no output to stderr
49+
#ifdef WIN32
50+
const std::string command{"cmd.exe /c exit 1"};
51+
#else
4152
const std::string command{"false"};
53+
#endif
4254
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) {
4355
const std::string what{e.what()};
4456
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)
4759
}
4860
{
4961
// Return non-zero exit code, with error message for stderr
62+
#ifdef WIN32
63+
const std::string command{"cmd.exe /c \"echo err 1>&2 && exit 1\""};
64+
#else
5065
const std::string command{"sh -c 'echo err 1>&2 && false'"};
66+
#endif
5167
const std::string expected{"err"};
5268
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) {
5369
const std::string what(e.what());
@@ -58,17 +74,23 @@ BOOST_AUTO_TEST_CASE(run_command)
5874
}
5975
{
6076
// Unable to parse JSON
77+
#ifdef WIN32
78+
const std::string command{"cmd.exe /c echo {"};
79+
#else
6180
const std::string command{"echo {"};
81+
#endif
6282
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, HasReason("Unable to parse JSON: {"));
6383
}
64-
// Test std::in
84+
#ifndef WIN32
6585
{
86+
// Test stdin
6687
const UniValue result = RunCommandParseJSON("cat", "{\"success\": true}");
6788
BOOST_CHECK(result.isObject());
6889
const UniValue& success = result.find_value("success");
6990
BOOST_CHECK(!success.isNull());
7091
BOOST_CHECK_EQUAL(success.get_bool(), true);
7192
}
93+
#endif
7294
}
7395
#endif // ENABLE_EXTERNAL_SIGNER
7496

0 commit comments

Comments
 (0)