Skip to content

add test code.

add test code. #365

Workflow file for this run

name: PSS_ASIO_CMake
on: [push]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/Build/Linux
- name: update gcov software
run: pip install gcovr==5.0
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/Build/Linux
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -Dgcov_check=1
- name: download sonar cloud client
working-directory: ${{github.workspace}}
shell: bash
run: |
echo "download sonar scanner client."
wget -nv https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
echo "ls download file."
unzip -q sonar-scanner-cli-5.0.1.3006-linux.zip
echo "ls unzip download file."
cd ${PWD}/sonar-scanner-5.0.1.3006-linux/bin/
echo "ls sonar scanner file."
ls -l
echo "ls sonar scanner path."
pwd
echo "${PWD}/sonar-scanner-5.0.1.3006-linux/bin/" >> $GITHUB_PATH
wget -nv https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip -q build-wrapper-linux-x86.zip
echo "${PWD}/build-wrapper-linux-x86" >> $GITHUB_PATH
cd ${{github.workspace}}
- name: Install dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y scons libfftw3-dev libopenmpi-dev openmpi-bin libhdf5-dev python3-numpy python3-dev libtiff5-dev unzip
- name: Build SonarCloud Scan
working-directory: ${{github.workspace}}
shell: bash
run: |
build-wrapper-linux-x86-64 --out-dir bw-output cmake --build Build/Linux/
cd ${{github.workspace}}/Build/Linux/
./pss_asio server_config_test_gcov.json
sleep 5
./pss_asio_test_client
sleep 5
killall pss_asio
sleep 20
echo "close pss_asio"
echo "gcov********************"
cd ${{github.workspace}}
pwd
gcovr --sonarqube > coverage.xml
ls -la coverage.xml
echo "gcov********************Begin"
cd ${{github.workspace}}/Build/Linux/
pwd
gcov -a ./PSS_ASIO/CMakeFiles/pss_asio.dir/QueueSession/*.cpp.gcda ../../PSS_ASIO/QueueSession/*.cpp > /dev/null
gcov -a ./PSS_ASIO/CMakeFiles/pss_asio.dir/TTySession/*.cpp.gcda ../../PSS_ASIO/TTySession/*.cpp > /dev/null
gcov -a ./PSS_ASIO/CMakeFiles/pss_asio.dir/TcpSession/*.cpp.gcda ../../PSS_ASIO/TcpSession/*.cpp > /dev/null
gcov -a ./PSS_ASIO/CMakeFiles/pss_asio.dir/UdpSession/*.cpp.gcda ../../PSS_ASIO/UdpSession/*.cpp > /dev/null
gcov -a ./PSS_ASIO/CMakeFiles/pss_asio.dir/Common/*.cpp.gcda ../../PSS_ASIO/Common/*.cpp > /dev/null
gcov -a ./PSS_ASIO/CMakeFiles/pss_asio.dir/Message/*.cpp.gcda ../../PSS_ASIO/Message/*.cpp > /dev/null
find ./ -name "*.gcov" | wc -l
echo "gcov********************End"
- name: SonarCloud Scan make report
working-directory: ${{github.workspace}}
shell: bash
run: |
cd ${{github.workspace}}/PSS_ASIO
/home/runner/work/PSS_ASIO/PSS_ASIO/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: install google test
working-directory: ${{github.workspace}}/tests
shell: bash
run: sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make
- name: run google test
working-directory: ${{github.workspace}}/tests
shell: bash
run: |
apt list --installed | grep gtest
cmake .
cmake --build . --config debug
./test_pss_asio
- name: make report && show
working-directory: ${{github.workspace}}/tests
shell: bash
run: |
cat Test_Pss_Asio.xml
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}