我一直在纠结于这件事,到目前为止还没能成功。一个简单的使用僵尸的主程序很好,但是当我把相同的代码放在一个单元测试中时,它就失败了。
// keygeneration_test.cpp
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp> // shuold use this one if using dynamic linking
#include <botan\botan.h>
#include <botan\rsa.h>
BOOST_AUTO_TEST_SUITE(keygeneration_suite)
BOOST_AUTO_TEST_CASE(rsa_key_generation)
{
BOOST_TEST_MESSAGE("generating key");
try
{
Botan::LibraryInitializer init;
Botan::AutoSeeded_RNG rng;
rng.reseed(10096);
Botan::RSA_PrivateKey rsaPrivate(rng, 1024);
}
catch (std::exception& e)
{
BOOST_TEST_MESSAGE(e.what());
}
}
BOOST_AUTO_TEST_SUITE_END()--
// main.cpp
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE cryptography test //module define should be only here, it takes care of creating entry point
#include <boost/test/unit_test.hpp> // should use this one if using dynamic linking然后,我尝试将init放在主要入口点上,如下所示:
//main.cpp
#define BOOST_TEST_DYN_LINK // Make the exe link dynamically
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp> // should use this one if using dynamic linking
#include <botan\botan.h>
bool init_function()
{
return true;
}
int main(int argc, char* argv[])
{
Botan::LibraryInitializer init;
return boost::unit_test::unit_test_main(&init_function, argc, argv);
}它们都显示出相同的错误:
运行一个测试用例..。未知位置(0):“rsa_key_generation”中的致命错误:当试图读取不可访问的数据时,地址0x00141000处发生内存访问冲突 *1在测试套件“密码测试”中检测到内存泄漏!转储对象-> {670}普通块为0x0000000000221380,16字节长。资料来源: 78 EA 13 00 00 00对象转储完成。
为了记录在案,我尝试过的一个简单的压缩测试或我所做的任何事情都很好,但是当我尝试用僵尸初始化创建一个测试时,不管我尝试什么,它都会失败。
编辑:我尝试过Qt,但同样发生了。真的很奇怪。有人经历过这样的事情吗?有人能复制这个吗?
发布于 2015-03-31 11:51:43
发现了恼人的问题。代码生成被设置为多线程调试DLL.由于某些原因,更改为多线程DLL使其工作。我猜可能是因为僵尸是为发行而编译的。(最好能从编译器那里得到提示或建议.)
https://stackoverflow.com/questions/29359878
复制相似问题