]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
test luawrapper registerFunction in make check 10031/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Sun, 31 Jan 2021 00:31:26 +0000 (01:31 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Sun, 31 Jan 2021 22:11:14 +0000 (23:11 +0100)
pdns/Makefile.am
pdns/dnsdistdist/Makefile.am
pdns/dnsdistdist/test-luawrapper.cc [new symlink]
pdns/recursordist/Makefile.am
pdns/recursordist/test-luawrapper.cc [new symlink]
pdns/test-luawrapper.cc [new file with mode: 0644]

index d327e6fbfbad610bb5d53a97b8de584654bb32eb..fd44d634522dbdbce7dffb3b185419e93551bec9 100644 (file)
@@ -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 \
index be29ab34ee9138c0542291259f1419570db929e9..08023ae71c5e1903268be621f9c9d20341706562 100644 (file)
@@ -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 (symlink)
index 0000000..ae1c2e6
--- /dev/null
@@ -0,0 +1 @@
+../test-luawrapper.cc
\ No newline at end of file
index b4f53f1df7e5d1ce6ef2287090bce991a6540be1..37cf9256fb9348334442c2790a561fe3219ef577 100644 (file)
@@ -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 (symlink)
index 0000000..ae1c2e6
--- /dev/null
@@ -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 (file)
index 0000000..44448ed
--- /dev/null
@@ -0,0 +1,30 @@
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_NO_MAIN
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <boost/test/unit_test.hpp>
+#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<Object>("obj").value);
+}
+
+BOOST_AUTO_TEST_SUITE_END()