-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
是否支持 stub 命名空间函数? #41
Comments
stub.set(&A::B::C::func, stub_func); |
这样 stub,我单独写的 demo 代码可以的。但是在我的工程里就不行,比较奇怪。 |
你工程里的函数是不是特殊函数,例如虚函数 |
不是虚函数。就是开源代码库 ceph 的 src/cls/clock/cls_lock_client.cc 里面的 get_lock_info 函数。不知道是不是 ceph 工程的问题,使用 cpp_free_mock 也没办法 mock 这个命名空间函数。(但是其它源文件的类成员函数是可以 mock 的)。 |
nm ceph | c++filter | grep get_lock_info |
编译是没问题的。能调用到 get_lock_info,但是没进 stub_get_lock_info |
example:
namespace A {
namespace B {
namespace C {
int func(int a, std::string b)
{
xxxx;
return 0;
}
}
}
}
int stub_func(int a, std::string b)
{
return 1;
}
我试了以下几种方式都不行:
Stub stub;
stub.set(func, stub_func);
stub.set(A::B::C::func, stub_func);
stub.set(ADDR(A::B::C, func), stub_func);
The text was updated successfully, but these errors were encountered: