parent
efd39fd208
commit
772fc95d56
@ -1,24 +1,15 @@
|
|||||||
cmake_minimum_required (VERSION 2.6)
|
add_definitions(-Wall -Werror -pedantic -Weffc++ -Wshadow -ggdb -fprofile-arcs -ftest-coverage)
|
||||||
project (CPP_UTILS_TEST)
|
|
||||||
|
|
||||||
message(STATUS "Test dir:")
|
|
||||||
|
|
||||||
set (CXX_FLAGS "-Wall -Wextra -pedantic")
|
|
||||||
add_definitions( ${CXX_FLAGS} )
|
|
||||||
message(STATUS "g++ flags: ${CXX_FLAGS}")
|
|
||||||
|
|
||||||
include_directories(../include)
|
include_directories(../include)
|
||||||
message(STATUS "include dir: ${CPP_UTILS_LIB}/include")
|
#add_library (CppUtils src/*)
|
||||||
|
|
||||||
add_executable (testThreadPool main_threadpool.cpp)
|
|
||||||
target_link_libraries (testThreadPool CppUtils)
|
|
||||||
|
|
||||||
|
|
||||||
find_package(CxxTest)
|
find_package(CxxTest)
|
||||||
if(CXXTEST_FOUND)
|
if(CXXTEST_FOUND)
|
||||||
set(CXXTEST_USE_PERL TRUE)
|
set(CXXTEST_USE_PERL TRUE)
|
||||||
include_directories(${CXXTEST_INCLUDE_DIR})
|
include_directories(${CXXTEST_INCLUDE_DIR} ../include)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
# CXXTEST_ADD_TEST(unittest_sos check_sos.cpp ${SOS_TEST_PATH}/check_sos.h)
|
CXXTEST_ADD_TEST(unittest_multiple generated_main.cpp unittest_multiple.hpp )
|
||||||
# target_link_libraries(unittest_sos CppUtils)
|
target_link_libraries(unittest_multiple CppUtils gcov)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Usage: ./run_test.sh <TEST_BINARY>
|
||||||
|
|
||||||
|
pre="\E[00;32m"
|
||||||
|
post="\E[00;00m"
|
||||||
|
|
||||||
|
echo -e "${pre}Reset coverage files${post}"
|
||||||
|
lcov --directory . -z
|
||||||
|
rm -f ./lcov.info
|
||||||
|
|
||||||
|
echo -e "${pre}Run tests${post}"
|
||||||
|
$1
|
||||||
|
|
||||||
|
echo -e "${pre}Capture coverage info${post}"
|
||||||
|
lcov --directory . --capture -o lcov.info
|
||||||
|
|
||||||
|
echo -e "${pre}Filtering coverage tracefile${post}"
|
||||||
|
lcov -r lcov.info "g++-v*" -o lcov.info
|
||||||
|
lcov -r lcov.info "/usr/include/cxxtest*" -o lcov.info
|
||||||
|
lcov -r lcov.info "$(PWD)/test/*" -o lcov.info
|
||||||
|
|
||||||
|
echo -e "${pre}Generating HTML${post}"
|
||||||
|
rm -rf ./cov
|
||||||
|
mkdir cov
|
||||||
|
genhtml -o ./cov lcov.info
|
@ -0,0 +1,16 @@
|
|||||||
|
#include <cxxtest/TestSuite.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MyTestSuite : public CxxTest::TestSuite
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void testAddition()
|
||||||
|
{
|
||||||
|
TS_ASSERT_EQUALS( 1 + 1, 2 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
Loading…
Reference in new issue