# HG changeset patch # User David Demelier # Date 1464281529 -7200 # Node ID 254bbc0f13b5314d2c9a4f3ee7220c274edc92e6 # Parent b8616981cc096aaab1e8a695f5059d58552e9975 Misc: dos2unix some files diff -r b8616981cc09 -r 254bbc0f13b5 extern/jansson/snprintf.patch --- a/extern/jansson/snprintf.patch Thu May 26 12:27:51 2016 +0200 +++ b/extern/jansson/snprintf.patch Thu May 26 18:52:09 2016 +0200 @@ -1,53 +1,53 @@ -diff --git a/cmake/jansson_private_config.h.cmake b/cmake/jansson_private_config.h.cmake -index ee1078f..ac7318f 100644 ---- a/cmake/jansson_private_config.h.cmake -+++ b/cmake/jansson_private_config.h.cmake -@@ -49,6 +49,20 @@ - - #cmakedefine HAVE_SNPRINTF 1 - -+/* snprintf should not be defined as macro with MSC_VER >= 1900 */ -+#if defined(_WIN32) || defined(WIN32) -+# if defined(_MSC_VER) /* MS compiller */ -+# if (_MSC_VER < 1900) /* snprintf not introduced */ -+# if !defined(snprintf) -+# define snprintf _snprintf -+# define HAVE_SNPRINTF 1 /* snprintf defined manually */ -+# endif -+# else -+# define HAVE_SNPRINTF 1 /* snprintf available via sdk */ -+# endif -+# endif -+#endif -+ - #ifndef HAVE_SNPRINTF - # define snprintf @JSON_SNPRINTF@ - #endif -diff --git a/src/jansson_private.h b/src/jansson_private.h -index e100726..ccb3a57 100644 ---- a/src/jansson_private.h -+++ b/src/jansson_private.h -@@ -90,10 +90,20 @@ char *jsonp_strndup(const char *str, size_t length); - char *jsonp_strdup(const char *str); - char *jsonp_strndup(const char *str, size_t len); - -+ - /* Windows compatibility */ --#ifdef _WIN32 --#define snprintf _snprintf --#define vsnprintf _vsnprintf -+#if defined(_WIN32) || defined(WIN32) -+# if defined(_MSC_VER) /* MS compiller */ -+# if (_MSC_VER < 1900) && !defined(snprintf) /* snprintf not defined yet & not introduced */ -+# define snprintf _snprintf -+# endif -+# if (_MSC_VER < 1500) && !defined(vsnprintf) /* vsnprintf not defined yet & not introduced */ -+# define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a) -+# endif -+# else /* Other Windows compiller, old definition */ -+# define snprintf _snprintf -+# define vsnprintf _vsnprintf -+# endif - #endif - - #endif +diff --git a/cmake/jansson_private_config.h.cmake b/cmake/jansson_private_config.h.cmake +index ee1078f..ac7318f 100644 +--- a/cmake/jansson_private_config.h.cmake ++++ b/cmake/jansson_private_config.h.cmake +@@ -49,6 +49,20 @@ + + #cmakedefine HAVE_SNPRINTF 1 + ++/* snprintf should not be defined as macro with MSC_VER >= 1900 */ ++#if defined(_WIN32) || defined(WIN32) ++# if defined(_MSC_VER) /* MS compiller */ ++# if (_MSC_VER < 1900) /* snprintf not introduced */ ++# if !defined(snprintf) ++# define snprintf _snprintf ++# define HAVE_SNPRINTF 1 /* snprintf defined manually */ ++# endif ++# else ++# define HAVE_SNPRINTF 1 /* snprintf available via sdk */ ++# endif ++# endif ++#endif ++ + #ifndef HAVE_SNPRINTF + # define snprintf @JSON_SNPRINTF@ + #endif +diff --git a/src/jansson_private.h b/src/jansson_private.h +index e100726..ccb3a57 100644 +--- a/src/jansson_private.h ++++ b/src/jansson_private.h +@@ -90,10 +90,20 @@ char *jsonp_strndup(const char *str, size_t length); + char *jsonp_strdup(const char *str); + char *jsonp_strndup(const char *str, size_t len); + ++ + /* Windows compatibility */ +-#ifdef _WIN32 +-#define snprintf _snprintf +-#define vsnprintf _vsnprintf ++#if defined(_WIN32) || defined(WIN32) ++# if defined(_MSC_VER) /* MS compiller */ ++# if (_MSC_VER < 1900) && !defined(snprintf) /* snprintf not defined yet & not introduced */ ++# define snprintf _snprintf ++# endif ++# if (_MSC_VER < 1500) && !defined(vsnprintf) /* vsnprintf not defined yet & not introduced */ ++# define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a) ++# endif ++# else /* Other Windows compiller, old definition */ ++# define snprintf _snprintf ++# define vsnprintf _vsnprintf ++# endif + #endif + + #endif diff -r b8616981cc09 -r 254bbc0f13b5 tests/plugin-ask/CMakeLists.txt --- a/tests/plugin-ask/CMakeLists.txt Thu May 26 12:27:51 2016 +0200 +++ b/tests/plugin-ask/CMakeLists.txt Thu May 26 18:52:09 2016 +0200 @@ -1,24 +1,24 @@ -# -# CMakeLists.txt -- CMake build system for irccd -# -# Copyright (c) 2013-2016 David Demelier -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -irccd_define_test( - NAME plugin-ask - SOURCES main.cpp answers.conf - LIBRARIES libirccd - FLAGS PLUGINDIR=\"${IRCCD_FAKEROOTDIR}/${WITH_PLUGINDIR}\" -) +# +# CMakeLists.txt -- CMake build system for irccd +# +# Copyright (c) 2013-2016 David Demelier +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +irccd_define_test( + NAME plugin-ask + SOURCES main.cpp answers.conf + LIBRARIES libirccd + FLAGS PLUGINDIR=\"${IRCCD_FAKEROOTDIR}/${WITH_PLUGINDIR}\" +) diff -r b8616981cc09 -r 254bbc0f13b5 tests/plugin-ask/answers.conf --- a/tests/plugin-ask/answers.conf Thu May 26 12:27:51 2016 +0200 +++ b/tests/plugin-ask/answers.conf Thu May 26 18:52:09 2016 +0200 @@ -1,2 +1,2 @@ -NO +NO YES \ No newline at end of file diff -r b8616981cc09 -r 254bbc0f13b5 tests/plugin-ask/main.cpp --- a/tests/plugin-ask/main.cpp Thu May 26 12:27:51 2016 +0200 +++ b/tests/plugin-ask/main.cpp Thu May 26 18:52:09 2016 +0200 @@ -1,92 +1,92 @@ -/* - * main.cpp -- test ask plugin - * - * Copyright (c) 2013-2016 David Demelier - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -#include -#include -#include - -using namespace irccd; - -class ServerTest : public Server { -private: - std::string m_last; - -public: - inline ServerTest() - : Server("test", ServerInfo()) - { - } - - inline const std::string &last() const noexcept - { - return m_last; - } - - void message(std::string target, std::string message) override - { - m_last = util::join({target, message}); - } -}; - -class AskTest : public testing::Test { -protected: - Irccd m_irccd; - PluginService &m_ps; - - std::shared_ptr m_server; - std::shared_ptr m_plugin; - -public: - AskTest() - : m_ps(m_irccd.pluginService()) - , m_server(std::make_shared()) - { - m_ps.configure("ask", {{"file", SOURCEDIR "/answers.conf"}}); - m_ps.load("ask", PLUGINDIR "/ask.js"); - m_plugin = m_ps.require("ask"); - } -}; - -TEST_F(AskTest, basic) -{ - bool no = false; - bool yes = false; - - // Invoke the plugin 1000 times, it will be very unlucky to not have both answers in that amount of tries. - for (int i = 0; i < 1000; ++i) { - m_plugin->onCommand(m_irccd, m_server, "tester", "#dummy", ""); - - if (m_server->last() == "#dummy:tester, YES") - yes = true; - if (m_server->last() == "#dummy:tester, NO") - no = true; - } - - ASSERT_TRUE(no); - ASSERT_TRUE(yes); -} - -int main(int argc, char **argv) -{ - path::setApplicationPath(argv[0]); - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} +/* + * main.cpp -- test ask plugin + * + * Copyright (c) 2013-2016 David Demelier + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include +#include +#include + +using namespace irccd; + +class ServerTest : public Server { +private: + std::string m_last; + +public: + inline ServerTest() + : Server("test", ServerInfo()) + { + } + + inline const std::string &last() const noexcept + { + return m_last; + } + + void message(std::string target, std::string message) override + { + m_last = util::join({target, message}); + } +}; + +class AskTest : public testing::Test { +protected: + Irccd m_irccd; + PluginService &m_ps; + + std::shared_ptr m_server; + std::shared_ptr m_plugin; + +public: + AskTest() + : m_ps(m_irccd.pluginService()) + , m_server(std::make_shared()) + { + m_ps.configure("ask", {{"file", SOURCEDIR "/answers.conf"}}); + m_ps.load("ask", PLUGINDIR "/ask.js"); + m_plugin = m_ps.require("ask"); + } +}; + +TEST_F(AskTest, basic) +{ + bool no = false; + bool yes = false; + + // Invoke the plugin 1000 times, it will be very unlucky to not have both answers in that amount of tries. + for (int i = 0; i < 1000; ++i) { + m_plugin->onCommand(m_irccd, m_server, "tester", "#dummy", ""); + + if (m_server->last() == "#dummy:tester, YES") + yes = true; + if (m_server->last() == "#dummy:tester, NO") + no = true; + } + + ASSERT_TRUE(no); + ASSERT_TRUE(yes); +} + +int main(int argc, char **argv) +{ + path::setApplicationPath(argv[0]); + testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} diff -r b8616981cc09 -r 254bbc0f13b5 tests/plugin-auth/CMakeLists.txt --- a/tests/plugin-auth/CMakeLists.txt Thu May 26 12:27:51 2016 +0200 +++ b/tests/plugin-auth/CMakeLists.txt Thu May 26 18:52:09 2016 +0200 @@ -1,24 +1,24 @@ -# -# CMakeLists.txt -- CMake build system for irccd -# -# Copyright (c) 2013-2016 David Demelier -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -irccd_define_test( - NAME plugin-auth - SOURCES main.cpp - LIBRARIES libirccd - FLAGS PLUGINDIR=\"${IRCCD_FAKEROOTDIR}/${WITH_PLUGINDIR}\" -) +# +# CMakeLists.txt -- CMake build system for irccd +# +# Copyright (c) 2013-2016 David Demelier +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +irccd_define_test( + NAME plugin-auth + SOURCES main.cpp + LIBRARIES libirccd + FLAGS PLUGINDIR=\"${IRCCD_FAKEROOTDIR}/${WITH_PLUGINDIR}\" +) diff -r b8616981cc09 -r 254bbc0f13b5 tests/plugin-auth/main.cpp --- a/tests/plugin-auth/main.cpp Thu May 26 12:27:51 2016 +0200 +++ b/tests/plugin-auth/main.cpp Thu May 26 18:52:09 2016 +0200 @@ -1,107 +1,107 @@ -/* - * main.cpp -- test auth plugin - * - * Copyright (c) 2013-2016 David Demelier - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -#include -#include -#include - -using namespace irccd; - -class ServerTest : public Server { -private: - std::string m_last; - -public: - inline ServerTest(std::string name) - : Server(std::move(name), ServerInfo()) - { - } - - inline const std::string &last() const noexcept - { - return m_last; - } - - void message(std::string target, std::string message) override - { - m_last = util::join({target, message}); - } -}; - -class AuthTest : public testing::Test { -protected: - Irccd m_irccd; - PluginService &m_ps; - - std::shared_ptr m_nickserv1; - std::shared_ptr m_nickserv2; - std::shared_ptr m_quakenet; - std::shared_ptr m_plugin; - -public: - AuthTest() - : m_ps(m_irccd.pluginService()) - , m_nickserv1(std::make_shared("nickserv1")) - , m_nickserv2(std::make_shared("nickserv2")) - , m_quakenet(std::make_shared("quakenet")) - { - m_ps.configure("auth", { - { "nickserv1.type", "nickserv" }, - { "nickserv1.password", "plopation" }, - { "nickserv2.type", "nickserv" }, - { "nickserv2.password", "something" }, - { "nickserv2.username", "jean" }, - { "quakenet.type", "quakenet" }, - { "quakenet.password", "hello" }, - { "quakenet.username", "mario" } - }); - m_ps.load("auth", PLUGINDIR "/auth.js"); - m_plugin = m_ps.require("auth"); - } -}; - -TEST_F(AuthTest, nickserv1) -{ - m_plugin->onConnect(m_irccd, m_nickserv1); - - ASSERT_EQ("NickServ:identify plopation", m_nickserv1->last()); -} - -TEST_F(AuthTest, nickserv2) -{ - m_plugin->onConnect(m_irccd, m_nickserv2); - - ASSERT_EQ("NickServ:identify jean something", m_nickserv2->last()); -} - -TEST_F(AuthTest, quakenet) -{ - m_plugin->onConnect(m_irccd, m_quakenet); - - ASSERT_EQ("Q@CServe.quakenet.org:AUTH mario hello", m_quakenet->last()); -} - -int main(int argc, char **argv) -{ - path::setApplicationPath(argv[0]); - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} +/* + * main.cpp -- test auth plugin + * + * Copyright (c) 2013-2016 David Demelier + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include +#include +#include + +using namespace irccd; + +class ServerTest : public Server { +private: + std::string m_last; + +public: + inline ServerTest(std::string name) + : Server(std::move(name), ServerInfo()) + { + } + + inline const std::string &last() const noexcept + { + return m_last; + } + + void message(std::string target, std::string message) override + { + m_last = util::join({target, message}); + } +}; + +class AuthTest : public testing::Test { +protected: + Irccd m_irccd; + PluginService &m_ps; + + std::shared_ptr m_nickserv1; + std::shared_ptr m_nickserv2; + std::shared_ptr m_quakenet; + std::shared_ptr m_plugin; + +public: + AuthTest() + : m_ps(m_irccd.pluginService()) + , m_nickserv1(std::make_shared("nickserv1")) + , m_nickserv2(std::make_shared("nickserv2")) + , m_quakenet(std::make_shared("quakenet")) + { + m_ps.configure("auth", { + { "nickserv1.type", "nickserv" }, + { "nickserv1.password", "plopation" }, + { "nickserv2.type", "nickserv" }, + { "nickserv2.password", "something" }, + { "nickserv2.username", "jean" }, + { "quakenet.type", "quakenet" }, + { "quakenet.password", "hello" }, + { "quakenet.username", "mario" } + }); + m_ps.load("auth", PLUGINDIR "/auth.js"); + m_plugin = m_ps.require("auth"); + } +}; + +TEST_F(AuthTest, nickserv1) +{ + m_plugin->onConnect(m_irccd, m_nickserv1); + + ASSERT_EQ("NickServ:identify plopation", m_nickserv1->last()); +} + +TEST_F(AuthTest, nickserv2) +{ + m_plugin->onConnect(m_irccd, m_nickserv2); + + ASSERT_EQ("NickServ:identify jean something", m_nickserv2->last()); +} + +TEST_F(AuthTest, quakenet) +{ + m_plugin->onConnect(m_irccd, m_quakenet); + + ASSERT_EQ("Q@CServe.quakenet.org:AUTH mario hello", m_quakenet->last()); +} + +int main(int argc, char **argv) +{ + path::setApplicationPath(argv[0]); + testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +}