I have a component I am testing:
namespace myproj {
class MyComp {
public:
void doSome();
};
}
using namespace myproj;
void MyComp::doSome() {
// Some code...
// And in the end, for debugging purposes, I print in one of the streams
EV_DEBUG << "Some debugging info" << endl;
}
My test is an ordinary OmNET++ Unit Test using the opp_test
tool:
%description:
Tests my component
%includes:
#include "myproj/MyComp.h"
%global:
using namespace ::inet::test::myproj;
%activity:
MyCompTest test = MyCompTest();
test.testDoSome();
EV << ".\n";
%contains: stdout
my test out
Of course a class MyCompTest
is using MyComp
in order to run some logic which will eventually invoke MyComp::doSome
.
Note that testDoSome
will cause the string "my test out" to be printed.
The issue is that, because of that EV_DEBUG
(same happens if I change it into EV_INFO
, EV_DETAIL
and all other EV
s) in my original class (source/simulation code), the test output is poisoned and the final output is:
Some debugging info
my test out
Which makes the test fail. If I comment out EV_DEBUG << ...
then the test is fine.
How to solve this problem? Do I really have to remove all EV
printouts in my original code?
You can turn off printing by EV_DEBUG
by adding these lines in %activity
section:
#undef EV_DEBUG
#define EV_DEBUG true ? EV : EV
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.