From: Peter van Dijk Date: Sun, 31 Jan 2021 00:31:26 +0000 (+0100) Subject: test luawrapper registerFunction in make check X-Git-Tag: dnsdist-1.6.0-alpha1~3^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a51b35e10c87ae7ccc2ade74e9b0274451100db8;p=thirdparty%2Fpdns.git test luawrapper registerFunction in make check --- diff --git a/pdns/Makefile.am b/pdns/Makefile.am index d327e6fbfb..fd44d63452 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -1341,6 +1341,7 @@ testrunner_SOURCES = \ test-ixfr_cc.cc \ test-lock_hh.cc \ test-lua_auth4_cc.cc \ + test-luawrapper.cc \ test-misc_hh.cc \ test-mplexer.cc \ test-nameserver_cc.cc \ diff --git a/pdns/dnsdistdist/Makefile.am b/pdns/dnsdistdist/Makefile.am index be29ab34ee..08023ae71c 100644 --- a/pdns/dnsdistdist/Makefile.am +++ b/pdns/dnsdistdist/Makefile.am @@ -276,6 +276,7 @@ testrunner_SOURCES = \ test-dnsdistrules_cc.cc \ test-dnsparser_cc.cc \ test-iputils_hh.cc \ + test-luawrapper.cc \ test-mplexer.cc \ test-proxy_protocol_cc.cc \ testrunner.cc \ diff --git a/pdns/dnsdistdist/test-luawrapper.cc b/pdns/dnsdistdist/test-luawrapper.cc new file mode 120000 index 0000000000..ae1c2e6bd8 --- /dev/null +++ b/pdns/dnsdistdist/test-luawrapper.cc @@ -0,0 +1 @@ +../test-luawrapper.cc \ No newline at end of file diff --git a/pdns/recursordist/Makefile.am b/pdns/recursordist/Makefile.am index b4f53f1df7..37cf9256fb 100644 --- a/pdns/recursordist/Makefile.am +++ b/pdns/recursordist/Makefile.am @@ -285,6 +285,7 @@ testrunner_SOURCES = \ test-filterpo_cc.cc \ test-iputils_hh.cc \ test-ixfr_cc.cc \ + test-luawrapper.cc \ test-misc_hh.cc \ test-mplexer.cc \ test-mtasker.cc \ diff --git a/pdns/recursordist/test-luawrapper.cc b/pdns/recursordist/test-luawrapper.cc new file mode 120000 index 0000000000..ae1c2e6bd8 --- /dev/null +++ b/pdns/recursordist/test-luawrapper.cc @@ -0,0 +1 @@ +../test-luawrapper.cc \ No newline at end of file diff --git a/pdns/test-luawrapper.cc b/pdns/test-luawrapper.cc new file mode 100644 index 0000000000..44448ed82c --- /dev/null +++ b/pdns/test-luawrapper.cc @@ -0,0 +1,30 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_NO_MAIN +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include +#include "ext/luawrapper/include/LuaContext.hpp" + +BOOST_AUTO_TEST_SUITE(test_lua_lightuserdata) + +BOOST_AUTO_TEST_CASE(test_registerFunction) +{ + // this test comes from luawrapper/tests/custom_types.cc, TEST(CustomTypes, MemberFunctions) + // on luajit/arm64, as shipped by Debian Buster and others, this test crashes because lightuserdata can only hold 47 bits of address + struct Object + { + void increment() { ++value; } + int value; + }; + + LuaContext context; + context.registerFunction("increment", &Object::increment); + + context.writeVariable("obj", Object{10}); + context.executeCode("obj:increment()"); + + BOOST_CHECK_EQUAL(11, context.readVariable("obj").value); +} + +BOOST_AUTO_TEST_SUITE_END()