@@ -29,35 +29,20 @@ BOOST_AUTO_TEST_CASE(dummy)
29
29
30
30
BOOST_AUTO_TEST_CASE (run_command)
31
31
{
32
- #ifdef WIN32
33
- // https://www.winehq.org/pipermail/wine-devel/2008-September/069387.html
34
- auto hntdll = GetModuleHandleA (" ntdll.dll" );
35
- assert (hntdll);
36
- const bool wine_runtime = GetProcAddress (hntdll, " wine_get_version" );
37
- #endif
38
-
39
32
{
40
33
const UniValue result = RunCommandParseJSON (" " );
41
34
BOOST_CHECK (result.isNull ());
42
35
}
43
36
{
44
- #ifdef WIN32
45
- const UniValue result = RunCommandParseJSON (" cmd.exe /c echo {\" success\" : true}" );
46
- #else
47
37
const UniValue result = RunCommandParseJSON (" echo \" {\" success\" : true}\" " );
48
- #endif
49
38
BOOST_CHECK (result.isObject ());
50
39
const UniValue& success = result.find_value (" success" );
51
40
BOOST_CHECK (!success.isNull ());
52
41
BOOST_CHECK_EQUAL (success.get_bool (), true );
53
42
}
54
43
{
55
44
// An invalid command is handled by Boost
56
- #ifdef WIN32
57
- const int expected_error{wine_runtime ? 6 : 2 };
58
- #else
59
45
const int expected_error{2 };
60
- #endif
61
46
BOOST_CHECK_EXCEPTION (RunCommandParseJSON (" invalid_command" ), boost::process::process_error, [&](const boost::process::process_error& e) {
62
47
BOOST_CHECK (std::string (e.what ()).find (" RunCommandParseJSON error:" ) == std::string::npos);
63
48
BOOST_CHECK_EQUAL (e.code ().value (), expected_error);
@@ -66,11 +51,7 @@ BOOST_AUTO_TEST_CASE(run_command)
66
51
}
67
52
{
68
53
// Return non-zero exit code, no output to stderr
69
- #ifdef WIN32
70
- const std::string command{" cmd.exe /c exit 1" };
71
- #else
72
54
const std::string command{" false" };
73
- #endif
74
55
BOOST_CHECK_EXCEPTION (RunCommandParseJSON (command), std::runtime_error, [&](const std::runtime_error& e) {
75
56
const std::string what{e.what ()};
76
57
BOOST_CHECK (what.find (strprintf (" RunCommandParseJSON error: process(%s) returned 1: \n " , command)) != std::string::npos);
@@ -79,13 +60,8 @@ BOOST_AUTO_TEST_CASE(run_command)
79
60
}
80
61
{
81
62
// Return non-zero exit code, with error message for stderr
82
- #ifdef WIN32
83
- const std::string command{" cmd.exe /c dir nosuchfile" };
84
- const std::string expected{wine_runtime ? " File not found." : " File Not Found" };
85
- #else
86
63
const std::string command{" ls nosuchfile" };
87
64
const std::string expected{" No such file or directory" };
88
- #endif
89
65
BOOST_CHECK_EXCEPTION (RunCommandParseJSON (command), std::runtime_error, [&](const std::runtime_error& e) {
90
66
const std::string what (e.what ());
91
67
BOOST_CHECK (what.find (strprintf (" RunCommandParseJSON error: process(%s) returned" , command)) != std::string::npos);
@@ -95,23 +71,17 @@ BOOST_AUTO_TEST_CASE(run_command)
95
71
}
96
72
{
97
73
// Unable to parse JSON
98
- #ifdef WIN32
99
- const std::string command{" cmd.exe /c echo {" };
100
- #else
101
74
const std::string command{" echo {" };
102
- #endif
103
75
BOOST_CHECK_EXCEPTION (RunCommandParseJSON (command), std::runtime_error, HasReason (" Unable to parse JSON: {" ));
104
76
}
105
- // Test std::in, except for Windows
106
- #ifndef WIN32
77
+ // Test std::in
107
78
{
108
79
const UniValue result = RunCommandParseJSON (" cat" , " {\" success\" : true}" );
109
80
BOOST_CHECK (result.isObject ());
110
81
const UniValue& success = result.find_value (" success" );
111
82
BOOST_CHECK (!success.isNull ());
112
83
BOOST_CHECK_EQUAL (success.get_bool (), true );
113
84
}
114
- #endif
115
85
}
116
86
#endif // ENABLE_EXTERNAL_SIGNER
117
87
0 commit comments