Skip to content

Commit

Permalink
adding utils to code coverage (#755)
Browse files Browse the repository at this point in the history
* turning utils on in developer workflow and testing noMemCheck

* Update CMakeLists.txt

* fixing memory leak in grb2index test

* path issue in degrib2 test

* separate asan / code coverage runs in developer workflow

* typo

* Update developer.yml

* debugging jasper failure

* debug with g2c_compare off

---------

Co-authored-by: Edward Hartnett <[email protected]>
  • Loading branch information
AlysonStahl-NOAA and edwardhartnett authored Nov 1, 2024
1 parent eed962b commit a49bdb7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,22 @@ on:
branches:
- develop

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
developer:
runs-on: ubuntu-latest
env:
FC: gfortran
CC: gcc
LD_LIBRARY_PATH: /home/runner/work/NCEPLIBS-g2/NCEPLIBS-g2/nceplibs/jasper/lib/

strategy:
fail-fast: true
matrix:
config: ["asan/warning check", "docs/code coverage"]

steps:

Expand Down Expand Up @@ -51,18 +61,26 @@ jobs:
key: data-developer-5

- name: asan
if: matrix.config == 'asan/warning check'
run: |
set -x
cd g2
mkdir build
doxygen --version
cd build
cmake -DBUILD_UTILS=OFF -DG2C_COMPARE=ON -DUSE_AEC=ON -DFTP_LARGE_TEST_FILES=ON -DENABLE_DOCS=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-bacio;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-w3emc;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DCMAKE_Fortran_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -Wall -fno-omit-frame-pointer -fsanitize=address" -DCMAKE_C_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -Wall -fno-omit-frame-pointer -fsanitize=address" -DFTP_TEST_FILES=ON -DTEST_FILE_DIR=/home/runner/data -DCMAKE_BUILD_TYPE=Debug ..
cmake -DBUILD_UTILS=OFF -DUSE_AEC=ON -DFTP_LARGE_TEST_FILES=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-bacio;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-w3emc;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DCMAKE_Fortran_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -Wall -fno-omit-frame-pointer -fsanitize=address" -DCMAKE_C_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -Wall -fno-omit-frame-pointer -fsanitize=address" -DFTP_TEST_FILES=ON -DTEST_FILE_DIR=/home/runner/data -DCMAKE_BUILD_TYPE=Debug ..
make -j2 VERBOSE=1
ctest --verbose --output-on-failure --rerun-failed
- name: test_asan
- name: build
if: matrix.config == 'docs/code coverage'
run: |
cd $GITHUB_WORKSPACE/g2/build
set -x
cd g2
mkdir build
doxygen --version
cd build
cmake -DBUILD_UTILS=ON -DG2C_COMPARE=OFF -DUSE_AEC=ON -DFTP_LARGE_TEST_FILES=ON -DENABLE_DOCS=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-bacio;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-w3emc;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DFTP_TEST_FILES=ON -DTEST_FILE_DIR=/home/runner/data ..
make -j2 VERBOSE=1
ctest --verbose --output-on-failure --rerun-failed
gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null
Expand All @@ -73,6 +91,7 @@ jobs:
cp $GITHUB_WORKSPACE/g2/build/tests/data/* ~/data
- name: upload-test-coverage
if: matrix.config == 'docs/code coverage'
uses: actions/upload-artifact@v4
with:
name: g2-test-coverage
Expand Down
4 changes: 4 additions & 0 deletions src/g2index.F90
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ end subroutine getg2i2r
nlen, nnum, nmess, irgi)
if (irgi .gt. 1 .or. nnum .eq. 0 .or. nlen .eq. 0) then
iret = 92
if (associated(cbuf)) then
deallocate(cbuf)
nullify(cbuf)
endif
return
endif
numtot = numtot + nnum
Expand Down
2 changes: 1 addition & 1 deletion test_utils/run_degrib2_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo ""
echo "*** Running degrib2 tests"

# Confirm that degrib2 fails without any arguments.
degrib2 && exit 1
../utils/degrib2 && exit 1

# Degrib2 a GRIB2 file.
../utils/degrib2 data/ref_gdaswave.t00z.wcoast.0p16.f000.grib2 &> test_gdaswave.degrib2.txt
Expand Down

0 comments on commit a49bdb7

Please sign in to comment.