diff options
Diffstat (limited to 'src/test/alert_tests.cpp')
-rw-r--r-- | src/test/alert_tests.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index 4af87cf8ef..614960fa6d 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -7,12 +7,13 @@ // #include "alert.h" +#include "clientversion.h" #include "data/alertTests.raw.h" #include "serialize.h" +#include "streams.h" #include "util.h" #include "utilstrencodings.h" -#include "version.h" #include <fstream> @@ -91,7 +92,7 @@ struct ReadAlerts alerts.push_back(alert); } } - catch (std::exception) { } + catch (const std::exception&) { } } ~ReadAlerts() { } @@ -153,9 +154,6 @@ BOOST_AUTO_TEST_CASE(AlertApplies) } -// This uses sh 'echo' to test the -alertnotify function, writing to a -// /tmp file. So skip it on Windows: -#ifndef WIN32 BOOST_AUTO_TEST_CASE(AlertNotify) { SetMockTime(11); @@ -170,15 +168,24 @@ BOOST_AUTO_TEST_CASE(AlertNotify) std::vector<std::string> r = read_lines(temp); BOOST_CHECK_EQUAL(r.size(), 4u); + +// Windows built-in echo semantics are different than posixy shells. Quotes and +// whitespace are printed literally. + +#ifndef WIN32 BOOST_CHECK_EQUAL(r[0], "Alert 1"); BOOST_CHECK_EQUAL(r[1], "Alert 2, cancels 1"); BOOST_CHECK_EQUAL(r[2], "Alert 2, cancels 1"); BOOST_CHECK_EQUAL(r[3], "Evil Alert; /bin/ls; echo "); // single-quotes should be removed - +#else + BOOST_CHECK_EQUAL(r[0], "'Alert 1' "); + BOOST_CHECK_EQUAL(r[1], "'Alert 2, cancels 1' "); + BOOST_CHECK_EQUAL(r[2], "'Alert 2, cancels 1' "); + BOOST_CHECK_EQUAL(r[3], "'Evil Alert; /bin/ls; echo ' "); +#endif boost::filesystem::remove(temp); SetMockTime(0); } -#endif BOOST_AUTO_TEST_SUITE_END() |