forked from aldebaran/libqi-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_qipython.cpp
More file actions
46 lines (35 loc) · 1.02 KB
/
test_qipython.cpp
File metadata and controls
46 lines (35 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <gtest/gtest.h>
#include <qi/anyobject.hpp>
#include <qi/application.hpp>
#include <qi/session.hpp>
#include <qi/jsoncodec.hpp>
#include <ka/errorhandling.hpp>
#include <ka/functional.hpp>
#include <qipython/common.hpp>
#include <qipython/pyguard.hpp>
#include <qipython/pyexport.hpp>
#include <pybind11/pybind11.h>
#include <pybind11/embed.h>
qiLogCategory("TestQiPython");
namespace py = pybind11;
PYBIND11_EMBEDDED_MODULE(qi, m) {
qi::py::exportAll(m);
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
pybind11::scoped_interpreter interp;
boost::optional<qi::Application> app;
app.emplace(argc, argv);
py::globals()["qi"] = py::module::import("qi");
int ret = EXIT_FAILURE;
{
qi::py::GILRelease unlock;
ret = RUN_ALL_TESTS();
// Destroy the application outside of the GIL to avoid deadlocks, but while
// the interpreter still runs to avoid crashes while trying to release the
// references we still hold in callbacks.
app.reset();
}
return ret;
}