Add CI autotest and Fix compile warning
This commit is contained in:
253
.gitlab-ci.yml
Normal file
253
.gitlab-ci.yml
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
variables:
|
||||||
|
GIT_STRATEGY: "clone"
|
||||||
|
BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
|
||||||
|
INSTALL_PREFIX: "/opt/tsg/stellar"
|
||||||
|
TESTING_VERSION_BUILD: 0
|
||||||
|
BUILD_IMAGE_CENTOS7: "git.mesalab.cn:7443/mesa_platform/build-env:master"
|
||||||
|
BUILD_IMAGE_CENTOS8: "git.mesalab.cn:7443/mesa_platform/build-env:rockylinux"
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- envelope
|
||||||
|
- upload
|
||||||
|
|
||||||
|
.build_before_script:
|
||||||
|
before_script:
|
||||||
|
- mkdir -p $BUILD_PADDING_PREFIX/$CI_PROJECT_NAMESPACE/
|
||||||
|
- ln -s $CI_PROJECT_DIR $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
|
||||||
|
- cd $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
|
||||||
|
- chmod +x ./ci/travis.sh
|
||||||
|
- yum makecache
|
||||||
|
- yum install -y elfutils-libelf-devel
|
||||||
|
|
||||||
|
.build_by_travis_for_centos7:
|
||||||
|
stage: build
|
||||||
|
image: $BUILD_IMAGE_CENTOS7
|
||||||
|
extends: .build_before_script
|
||||||
|
script:
|
||||||
|
- ./ci/travis.sh
|
||||||
|
tags:
|
||||||
|
- share
|
||||||
|
|
||||||
|
.build_by_travis_for_centos8:
|
||||||
|
stage: build
|
||||||
|
image: $BUILD_IMAGE_CENTOS8
|
||||||
|
extends: .build_before_script
|
||||||
|
script:
|
||||||
|
- ./ci/travis.sh
|
||||||
|
tags:
|
||||||
|
- share
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# compile use image: build-env:master
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
branch_build_debug_for_centos7:
|
||||||
|
extends: .build_by_travis_for_centos7
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: Debug
|
||||||
|
except:
|
||||||
|
- /^develop-.*$/i
|
||||||
|
- /^release-.*$/i
|
||||||
|
- tags
|
||||||
|
|
||||||
|
branch_build_release_for_centos7:
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: RelWithDebInfo
|
||||||
|
extends: .build_by_travis_for_centos7
|
||||||
|
except:
|
||||||
|
- /^develop-.*$/i
|
||||||
|
- /^release-.*$/i
|
||||||
|
- tags
|
||||||
|
|
||||||
|
develop_build_debug_for_centos7:
|
||||||
|
extends: .build_by_travis_for_centos7
|
||||||
|
variables:
|
||||||
|
TESTING_VERSION_BUILD: 1
|
||||||
|
UPLOAD_SYMBOL_FILES: 1
|
||||||
|
BUILD_TYPE: Debug
|
||||||
|
# ASAN_OPTION: ADDRESS
|
||||||
|
PACKAGE: 1
|
||||||
|
PULP3_REPO_NAME: stellar-testing-x86_64.el7
|
||||||
|
PULP3_DIST_NAME: stellar-testing-x86_64.el7
|
||||||
|
artifacts:
|
||||||
|
name: "stellar-develop-$CI_COMMIT_REF_NAME-debug"
|
||||||
|
paths:
|
||||||
|
- build/*.rpm
|
||||||
|
only:
|
||||||
|
- /^develop-.*$/i
|
||||||
|
- /^release-.*$/i
|
||||||
|
|
||||||
|
develop_build_release_for_centos7:
|
||||||
|
extends: .build_by_travis_for_centos7
|
||||||
|
variables:
|
||||||
|
TESTING_VERSION_BUILD: 1
|
||||||
|
UPLOAD_SYMBOL_FILES: 1
|
||||||
|
# ASAN_OPTION: ADDRESS
|
||||||
|
BUILD_TYPE: RelWithDebInfo
|
||||||
|
PACKAGE: 1
|
||||||
|
PULP3_REPO_NAME: stellar-testing-x86_64.el7
|
||||||
|
PULP3_DIST_NAME: stellar-testing-x86_64.el7
|
||||||
|
artifacts:
|
||||||
|
name: "stellar-develop-$CI_COMMIT_REF_NAME-release"
|
||||||
|
paths:
|
||||||
|
- build/*.rpm
|
||||||
|
only:
|
||||||
|
- /^develop-.*$/i
|
||||||
|
- /^release-.*$/i
|
||||||
|
|
||||||
|
release_build_debug_for_centos7:
|
||||||
|
variables:
|
||||||
|
UPLOAD_SYMBOL_FILES: 1
|
||||||
|
BUILD_TYPE: Debug
|
||||||
|
PACKAGE: 1
|
||||||
|
PULP3_REPO_NAME: stellar-stable-x86_64.el7
|
||||||
|
PULP3_DIST_NAME: stellar-stable-x86_64.el7
|
||||||
|
extends: .build_by_travis_for_centos7
|
||||||
|
artifacts:
|
||||||
|
name: "stellar-install-$CI_COMMIT_REF_NAME-debug"
|
||||||
|
paths:
|
||||||
|
- build/*.rpm
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
|
||||||
|
release_build_release_for_centos7:
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: RelWithDebInfo
|
||||||
|
UPLOAD_SYMBOL_FILES: 1
|
||||||
|
PACKAGE: 1
|
||||||
|
PULP3_REPO_NAME: stellar-stable-x86_64.el7
|
||||||
|
PULP3_DIST_NAME: stellar-stable-x86_64.el7
|
||||||
|
extends: .build_by_travis_for_centos7
|
||||||
|
artifacts:
|
||||||
|
name: "stellar-install-$CI_COMMIT_REF_NAME-release"
|
||||||
|
paths:
|
||||||
|
- build/*.rpm
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# compile use image: build-env:rockylinux
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
branch_build_debug_for_centos8:
|
||||||
|
extends: .build_by_travis_for_centos8
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: Debug
|
||||||
|
except:
|
||||||
|
- /^develop-.*$/i
|
||||||
|
- /^release-.*$/i
|
||||||
|
- tags
|
||||||
|
|
||||||
|
branch_build_release_for_centos8:
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: RelWithDebInfo
|
||||||
|
extends: .build_by_travis_for_centos8
|
||||||
|
except:
|
||||||
|
- /^develop-.*$/i
|
||||||
|
- /^release-.*$/i
|
||||||
|
- tags
|
||||||
|
|
||||||
|
develop_build_debug_for_centos8:
|
||||||
|
extends: .build_by_travis_for_centos8
|
||||||
|
variables:
|
||||||
|
TESTING_VERSION_BUILD: 1
|
||||||
|
UPLOAD_SYMBOL_FILES: 1
|
||||||
|
BUILD_TYPE: Debug
|
||||||
|
# ASAN_OPTION: ADDRESS
|
||||||
|
PACKAGE: 1
|
||||||
|
PULP3_REPO_NAME: stellar-testing-x86_64.el8
|
||||||
|
PULP3_DIST_NAME: stellar-testing-x86_64.el8
|
||||||
|
artifacts:
|
||||||
|
name: "stellar-develop-$CI_COMMIT_REF_NAME-debug"
|
||||||
|
paths:
|
||||||
|
- build/*.rpm
|
||||||
|
only:
|
||||||
|
- /^develop-.*$/i
|
||||||
|
- /^release-.*$/i
|
||||||
|
|
||||||
|
develop_build_release_for_centos8:
|
||||||
|
extends: .build_by_travis_for_centos8
|
||||||
|
variables:
|
||||||
|
TESTING_VERSION_BUILD: 1
|
||||||
|
UPLOAD_SYMBOL_FILES: 1
|
||||||
|
# ASAN_OPTION: ADDRESS
|
||||||
|
BUILD_TYPE: RelWithDebInfo
|
||||||
|
PACKAGE: 1
|
||||||
|
PULP3_REPO_NAME: stellar-testing-x86_64.el8
|
||||||
|
PULP3_DIST_NAME: stellar-testing-x86_64.el8
|
||||||
|
artifacts:
|
||||||
|
name: "stellar-develop-$CI_COMMIT_REF_NAME-release"
|
||||||
|
paths:
|
||||||
|
- build/*.rpm
|
||||||
|
only:
|
||||||
|
- /^develop-.*$/i
|
||||||
|
- /^release-.*$/i
|
||||||
|
|
||||||
|
release_build_debug_for_centos8:
|
||||||
|
variables:
|
||||||
|
UPLOAD_SYMBOL_FILES: 1
|
||||||
|
BUILD_TYPE: Debug
|
||||||
|
PACKAGE: 1
|
||||||
|
PULP3_REPO_NAME: stellar-stable-x86_64.el8
|
||||||
|
PULP3_DIST_NAME: stellar-stable-x86_64.el8
|
||||||
|
extends: .build_by_travis_for_centos8
|
||||||
|
artifacts:
|
||||||
|
name: "stellar-install-$CI_COMMIT_REF_NAME-debug"
|
||||||
|
paths:
|
||||||
|
- build/*.rpm
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
|
||||||
|
release_build_release_for_centos8:
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: RelWithDebInfo
|
||||||
|
UPLOAD_SYMBOL_FILES: 1
|
||||||
|
PACKAGE: 1
|
||||||
|
PULP3_REPO_NAME: stellar-stable-x86_64.el8
|
||||||
|
PULP3_DIST_NAME: stellar-stable-x86_64.el8
|
||||||
|
extends: .build_by_travis_for_centos8
|
||||||
|
artifacts:
|
||||||
|
name: "stellar-install-$CI_COMMIT_REF_NAME-release"
|
||||||
|
paths:
|
||||||
|
- build/*.rpm
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# envelope and upload
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
envelope_rpm:
|
||||||
|
stage: envelope
|
||||||
|
image: $BUILD_IMAGE_CENTOS7
|
||||||
|
variables:
|
||||||
|
FEATURE_ID: 100
|
||||||
|
APP_NAME_IN_RPM_SPEC: stellar
|
||||||
|
script:
|
||||||
|
- chmod +x ./ci/envelope_rpm.sh
|
||||||
|
- ./ci/envelope_rpm.sh
|
||||||
|
artifacts:
|
||||||
|
name: "stellar-pr-$CI_COMMIT_REF_NAME-release"
|
||||||
|
paths:
|
||||||
|
- build/*-pr-*.rpm
|
||||||
|
tags:
|
||||||
|
- envelope
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
|
||||||
|
upload_enveloped_rpm:
|
||||||
|
stage: upload
|
||||||
|
image: $BUILD_IMAGE_CENTOS7
|
||||||
|
variables:
|
||||||
|
PULP3_REPO_NAME_EL7: stellar-stable-x86_64.el7
|
||||||
|
PULP3_DIST_NAME_EL7: stellar-stable-x86_64.el7
|
||||||
|
PULP3_REPO_NAME_EL8: stellar-stable-x86_64.el8
|
||||||
|
PULP3_DIST_NAME_EL8: stellar-stable-x86_64.el8
|
||||||
|
script:
|
||||||
|
- chmod +x ./ci/upload_enveloped_rpm.sh
|
||||||
|
- ./ci/upload_enveloped_rpm.sh
|
||||||
|
tags:
|
||||||
|
- share
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
@@ -1,21 +1,35 @@
|
|||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
project(stellar)
|
project(stellar)
|
||||||
|
|
||||||
# GoogleTest requires at least C++11
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
|
|
||||||
#find required package
|
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
include(Version)
|
include(Version)
|
||||||
find_package(PkgConfig REQUIRED)
|
include(Package)
|
||||||
find_package(Threads REQUIRED)
|
|
||||||
find_package(PCAP REQUIRED)
|
|
||||||
pkg_check_modules(SYSTEMD REQUIRED systemd)
|
|
||||||
|
|
||||||
|
add_definitions(-D_GNU_SOURCE)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE RelWithDebInfo)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||||
|
set (CMAKE_INSTALL_PREFIX "/opt/tsg/stellar" CACHE PATH "default install path" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(ENABLE_PIC "Generate position independent code (necessary for shared libraries)" TRUE)
|
||||||
|
option(ENABLE_WARNING_ALL "Enable all optional warnings which are desirable for normal code" TRUE)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lelf")
|
||||||
|
|
||||||
|
add_custom_target("install-program" COMMAND ${CMAKE_COMMAND} ARGS -DCOMPONENT=Program -P cmake_install.cmake)
|
||||||
|
add_custom_target("install-profile" COMMAND ${CMAKE_COMMAND} ARGS -DCOMPONENT=Profile -P cmake_install.cmake)
|
||||||
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/sdk/include)
|
include_directories(${CMAKE_SOURCE_DIR}/sdk/include)
|
||||||
|
|
||||||
#add vendor and source directory
|
add_subdirectory(conf)
|
||||||
add_subdirectory(vendor)
|
add_subdirectory(vendor)
|
||||||
add_subdirectory(deps/toml)
|
add_subdirectory(deps/toml)
|
||||||
add_subdirectory(deps/sds)
|
add_subdirectory(deps/sds)
|
||||||
@@ -23,11 +37,5 @@ add_subdirectory(deps/timeout)
|
|||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(sdk/example)
|
add_subdirectory(sdk/example)
|
||||||
|
|
||||||
|
|
||||||
#add gtest
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -359,8 +359,7 @@ svnRepo() {
|
|||||||
/*trunk* | /*branches* | /*tags*)
|
/*trunk* | /*branches* | /*tags*)
|
||||||
local lastbase=""
|
local lastbase=""
|
||||||
local fn="${PWD}"
|
local fn="${PWD}"
|
||||||
while :
|
while :; do
|
||||||
do
|
|
||||||
base="$(basename "${fn}")"
|
base="$(basename "${fn}")"
|
||||||
if [ "${base}" = 'trunk' ]; then
|
if [ "${base}" = 'trunk' ]; then
|
||||||
VCS_BRANCH='trunk'
|
VCS_BRANCH='trunk'
|
||||||
@@ -394,7 +393,6 @@ svnRepo() {
|
|||||||
cd "${oldPath}"
|
cd "${oldPath}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Functions to output data in different formats.
|
# Functions to output data in different formats.
|
||||||
# For bash output
|
# For bash output
|
||||||
shOutput() {
|
shOutput() {
|
||||||
@@ -1051,7 +1049,6 @@ set(VCS_WC_MODIFIED ${VCS_WC_MODIFIED})
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
# Count path segments
|
# Count path segments
|
||||||
# shellcheck disable=SC2039
|
# shellcheck disable=SC2039
|
||||||
@@ -1142,8 +1139,6 @@ repoTest() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Detect which repos we are in and gather data.
|
# Detect which repos we are in and gather data.
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
if [ -f "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then
|
if [ -f "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then
|
||||||
@@ -1165,7 +1160,6 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# -s output is handled here.
|
# -s output is handled here.
|
||||||
if [ ! -z "${VAROUT}" ]; then
|
if [ ! -z "${VAROUT}" ]; then
|
||||||
if [ "${VAROUT}" = "VCS_TYPE" ]; then
|
if [ "${VAROUT}" = "VCS_TYPE" ]; then
|
||||||
@@ -1196,7 +1190,6 @@ if [ ! -z "${VAROUT}" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Detect requested output type and use it.
|
# Detect requested output type and use it.
|
||||||
if [ ! -z "${AFILETYPE}" ]; then
|
if [ ! -z "${AFILETYPE}" ]; then
|
||||||
if [ "${AFILETYPE}" = "c" ]; then
|
if [ "${AFILETYPE}" = "c" ]; then
|
||||||
@@ -1251,7 +1244,6 @@ if [ ! -z "${AFILETYPE}" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# If requested, make a cache file.
|
# If requested, make a cache file.
|
||||||
if [ ! -z "${CACHEFILE}" ] && [ ! "${CACHEFORCE}" = "1" ]; then
|
if [ ! -z "${CACHEFILE}" ] && [ ! "${CACHEFORCE}" = "1" ]; then
|
||||||
TARGETFILE="${CACHEFILE}.tmp"
|
TARGETFILE="${CACHEFILE}.tmp"
|
||||||
12
ci/envelope_rpm.sh
Normal file
12
ci/envelope_rpm.sh
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
ls $CI_PROJECT_DIR/build/*.rpm
|
||||||
|
|
||||||
|
BIN_TO_PROTECT_IN_RPM="${INSTALL_PREFIX}/bin/stellar"
|
||||||
|
RPMS_FULL_PATH=$(ls $CI_PROJECT_DIR/build/*.rpm | grep -v debug | grep -v devel)
|
||||||
|
echo "RPMS_TO_BE_ENVELOPE: " $RPMS_FULL_PATH
|
||||||
|
|
||||||
|
for RPM in ${RPMS_FULL_PATH[@]}; do
|
||||||
|
echo "ENVELOPE: " $RPM
|
||||||
|
/root/rebuildrpm_and_envelope.sh $RPM $BIN_TO_PROTECT_IN_RPM $FEATURE_ID $APP_NAME_IN_RPM_SPEC
|
||||||
|
done
|
||||||
48
ci/get-nprocessors.sh
Normal file
48
ci/get-nprocessors.sh
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2017 Google Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are
|
||||||
|
# met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above
|
||||||
|
# copyright notice, this list of conditions and the following disclaimer
|
||||||
|
# in the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# * Neither the name of Google Inc. nor the names of its
|
||||||
|
# contributors may be used to endorse or promote products derived from
|
||||||
|
# this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
# This file is typically sourced by another script.
|
||||||
|
# if possible, ask for the precise number of processors,
|
||||||
|
# otherwise take 2 processors as reasonable default; see
|
||||||
|
# https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization
|
||||||
|
if [ -x /usr/bin/getconf ]; then
|
||||||
|
NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
|
||||||
|
else
|
||||||
|
NPROCESSORS=2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# as of 2017-09-04 Travis CI reports 32 processors, but GCC build
|
||||||
|
# crashes if parallelized too much (maybe memory consumption problem),
|
||||||
|
# so limit to 4 processors for the time being.
|
||||||
|
if [ $NPROCESSORS -gt 4 ]; then
|
||||||
|
echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4."
|
||||||
|
NPROCESSORS=4
|
||||||
|
fi
|
||||||
3
ci/perpare_pulp3_netrc.sh
Normal file
3
ci/perpare_pulp3_netrc.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
set -evx
|
||||||
|
echo "machine ${PULP3_SERVER_URL}\nlogin ${PULP3_SERVER_LOGIN}\npassword ${PULP3_SERVER_PASSWORD}\n" >~/.netrc
|
||||||
66
ci/travis.sh
Normal file
66
ci/travis.sh
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
set -evx
|
||||||
|
|
||||||
|
chmod +x ci/get-nprocessors.sh
|
||||||
|
. ci/get-nprocessors.sh
|
||||||
|
|
||||||
|
# if possible, ask for the precise number of processors,
|
||||||
|
# otherwise take 2 processors as reasonable default; see
|
||||||
|
# https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization
|
||||||
|
if [ -x /usr/bin/getconf ]; then
|
||||||
|
NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
|
||||||
|
else
|
||||||
|
NPROCESSORS=2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# as of 2017-09-04 Travis CI reports 32 processors, but GCC build
|
||||||
|
# crashes if parallelized too much (maybe memory consumption problem),
|
||||||
|
# so limit to 4 processors for the time being.
|
||||||
|
if [ $NPROCESSORS -gt 4 ]; then
|
||||||
|
echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4."
|
||||||
|
NPROCESSORS=4
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Tell make to use the processors. No preceding '-' required.
|
||||||
|
MAKEFLAGS="j${NPROCESSORS}"
|
||||||
|
export MAKEFLAGS
|
||||||
|
|
||||||
|
env | sort
|
||||||
|
|
||||||
|
# Set default values to OFF for these variables if not specified.
|
||||||
|
: "${NO_EXCEPTION:=OFF}"
|
||||||
|
: "${NO_RTTI:=OFF}"
|
||||||
|
: "${COMPILER_IS_GNUCXX:=OFF}"
|
||||||
|
|
||||||
|
# Install dependency from YUM
|
||||||
|
yum install -y libpcap-devel
|
||||||
|
|
||||||
|
if [ $ASAN_OPTION ]; then
|
||||||
|
source /opt/rh/devtoolset-7/enable
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir build || true
|
||||||
|
cd build
|
||||||
|
|
||||||
|
cmake3 -DCMAKE_CXX_FLAGS=$CXX_FLAGS \
|
||||||
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||||
|
-DASAN_OPTION=$ASAN_OPTION \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
|
||||||
|
-DTFE_VERSION_DAILY_BUILD=$TESTING_VERSION_BUILD \
|
||||||
|
..
|
||||||
|
|
||||||
|
make
|
||||||
|
make test
|
||||||
|
|
||||||
|
if [ -n "${PACKAGE}" ]; then
|
||||||
|
make package
|
||||||
|
cp ~/rpm_upload_tools.py ./
|
||||||
|
python3 rpm_upload_tools.py ${PULP3_REPO_NAME} ${PULP3_DIST_NAME} *.rpm
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${UPLOAD_SYMBOL_FILES}" ]; then
|
||||||
|
rpm -i stellar*debuginfo*.rpm
|
||||||
|
ls -ahl /usr/lib/debug/opt/tsg/stellar/bin/
|
||||||
|
cp /usr/lib/debug/opt/tsg/stellar/bin/stellar*debug /tmp/stellar.debuginfo.${CI_COMMIT_SHORT_SHA}
|
||||||
|
sentry-cli upload-dif -t elf /tmp/stellar.debuginfo.${CI_COMMIT_SHORT_SHA}
|
||||||
|
fi
|
||||||
21
ci/upload_enveloped_rpm.sh
Normal file
21
ci/upload_enveloped_rpm.sh
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
cd $CI_PROJECT_DIR/build/
|
||||||
|
cp ~/rpm_upload_tools.py ./
|
||||||
|
|
||||||
|
ls -ahl *.rpm
|
||||||
|
|
||||||
|
RPM_IS_EL7=$(ls -ahl *-pr-*.rpm | grep el7 | wc -l)
|
||||||
|
RPM_IS_EL8=$(ls -ahl *-pr-*.rpm | grep el8 | wc -l)
|
||||||
|
|
||||||
|
if [ $RPM_IS_EL7 -eq 1 ]; then
|
||||||
|
echo "====== Upload the packed RPM package for CentOS7 ======"
|
||||||
|
python3 rpm_upload_tools.py ${PULP3_REPO_NAME_EL7} ${PULP3_DIST_NAME_EL7} *-pr-*el7*.rpm
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $RPM_IS_EL8 -eq 1 ]; then
|
||||||
|
echo "====== Upload the packed RPM package for CentOS8 ======"
|
||||||
|
python3 rpm_upload_tools.py ${PULP3_REPO_NAME_EL8} ${PULP3_DIST_NAME_EL8} *-pr-*el8*.rpm
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf *.rpm
|
||||||
39
cmake/FindSYSTEMD.cmake
Normal file
39
cmake/FindSYSTEMD.cmake
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# - Find SystemdDaemon
|
||||||
|
# Find the systemd daemon library
|
||||||
|
#
|
||||||
|
# This module defines the following variables:
|
||||||
|
# SYSTEMD_FOUND - True if library and include directory are found
|
||||||
|
# If set to TRUE, the following are also defined:
|
||||||
|
# SYSTEMD_INCLUDE_DIRS - The directory where to find the header file
|
||||||
|
# SYSTEMD_LIBRARIES - Where to find the library file
|
||||||
|
#
|
||||||
|
# For conveniance, these variables are also set. They have the same values
|
||||||
|
# than the variables above. The user can thus choose his/her prefered way
|
||||||
|
# to write them.
|
||||||
|
# SYSTEMD_LIBRARY
|
||||||
|
# SYSTEMD_INCLUDE_DIR
|
||||||
|
#
|
||||||
|
# This file is in the public domain
|
||||||
|
|
||||||
|
include(FindPkgConfig)
|
||||||
|
pkg_check_modules(SYSTEMD libsystemd)
|
||||||
|
|
||||||
|
if(NOT SYSTEMD_FOUND)
|
||||||
|
find_path(SYSTEMD_INCLUDE_DIRS NAMES systemd/sd-daemon.h
|
||||||
|
DOC "The Systemd include directory")
|
||||||
|
|
||||||
|
find_library(SYSTEMD_LIBRARIES NAMES systemd
|
||||||
|
DOC "The Systemd library")
|
||||||
|
|
||||||
|
# Use some standard module to handle the QUIETLY and REQUIRED arguments, and
|
||||||
|
# set SYSTEMD_FOUND to TRUE if these two variables are set.
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(SYSTEMD REQUIRED_VARS SYSTEMD_LIBRARIES SYSTEMD_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
if(SYSTEMD_FOUND)
|
||||||
|
set(SYSTEMD_LIBRARY ${SYSTEMD_LIBRARIES})
|
||||||
|
set(SYSTEMD_INCLUDE_DIR ${SYSTEMD_INCLUDE_DIRS})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES)
|
||||||
35
cmake/Package.cmake
Normal file
35
cmake/Package.cmake
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(CPACK_PACKAGE_NAME "stellar-debug")
|
||||||
|
else()
|
||||||
|
set(CPACK_PACKAGE_NAME "stellar")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Package: ${CPACK_PACKAGE_NAME}")
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_VENDOR "TSG")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR "${STELLAR_VERSION_MAJOR}")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR "${STELLAR_VERSION_MINOR}")
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH "${STELLAR_VERSION_PATCH}.${STELLAR_DESCRIBE}")
|
||||||
|
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||||
|
|
||||||
|
# RPM Build
|
||||||
|
set(CPACK_GENERATOR "RPM")
|
||||||
|
set(CPACK_RPM_AUTO_GENERATED_FILE_NAME ON)
|
||||||
|
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
|
||||||
|
set(CPACK_RPM_PACKAGE_AUTOREQPROV "no")
|
||||||
|
set(CPACK_RPM_PACKAGE_RELEASE_DIST on)
|
||||||
|
set(CPACK_RPM_DEBUGINFO_PACKAGE on)
|
||||||
|
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostInstall.in)
|
||||||
|
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostUninstall.in)
|
||||||
|
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PreUninstall.in)
|
||||||
|
|
||||||
|
# Must uninstall the debug package before install release package
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(CPACK_RPM_PACKAGE_CONFLICTS "stellar")
|
||||||
|
else()
|
||||||
|
set(CPACK_RPM_PACKAGE_CONFLICTS "stellar-debug")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Setup %config(noreplace)
|
||||||
|
set(CPACK_RPM_USER_FILELIST "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/conf/stellar/stellar.conf")
|
||||||
|
include(CPack)
|
||||||
@@ -1,58 +1,47 @@
|
|||||||
|
|
||||||
# Using autorevision.sh to generate version information
|
# Using autorevision.sh to generate version information
|
||||||
|
set(__SOURCE_AUTORESIVISION ${CMAKE_SOURCE_DIR}/autorevision.sh)
|
||||||
set(__SOURCE_AUTORESIVISION ${CMAKE_SOURCE_DIR}/cmake/autorevision.sh)
|
|
||||||
set(__AUTORESIVISION ${CMAKE_BINARY_DIR}/autorevision.sh)
|
set(__AUTORESIVISION ${CMAKE_BINARY_DIR}/autorevision.sh)
|
||||||
set(__VERSION_CACHE ${CMAKE_BINARY_DIR}/version.txt)
|
set(__VERSION_CACHE ${CMAKE_SOURCE_DIR}/version.txt)
|
||||||
set(__VERSION_CONFIG ${CMAKE_BINARY_DIR}/version.cmake)
|
set(__VERSION_CONFIG ${CMAKE_BINARY_DIR}/version.cmake)
|
||||||
|
|
||||||
file(COPY ${__SOURCE_AUTORESIVISION} DESTINATION ${CMAKE_BINARY_DIR}
|
file(COPY ${__SOURCE_AUTORESIVISION} DESTINATION ${CMAKE_BINARY_DIR}
|
||||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
|
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
|
||||||
WORLD_READ WORLD_EXECUTE)
|
WORLD_READ WORLD_EXECUTE)
|
||||||
|
|
||||||
# execute autorevision.sh to generate version information
|
# Execute autorevision.sh to generate version information
|
||||||
execute_process(COMMAND ${__AUTORESIVISION} -t cmake -o ${__VERSION_CACHE}
|
execute_process(COMMAND ${__AUTORESIVISION} -t cmake -o ${__VERSION_CACHE} OUTPUT_FILE ${__VERSION_CONFIG})
|
||||||
OUTPUT_FILE ${__VERSION_CONFIG} ERROR_QUIET)
|
|
||||||
include(${__VERSION_CONFIG})
|
include(${__VERSION_CONFIG})
|
||||||
|
|
||||||
# extract major, minor, patch version from git tag
|
# Extract major, minor, patch version from git tag
|
||||||
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VCS_TAG}")
|
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" STELLAR_VERSION_MAJOR "${VCS_TAG}")
|
||||||
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VCS_TAG}")
|
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" STELLAR_VERSION_MINOR "${VCS_TAG}")
|
||||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VCS_TAG}")
|
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STELLAR_VERSION_PATCH "${VCS_TAG}")
|
||||||
|
string(REGEX REPLACE "[T\\:\\+\\-]" "" STELLAR_VERSION_DATE "${VCS_DATE}")
|
||||||
|
|
||||||
string(REGEX REPLACE "[T\\:\\+\\-]" "" VERSION_DATE "${VCS_DATE}")
|
if(STELLAR_VERSION_DAILY_BUILD)
|
||||||
|
set(STELLAR_VERSION_PATCH ${STELLAR_VERSION_PATCH}.${STELLAR_VERSION_DATE})
|
||||||
if(VERSION_DAILY_BUILD)
|
|
||||||
set(VERSION_PATCH ${VERSION_PATCH}.${VERSION_DATE})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT STELLAR_VERSION_MAJOR)
|
||||||
if(NOT VERSION_MAJOR)
|
set(STELLAR_VERSION_MAJOR 3)
|
||||||
set(VERSION_MAJOR 1)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT VERSION_MINOR)
|
if(NOT STELLAR_VERSION_MINOR)
|
||||||
set(VERSION_MINOR 0)
|
set(STELLAR_VERSION_MINOR 0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT VERSION_PATCH)
|
if(NOT STELLAR_VERSION_PATCH)
|
||||||
set(VERSION_PATCH 0)
|
set(STELLAR_VERSION_PATCH 0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
set(STELLAR_DESCRIBE "${VCS_SHORT_HASH}")
|
||||||
set(VERSION_BUILD "${VCS_SHORT_HASH}")
|
set(STELLAR_VERSION "${STELLAR_VERSION_MAJOR}.${STELLAR_VERSION_MINOR}.${STELLAR_VERSION_PATCH}")
|
||||||
|
set(STELLAR_GIT_VERSION "${STELLAR_VERSION_MAJOR}.${STELLAR_VERSION_MINOR}.${STELLAR_VERSION_PATCH}-${STELLAR_DESCRIBE}")
|
||||||
|
|
||||||
# print information
|
# Replace .- with _
|
||||||
message(STATUS "Version: ${VERSION}-${VERSION_BUILD}")
|
string(REGEX REPLACE "[\\.\\-]" "_" STELLAR_VAR_VERSION "${STELLAR_GIT_VERSION}")
|
||||||
|
|
||||||
option(DEFINE_GIT_VERSION "Set DEFINE_GIT_VERSION to TRUE or FALSE" TRUE)
|
# Print information
|
||||||
|
message(STATUS "Welcome to stateful network function development platform, Version: ${STELLAR_GIT_VERSION}")
|
||||||
if(DEFINE_GIT_VERSION)
|
add_definitions(-DSTELLAR_GIT_VERSION=\"${STELLAR_GIT_VERSION}\")
|
||||||
|
add_definitions(-DSTELLAR_VAR_VERSION=${STELLAR_VAR_VERSION})
|
||||||
set(GIT_VERSION "${VERSION}-${CMAKE_BUILD_TYPE}-${VERSION_BUILD}-${VCS_BRANCH}-${VCS_DATE}")
|
|
||||||
message(STATUS "GIT_VERSION: ${GIT_VERSION}")
|
|
||||||
string(REGEX REPLACE "[-:+/\\.]" "_" GIT_VERSION ${GIT_VERSION})
|
|
||||||
|
|
||||||
add_definitions(-DGIT_VERSION=\"${GIT_VERSION}\")
|
|
||||||
|
|
||||||
endif()
|
|
||||||
1
conf/CMakeLists.txt
Normal file
1
conf/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
install(DIRECTORY stellar DESTINATION conf COMPONENT Profile)
|
||||||
0
conf/stellar/stellar.conf
Normal file
0
conf/stellar/stellar.conf
Normal file
@@ -84,7 +84,7 @@ extern "C" void custom_event_plugin_tcp_entry(const struct stellar_session *sess
|
|||||||
if (*per_tcp_session_pme == NULL)
|
if (*per_tcp_session_pme == NULL)
|
||||||
{
|
{
|
||||||
struct tcp_session_pme *cur_ctx = tcp_session_pme_create();
|
struct tcp_session_pme *cur_ctx = tcp_session_pme_create();
|
||||||
snprintf(cur_ctx->data, 6, "tcp******");
|
memcpy(cur_ctx->data, "custom_event_plugin_tcp_entry", strlen("custom_event_plugin_tcp_entry"));
|
||||||
*per_tcp_session_pme = *&cur_ctx;
|
*per_tcp_session_pme = *&cur_ctx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ extern "C" void custom_event_plugin_custom_entry(const struct stellar_session *s
|
|||||||
if (*per_custom_session_pme == NULL)
|
if (*per_custom_session_pme == NULL)
|
||||||
{
|
{
|
||||||
struct custom_session_pme *cur_ctx = custom_session_pme_create();
|
struct custom_session_pme *cur_ctx = custom_session_pme_create();
|
||||||
snprintf(cur_ctx->data, 6, "custom******");
|
memcpy(cur_ctx->data, "custom_event_plugin_custom_entry", strlen("custom_event_plugin_custom_entry"));
|
||||||
*per_custom_session_pme = *&cur_ctx;
|
*per_custom_session_pme = *&cur_ctx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ extern "C" void http_event_plugin_entry(const struct stellar_session *session, e
|
|||||||
if (*per_http_session_pme == NULL)
|
if (*per_http_session_pme == NULL)
|
||||||
{
|
{
|
||||||
struct http_session_pme *cur_ctx = http_session_pme_create();
|
struct http_session_pme *cur_ctx = http_session_pme_create();
|
||||||
snprintf(cur_ctx->data, 6, "http******");
|
memcpy(cur_ctx->data, "http_event_plugin_entry", strlen("http_event_plugin_entry"));
|
||||||
*per_http_session_pme = *&cur_ctx;
|
*per_http_session_pme = *&cur_ctx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ add_executable(gtest_packet_io
|
|||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
gtest_packet_io
|
gtest_packet_io
|
||||||
gtest_main
|
gtest
|
||||||
packet_io
|
packet_io
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ static int plugin_manager_init_plugins(struct plugin_manager *plug_mgr)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
double percentage = ((double)(i + 1)) / ((double)plug_mgr->used_module_num) * ((double)100);
|
double percentage = ((double)(i + 1)) / ((double)plug_mgr->used_module_num) * ((double)100);
|
||||||
plugin_manager_log(INFO, "Plugin initialization progress: [%.2f%]", percentage);
|
plugin_manager_log(INFO, "Plugin initialization progress: [%.2f%%]", percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -419,7 +419,7 @@ void plugin_manager_dispatch(struct plugin_manager *plug_mgr, struct stellar_eve
|
|||||||
plug_ctx = plugin_manager_create_plugin_ctx(plug_mgr, session_name);
|
plug_ctx = plugin_manager_create_plugin_ctx(plug_mgr, session_name);
|
||||||
if (plug_ctx == NULL)
|
if (plug_ctx == NULL)
|
||||||
{
|
{
|
||||||
plugin_manager_log(ERROR, "can't create runtime plugin ctx for session '%s', Please check whether the callback is registered in the current session");
|
plugin_manager_log(ERROR, "can't create runtime plugin ctx for session '%s', Please check whether the callback is registered in the current session", session_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stellar_event_set_plugin_ctx(event, plug_ctx);
|
stellar_event_set_plugin_ctx(event, plug_ctx);
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ int plugin_manager_module_init(struct plugin_manager_module *module)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
long elapsed = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000;
|
long long elapsed = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000;
|
||||||
plugin_manager_log(INFO, "plugin dynamic library '%s' init success, using '%lld' us", module->lib_path, elapsed);
|
plugin_manager_log(INFO, "plugin dynamic library '%s' init success, using '%lld' us", module->lib_path, elapsed);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -157,7 +157,7 @@ void plugin_manager_module_exit(struct plugin_manager_module *module)
|
|||||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||||
module->exit_cb_ptr = NULL;
|
module->exit_cb_ptr = NULL;
|
||||||
|
|
||||||
long elapsed = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000;
|
long long elapsed = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000;
|
||||||
plugin_manager_log(INFO, "plugin dynamic library '%s' exit success, using '%lld' us", module->lib_path, elapsed);
|
plugin_manager_log(INFO, "plugin dynamic library '%s' exit success, using '%lld' us", module->lib_path, elapsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ add_executable(gtest_plugin_manager
|
|||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
gtest_plugin_manager
|
gtest_plugin_manager
|
||||||
gtest_main
|
gtest
|
||||||
plugin_manager
|
plugin_manager
|
||||||
session_manager
|
session_manager
|
||||||
toml
|
toml
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ TEST(PLUGIN_MANAGER_TEST, plugin_mangager_config_CUSTOM)
|
|||||||
|
|
||||||
EXPECT_STREQ(config->session_section[2].session_name, "CUSTOM");
|
EXPECT_STREQ(config->session_section[2].session_name, "CUSTOM");
|
||||||
EXPECT_STREQ(config->session_section[2].cb_func_name, "custom_event_plugin_custom_entry");
|
EXPECT_STREQ(config->session_section[2].cb_func_name, "custom_event_plugin_custom_entry");
|
||||||
EXPECT_TRUE(config->session_section[2].event == (0x01 << 1) | (0x01 << 3) | (0x01 << 5));
|
EXPECT_TRUE(config->session_section[2].event == (enum session_event_type)((0x01 << 1) | (0x01 << 3) | (0x01 << 5)));
|
||||||
|
|
||||||
plugin_mangager_config_dump(config);
|
plugin_mangager_config_dump(config);
|
||||||
plugin_mangager_config_destory(config);
|
plugin_mangager_config_destory(config);
|
||||||
@@ -377,28 +377,28 @@ TEST(PLUGIN_MANAGER_TEST, plugin_manager_dispatch_TCP)
|
|||||||
plugin_manager_dispatch(plug_mgr, &event);
|
plugin_manager_dispatch(plug_mgr, &event);
|
||||||
pme = (struct tcp_session_pme *)pm_session_get_plugin_pme(&session);
|
pme = (struct tcp_session_pme *)pm_session_get_plugin_pme(&session);
|
||||||
EXPECT_TRUE(pme->flags == SESSION_EVENT_OPENING);
|
EXPECT_TRUE(pme->flags == SESSION_EVENT_OPENING);
|
||||||
EXPECT_STREQ(pme->data, "tcp***");
|
EXPECT_STREQ(pme->data, "custom_event_plugin_tcp_entry");
|
||||||
|
|
||||||
// run evencb
|
// run evencb
|
||||||
event_data.type = SESSION_EVENT_RAWPKT;
|
event_data.type = SESSION_EVENT_RAWPKT;
|
||||||
plugin_manager_dispatch(plug_mgr, &event);
|
plugin_manager_dispatch(plug_mgr, &event);
|
||||||
pme = (struct tcp_session_pme *)pm_session_get_plugin_pme(&session);
|
pme = (struct tcp_session_pme *)pm_session_get_plugin_pme(&session);
|
||||||
EXPECT_TRUE(pme->flags == SESSION_EVENT_RAWPKT);
|
EXPECT_TRUE(pme->flags == SESSION_EVENT_RAWPKT);
|
||||||
EXPECT_STREQ(pme->data, "tcp***");
|
EXPECT_STREQ(pme->data, "custom_event_plugin_tcp_entry");
|
||||||
|
|
||||||
// run evencb
|
// run evencb
|
||||||
event_data.type = SESSION_EVENT_ORDPKT;
|
event_data.type = SESSION_EVENT_ORDPKT;
|
||||||
plugin_manager_dispatch(plug_mgr, &event);
|
plugin_manager_dispatch(plug_mgr, &event);
|
||||||
pme = (struct tcp_session_pme *)pm_session_get_plugin_pme(&session);
|
pme = (struct tcp_session_pme *)pm_session_get_plugin_pme(&session);
|
||||||
EXPECT_TRUE(pme->flags == SESSION_EVENT_ORDPKT);
|
EXPECT_TRUE(pme->flags == SESSION_EVENT_ORDPKT);
|
||||||
EXPECT_STREQ(pme->data, "tcp***");
|
EXPECT_STREQ(pme->data, "custom_event_plugin_tcp_entry");
|
||||||
|
|
||||||
// run evencb
|
// run evencb
|
||||||
event_data.type = SESSION_EVENT_META;
|
event_data.type = SESSION_EVENT_META;
|
||||||
plugin_manager_dispatch(plug_mgr, &event);
|
plugin_manager_dispatch(plug_mgr, &event);
|
||||||
pme = (struct tcp_session_pme *)pm_session_get_plugin_pme(&session);
|
pme = (struct tcp_session_pme *)pm_session_get_plugin_pme(&session);
|
||||||
EXPECT_TRUE(pme->flags == SESSION_EVENT_META);
|
EXPECT_TRUE(pme->flags == SESSION_EVENT_META);
|
||||||
EXPECT_STREQ(pme->data, "tcp***");
|
EXPECT_STREQ(pme->data, "custom_event_plugin_tcp_entry");
|
||||||
|
|
||||||
// run evencb
|
// run evencb
|
||||||
event_data.type = SESSION_EVENT_CLOSING;
|
event_data.type = SESSION_EVENT_CLOSING;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ extern "C" void custom_event_plugin_tcp_entry(const struct stellar_session *sess
|
|||||||
if (*per_tcp_session_pme == NULL)
|
if (*per_tcp_session_pme == NULL)
|
||||||
{
|
{
|
||||||
struct tcp_session_pme *cur_ctx = tcp_session_pme_create();
|
struct tcp_session_pme *cur_ctx = tcp_session_pme_create();
|
||||||
memcpy(cur_ctx->data, "tcp***", 6);
|
memcpy(cur_ctx->data, "custom_event_plugin_tcp_entry", strlen("custom_event_plugin_tcp_entry"));
|
||||||
cur_ctx->flags = SESSION_EVENT_OPENING;
|
cur_ctx->flags = SESSION_EVENT_OPENING;
|
||||||
*per_tcp_session_pme = *&cur_ctx;
|
*per_tcp_session_pme = *&cur_ctx;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "sdk/include/session.h"
|
#include "sdk/include/session.h"
|
||||||
|
|
||||||
void http_decoder(const struct stellar_session *s, enum session_event_type event, struct stellar_packet *p, const char *payload, uint16_t len, void **pme)
|
void http_decoder(const struct stellar_session *s, enum session_event_type event, struct stellar_packet *p, const char *payload, uint16_t len, void **pme)
|
||||||
{
|
{
|
||||||
struct stellar_session_event_extras *info;
|
struct stellar_session_event_extras *info = NULL;
|
||||||
struct stellar_session *new_session = session_manager_session_derive(s, "HTTP");
|
struct stellar_session *new_session = session_manager_session_derive(s, "HTTP");
|
||||||
|
|
||||||
session_manager_trigger_event(new_session, SESSION_EVENT_OPENING, info);
|
session_manager_trigger_event(new_session, SESSION_EVENT_OPENING, info);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ add_executable(gtest_stellar
|
|||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
gtest_stellar
|
gtest_stellar
|
||||||
gtest_main
|
gtest
|
||||||
)
|
)
|
||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
|
|||||||
27
vendor/CMakeLists.txt
vendored
27
vendor/CMakeLists.txt
vendored
@@ -1,10 +1,21 @@
|
|||||||
include(FetchContent)
|
include(ExternalProject)
|
||||||
FetchContent_Declare(
|
|
||||||
googletest
|
# GoogleTest
|
||||||
#URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
|
ExternalProject_Add(googletest PREFIX googletest
|
||||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/googletest-release-1.8.0.tar.gz
|
URL ${CMAKE_CURRENT_SOURCE_DIR}/googletest-release-1.8.0.tar.gz
|
||||||
URL_MD5 16877098823401d1bf2ed7891d7dce36
|
URL_MD5 16877098823401d1bf2ed7891d7dce36
|
||||||
)
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
|
||||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
||||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
ExternalProject_Get_Property(googletest INSTALL_DIR)
|
||||||
FetchContent_MakeAvailable(googletest)
|
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
|
||||||
|
|
||||||
|
add_library(gtest STATIC IMPORTED GLOBAL)
|
||||||
|
add_dependencies(gtest googletest)
|
||||||
|
set_property(TARGET gtest PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libgtest.a)
|
||||||
|
set_property(TARGET gtest PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
|
||||||
|
set_property(TARGET gtest PROPERTY INTERFACE_LINK_LIBRARIES pthread)
|
||||||
|
|
||||||
|
add_library(gmock STATIC IMPORTED GLOBAL)
|
||||||
|
add_dependencies(gmock googletest)
|
||||||
|
set_property(TARGET gmock PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libgmock.a)
|
||||||
|
set_property(TARGET gmock PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
|
||||||
Reference in New Issue
Block a user