I am working on a project in SystemC and want to incorporate unit testing. Is it possible to use existing unit test frameworks with SystemC?
I ask this because it seems
I have a second solution to this question that uses CMkae and CTest (http://cmake.org/). The setup I used creates a binary for each test. Here's the CMakeLists.txt
file I used:
project(sc_unit_test)
include_directories(/home/stephan/local/include)
find_library(systemc systemc /home/stephan/local/lib-linux64)
link_directories(/home/stephan/local/lib-linux64)
add_executable(test_1 test_1.cxx)
target_link_libraries(test_1 systemc)
add_executable(test_2 test_2.cxx)
target_link_libraries(test_2 systemc)
enable_testing()
add_test(test_1 test_1)
add_test(test_2 test_2)
Each test_*.cxx
file has a sc_main
method that executes the test and the return value indicates whether or not the test passed or failed. To run the tests simply do:
$ cmake .
$ make
$ ctest
Test project
1/ 2 Testing test_1 Passed
2/ 2 Testing test_2 Passed
100% tests passed, 0 tests failed out of 2
If you don't want to run the simulator, you can simply skip the call to sc_start
and exit the application after doing whatever specific testing you want on a particular module.