aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-09-11 11:17:47 +0000
committerSaturneric <[email protected]>2021-09-11 11:17:47 +0000
commit514a232a03cc7f3800301d509dd199c396410cba (patch)
tree19f1c449073d27236370f77edd32184c1026bacb
parentImprove and optimize the code. (diff)
downloadGpgFrontend-514a232a03cc7f3800301d509dd199c396410cba.tar.gz
GpgFrontend-514a232a03cc7f3800301d509dd199c396410cba.zip
Add branch coverage test settings.
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt49
-rw-r--r--src/GpgFrontendBuildInfo.h54
-rw-r--r--test/CMakeLists.txt9
3 files changed, 50 insertions, 62 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e40eb148..3ffedc57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,27 @@ project(GpgFrontend VERSION 1.3.1 LANGUAGES CXX)
message(STATUS "GPGFrontend Build Configuration Started CMAKE Version ${CMAKE_VERSION}")
# C++
+# Need Gcc For Coverage Test
+set(CMAKE_C_COMPILER "/usr/bin/gcc")
+set(CMAKE_CXX_COMPILER "/usr/bin/g++")
+
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ # using Clang
+ message(STATUS "Using Complier Clang")
+ set(USING_COMPILER_CLANG 1)
+elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+ # using GCC
+ message(STATUS "Using Complier Gcc")
+ set(USING_COMPILER_GCC 1)
+elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
+ # using Intel C++
+ message(STATUS "Using Complier Intel")
+elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+ # using Visual Studio C++
+ message(STATUS "Using Complier Msvc")
+endif()
+
+# Using Standard CXX-20
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -22,11 +43,25 @@ else()
message(STATUS "Set CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
endif()
+# Specify different compilation modes
if(BUILD_CONFIG)
+ # Test Build
if(${BUILD_CONFIG} STREQUAL "test")
message(STATUS "Switch TEST_BUILD")
set(TEST_BUILD 1)
set(AppName GpgFrontendTest)
+ # Test Build With Coverage Test
+ elseif(${BUILD_CONFIG} STREQUAL "test_coverage")
+ message(STATUS "Switch TEST_COVERAGE_BUILD")
+ set(TEST_BUILD 1)
+ if(USING_COMPILER_CLANG OR USING_COMPILER_GCC)
+ set(TEST_COVERAGE_BUILD 1)
+ set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
+ else()
+ message(WARNING "Branch testing is disabled")
+ message(WARNING "Please use gcc or clang for branch coverage test.")
+ endif()
+ set(AppName GpgFrontendTest)
endif()
else()
message(STATUS "Switch Default FULL_APPLICATION_BUILD")
@@ -52,9 +87,16 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
else()
set(BUILD_FLAG 1)
message(STATUS "Build Type DEBUG")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g")
+ # Generate branch coverage information using gcc
+ if(TEST_COVERAGE_BUILD AND USING_COMPILER_GCC)
+ message(STATUS "Set branch coverage test parameters for Gcc")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
+ endif()
endif()
+message(STATUS "Build Flags " ${CMAKE_CXX_FLAGS})
+
# Get Git Information
set(GIT_COMMIT_HASH "")
@@ -193,8 +235,7 @@ add_subdirectory(third_party)
add_subdirectory(src)
if(TEST_BUILD)
+ include(CTest)
+ enable_testing()
add_subdirectory(test)
endif()
-
-
-
diff --git a/src/GpgFrontendBuildInfo.h b/src/GpgFrontendBuildInfo.h
deleted file mode 100644
index 1155a6c9..00000000
--- a/src/GpgFrontendBuildInfo.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * This file is part of GPGFrontend.
- *
- * GPGFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_BUILD_INFO_H_IN
-#define GPGFRONTEND_BUILD_INFO_H_IN
-
-/**
- * Logic Version (*.*.*)
- */
-#define VERSION_MAJOR 1
-#define VERSION_MINOR 3
-#define VERSION_PATCH 1
-
-/**
- * Code Version (According to Git)
- */
-#define GIT_BRANCH_NAME "develop-core"
-#define GIT_COMMIT_HASH "22b454912a8993a6897b21db2baf345961711cb5"
-
-/**
- * Generated Information (According to CMake)
- */
-#define PROJECT_NAME "GpgFrontend"
-#define BUILD_VERSION "1.3.1_Linux-5.4.0-81-generic_x86_64_Release"
-#define GIT_VERSION "develop-core_22b454912a8993a6897b21db2baf345961711cb5"
-
-/**
- * Build Information
- */
-#define BUILD_FLAG 0
-#define BUILD_TIMESTAMP "2021-09-10 23:57:04"
-
-#endif // GPGFRONTEND_BUILD_INFO_H_IN
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0fba7b0d..24cfc2df 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,5 +1,3 @@
-enable_testing()
-
find_package(GTest REQUIRED)
aux_source_directory(. TEST_SOURCE)
@@ -13,7 +11,10 @@ if(GPG_CORE)
target_link_libraries(${AppName} gpg_core)
endif()
-target_link_libraries(${AppName} gtest gtest_main)
+if(TEST_COVERAGE_BUILD AND USING_COMPILER_GCC)
+ target_link_libraries(${AppName} gcov)
+endif()
+target_link_libraries(${AppName} gtest gtest_main)
-add_test(AllTestsInGpgFrontend ${AppName}) \ No newline at end of file
+add_test(AllTestsInGpgFrontend ${AppName})