GTest on SystemC
- Install the gtest and systemc libraries.
# ubuntu 22.04
sudo apt install libgtest-dev libsystemc-dev
- Include this repo in your cmake file.
include(FetchContent)
FetchContent_Declare(
SCGTest
GIT_REPOSITORY https://github.com/zzz00yx/SCGTest.git
GIT_TAG main
)
FetchContent_MakeAvailable(SCGTest)
target_link_libraries(<YOUR-TARGET>
SCGTest
)
- Use a GTest test-fixture to define your SystemC modules and other components, and instance or bind them in
SetUp
function.
#include "scgtest.h"
class MyTest : public testing::Test {
public:
Module module{"module"};
sc_clock clk{"clk", 1, SC_NS};
void SetUp() override { module.sci_clk(clk); }
};
- Using
SCGTEST_F
macros to construct your testcases.SCGTEST_F
are completely consistent with the well-knownTEST_F
in GTest from the perspective of the user but works in SystemC context.
SCGTEST_F(MyTest, TestName) {
// ... test body ...
}