操作系统 = Ubuntu。
bjam 用法 = 真。
我想在 OpenMP 的帮助下优化我的单元测试系统。
bjam 脚本文件:
lib my_lib
:
[ glob sources/*.cpp ]
:
<link>static
;
...
explicit my_project ;
unit-test my_project
:
[ glob UnitTests/*.cpp ]
my_lib
:
<linkflags>-fopenmp
<cflags>-fopenmp
;
我的代码部分:
for(j = 0; j < AMOUNT; j++)
{
#pragma omp parallel for
for(i = 0; i < 0x10000; ++i)
{
...
try
{
variable1 = func1();
variable2 = func2();
//variable1 and variable 2 must be equal
CPPUNIT_ASSERT_MESSAGE("OLOLO", variable1 == variable2);
}
catch (const std::logic_error& exception)
{
std::cerr << exception.what() << std::endl;
CPPUNIT_ASSERT_MESSAGE("OLOLO", 0);
}
catch (const std::runtime_error & exception)
{
std::cerr << exception.what() << std::endl;
CPPUNIT_ASSERT_MESSAGE("OLOLO", 0);
}
}
}
当我启动我的测试系统时,它退出并出现错误:
terminate called without an active exception
Aborted
我评论 CPPUNIT_ASSERT_MESSAGE 行:
for(j = 0; j < AMOUNT; j++)
{
#pragma omp parallel for
for(i = 0; i < 0x10000; ++i)
{
...
try
{
variable1 = func1();
variable2 = func2();
//CPPUNIT_ASSERT_MESSAGE("OLOLO", variable1 == variable2);
}
catch (const std::logic_error& exception)
{
std::cerr << exception.what() << std::endl;
//CPPUNIT_ASSERT_MESSAGE("OLOLO", 0);
}
catch (const std::runtime_error & exception)
{
std::cerr << exception.what() << std::endl;
//CPPUNIT_ASSERT_MESSAGE("OLOLO", 0);
}
}
}
它以我需要的方式工作。但是我需要 CPPUNIT_ASSERT_MESSAGE 来输出信息以防出现错误结果。为什么 CPPUNIT_ASSERT_MESSAGE 会导致错误,我应该怎么做才能摆脱这些错误。