I am trying to create python controlled implementation for C/C++ interface (headers).
For example I have C/C++ library:
// header
int foo(bool var);
// cpp
int foo(bool var) {
// impl
}
This is compiled to mylib.so
And I would like to create mymockedlib.so that would transfer foo
call with parameters to the python code. So that in python code I could write some kind of test like this:
MyLibMoc mock
mock.expect_call("foo").with_args(var=true).return(100);
Didn't find any similar solution. Started implemented my own based on protobuf and grpc server (on python side).
C++ binary -> (mocked C++ lib implements original header) -> GRPC -> python backed.
But C++ is extremely variadic language. There are templated functions, both input and output parameters, callbacks, pointers - huge amount of work to support controlling of all all this C++ staff by python, but it is definitely possible.
Anyone could suggest me existing project with something similar (may be not python controlled but other language good for creating automated tests) .
Or at least other path then generating protobuf types for each C++ method call, callback, parameters, structs and enums.
My goal is to check that C++ binary do appropriate calls in shared libraries and redefine behavior of shared library for certain test cases.