Jump to content
katang

Unit testing with gtest

Recommended Posts

with reference to

http://stackoverflow.com/questions/4923292/using-existing-unit-test-frameworks-with-systemc

the

Error: (E546) sc_start called after sc_stop has been called

seems to be logical. Can it have side effects, should (can) it be suppressed, or can the system be re-initialized, or is a better way for unit testing?

A related question: in a testing environment it would be advantageous for me, to use some SystemC-handled functions as normal C++ function (I mean to make some unit tests). I guess BEFORE calling sc_start, I can do so. Am I right, or they may have side effects? Is it safe to make unit tests together with SystemC-style testing, or which are the limitations?

Share this post


Link to post
Share on other sites

Once sc_stop() has been called, you are not allowed to call sc_start() anymore (cf. to clause 4.5.3 in IEEE Std 1666-2011). For each unit test involving a sc_start() and sc_stop() sequence, you will have to start an own process to ensure that the SystemC kernel is properly initialized. Testing frameworks, which link together individual unit test into one big executable containing the test runner are to my knowledge not suitable for unit testing SystemC applications. The reason is that the simulation kernel of the SystemC PoC simulator can currently not be restarted due to some implementation constraints. However, you can use script-based test runner approaches, e.g., provided by CMake/CTest.

Once you link to libsystemc, you will also have to provide a sc_main() function. Most SystemC functions will only properly work in the context of sc_main(), especially if they manipulate to design hierarchy (anything related to sc_object or control elaboration/simulation), You can check the SystemC regression test suite for examples on how to do unit testing in the SystemC context.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×