I want to do unit testing in SystemC. The idea is to have multiple test suites with multiple tests in each package. Each of the tests will require a reboot of the SystemC system (for example, by calling sc_simcontext::reset()), but this is actually impossible due to some error, which, apparently, will not be fixed in the near future. So I decided to come up with a workaround.
I found out that if I run each test on a different process, everything works fine. The following code snippet gives an overview of the circuitry that I used to make it work:
void test1() {
sc_start();
}
void test2() {
sc_start();
}
typedef std::function<void()> TestFunction;
void run_test(TestFunction test_function) {
pid_t pid = fork();
switch (pid) {
case -1:
throw std::runtime_error("Error forking process");
case 0:
test_function();
exit(0);
default:
waitpid(pid, nullptr, 0);
break;
}
}
int main() {
run_test(test1);
run_test(test2);
}
Now I want to implement such a testing scheme using the Boost Unit Test.
Boost Unit Test, , unit_test_main , . Boost Unit Test .
- ?