Merge branch 'googletest_merge2' into 'master'
Include googletest and subproject for unit tests. See merge request ems/astdm/dram.sys!240
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -5,3 +5,6 @@
|
||||
path = DRAMSys/library/src/common/third_party/DRAMPower
|
||||
url = https://github.com/tukl-msd/DRAMPower.git
|
||||
branch = master
|
||||
[submodule "DRAMSys/unitTests/googletest"]
|
||||
path = DRAMSys/unitTests/googletest
|
||||
url = https://github.com/google/googletest.git
|
||||
|
||||
@@ -25,10 +25,12 @@ isEmpty(systemc_home) {
|
||||
message(SystemC home is $${systemc_home})
|
||||
|
||||
SUBDIRS += library
|
||||
SUBDIRS += unitTests
|
||||
SUBDIRS += simulator
|
||||
SUBDIRS += traceAnalyzer
|
||||
|
||||
library.subdir = library
|
||||
unitTests.subdir = unitTests
|
||||
simulator.subdir = simulator
|
||||
traceAnalyzer.subdir = traceAnalyzer
|
||||
|
||||
|
||||
7
DRAMSys/unitTests/Testfile.h
Normal file
7
DRAMSys/unitTests/Testfile.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "../library/src/controller/Command.h"
|
||||
|
||||
TEST(testsuite, test)
|
||||
{
|
||||
EXPECT_EQ(commandToString(Command::Activate), "ACT");
|
||||
}
|
||||
23
DRAMSys/unitTests/googleTest.pri
Normal file
23
DRAMSys/unitTests/googleTest.pri
Normal file
@@ -0,0 +1,23 @@
|
||||
GOOGLETEST_DIR = googletest
|
||||
|
||||
!isEmpty(GOOGLETEST_DIR): {
|
||||
GTEST_SRCDIR = $$GOOGLETEST_DIR/googletest
|
||||
GMOCK_SRCDIR = $$GOOGLETEST_DIR/googlemock
|
||||
}
|
||||
|
||||
requires(exists($$GTEST_SRCDIR):exists($$GMOCK_SRCDIR))
|
||||
|
||||
!exists($$GOOGLETEST_DIR):message("No googletest src dir found - set GOOGLETEST_DIR to enable.")
|
||||
|
||||
DEFINES += \
|
||||
GTEST_LANG_CXX11
|
||||
|
||||
INCLUDEPATH *= \
|
||||
$$GTEST_SRCDIR \
|
||||
$$GTEST_SRCDIR/include \
|
||||
$$GMOCK_SRCDIR \
|
||||
$$GMOCK_SRCDIR/include
|
||||
|
||||
SOURCES += \
|
||||
$$GTEST_SRCDIR/src/gtest-all.cc \
|
||||
$$GMOCK_SRCDIR/src/gmock-all.cc
|
||||
1
DRAMSys/unitTests/googletest
Submodule
1
DRAMSys/unitTests/googletest
Submodule
Submodule DRAMSys/unitTests/googletest added at b77e5c7625
9
DRAMSys/unitTests/main.cpp
Normal file
9
DRAMSys/unitTests/main.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <systemc.h>
|
||||
#include "Testfile.h"
|
||||
|
||||
int sc_main(int argc, char **argv)
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
77
DRAMSys/unitTests/unitTests.pro
Normal file
77
DRAMSys/unitTests/unitTests.pro
Normal file
@@ -0,0 +1,77 @@
|
||||
TARGET = unitTestsDRAMSys
|
||||
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
CONFIG -= qt
|
||||
|
||||
systemc_home = $$(SYSTEMC_HOME)
|
||||
isEmpty(systemc_home) {
|
||||
systemc_home = /opt/systemc
|
||||
}
|
||||
message(SystemC home is $${systemc_home})
|
||||
|
||||
systemc_target_arch = $$(SYSTEMC_TARGET_ARCH)
|
||||
isEmpty(systemc_target_arch) {
|
||||
systemc_target_arch = linux64
|
||||
}
|
||||
|
||||
message(SystemC target architecture is $${systemc_target_arch})
|
||||
|
||||
dramsys_disable_coverage_check = $$(DRAMSYS_DISABLE_COVERAGE_CHECK)
|
||||
isEmpty(dramsys_disable_coverage_check) {
|
||||
coverage_check = true
|
||||
message(Coverage check ENABLED)
|
||||
} else {
|
||||
coverage_check = false
|
||||
message(Coverage check DISABLED)
|
||||
}
|
||||
|
||||
unix:!macx {
|
||||
message(Building on a GNU/Linux)
|
||||
QMAKE_RPATHDIR += $${systemc_home}/lib-$${systemc_target_arch}
|
||||
message(Linker options QMAKE_RPATHDIR is $${QMAKE_RPATHDIR})
|
||||
}
|
||||
|
||||
DEFINES += TIXML_USE_STL
|
||||
DEFINES += SC_INCLUDE_DYNAMIC_PROCESSES
|
||||
|
||||
unix:!macx {
|
||||
QMAKE_CXXFLAGS += -std=c++11 -O0 -g
|
||||
$$eval(coverage_check) {
|
||||
QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage -fPIC -O0
|
||||
QMAKE_LFLAGS += -lgcov --coverage
|
||||
}
|
||||
}
|
||||
|
||||
macx: {
|
||||
CONFIG += c++11
|
||||
QMAKE_CXXFLAGS += -std=c++0x -stdlib=libc++ -O0 -g
|
||||
$$eval(coverage_check) {
|
||||
QMAKE_CXXFLAGS += --coverage
|
||||
QMAKE_LFLAGS += --coverage
|
||||
}
|
||||
}
|
||||
|
||||
QMAKE_CXXFLAGS += -pthread
|
||||
|
||||
INCLUDEPATH += ../library/src/simulation/
|
||||
INCLUDEPATH += $${systemc_home}/include
|
||||
|
||||
LIBS += -L$${systemc_home}/lib-$${systemc_target_arch} -lsystemc -lpthread
|
||||
|
||||
SOURCEHOME = ../library/src/
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
$${SOURCEHOME}/controller/Command.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
Testfile.h \
|
||||
$${SOURCEHOME}/controller/Command.h
|
||||
|
||||
DISTFILES += ../DRAMSys.astylerc
|
||||
|
||||
include(googleTest.pri)
|
||||
DISTFILES += googleTest.pri
|
||||
Reference in New Issue
Block a user