Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valgrind CI #565

Merged
merged 9 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 61 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04]
gcc_v: [7,8,9,10] # Version of GFortran we want to use.
python-version: [3.9]
gcc_v: [7,8,9,10,11] # Version of GFortran we want to use.
python-version: [3.11]
env:
FC: gfortran-${{matrix.gcc_v}}
GCC_V: ${{matrix.gcc_v}}
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
if: contains( matrix.os, 'ubuntu')
run: |
python -m pip install --upgrade pip
pip install ford FoBiS.py pygooglechart
pip install ford FoBiS.py pygooglechart fpm
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Install GFortran Linux
Expand All @@ -60,14 +60,71 @@ jobs:
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}

- name: Compile_with_build
if: matrix.gcc_v != 7
if: matrix.gcc_v != 7 && matrix.gcc_v != 11
run: |
GFORTRAN=gfortran-${{matrix.gcc_v}}
GCOV=gcov-${{matrix.gcc_v}}
# build with build.sh, run unit tests
./build.sh --skip-documentation
./build.sh --skip-documentation --enable-unicode

- name: Compile_with_FPM
if: matrix.gcc_v == 11
run: |
GFORTRAN=gfortran-${{matrix.gcc_v}}
GCOV=gcov-${{matrix.gcc_v}}
sudo apt update && sudo apt install -y valgrind
fpm test jf_test_01 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_02 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_03 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_04 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_05 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_06 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_07 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_08 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_09 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_10 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_11 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_12 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_13 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_14 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_15 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_16 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_17 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_18 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_19 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_20 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_21 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_22 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_23 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_24 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_25 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_26 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_27 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_28 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_29 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_30 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_31 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_32 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_33 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_34 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_35 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_36 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_37 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_38 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_39 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_40 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_41 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_42 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_43 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_44 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_45 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_46 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_47 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_48 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_49 --runner "valgrind --leak-check=full --show-leak-kinds=all"
fpm test jf_test_50 --runner "valgrind --leak-check=full --show-leak-kinds=all"

- name: Compile_with_cmake
# CMake build with unit tests, no documentation, with coverage analysis
# No unicode so that coverage combined with the build script will cover unicode
Expand Down
5 changes: 4 additions & 1 deletion src/tests/jf_test_12.F90
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ subroutine test_12(error_cnt)
call json%get(me=root,path='array data.data',array_callback=get_3D_from_array)
call check_errors(all(abs(fetched_array - reshape(raw_array,[size(raw_array)])) <= TOL))

my_file = json_file(root,verbose=.true.,real_format='G')
!my_file = json_file(root,verbose=.true.,real_format='G') ! valgrind says this cases a memory leak
call my_file%initialize(verbose=.true.,real_format='G') ! this doesn't have a memmory leak
call my_file%add(root)
nullify(root)

call my_file%update('array data.description',CK_'vector data',found=existed)
call check_file_errors(existed)
Expand Down
4 changes: 3 additions & 1 deletion src/tests/jf_test_15.F90
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ subroutine test_15(error_cnt)

!****************************************

file1 = json_file(p2,json) !constructor
!file1 = json_file(p2,json) ! memory leak with gfortran?
call file1%initialize(json)
call file1%add(p2); nullify(p2)
call file1%destroy(destroy_core=.true.)

!****************************************
Expand Down
4 changes: 3 additions & 1 deletion src/tests/jf_test_25.F90
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ subroutine test_25(error_cnt)
#endif

! test json_file interface
f = json_file(p)
!f = json_file(p) ! memory leak in gfortran?
call f%initialize()
call f%add(p)
nullify(p) ! data is now in f
call f%get('str_array', vec, ilen, found)
if (.not. found) then
Expand Down
4 changes: 3 additions & 1 deletion src/tests/jf_test_27.F90
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ subroutine test_27(error_cnt)
call json%print(p,int(output_unit,IK))

! test json_file interface
f = json_file(p)
!f = json_file(p) ! memory leak in gfortran?
call f%initialize()
call f%add(p)
nullify(p) ! data is now in f
call f%initialize(compress_vectors=.true.)
call f%print()
Expand Down
32 changes: 24 additions & 8 deletions src/tests/jf_test_37.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,34 @@ subroutine test_37(error_cnt)
call json%initialize(no_whitespace=.true.)

call json%deserialize(p, CK_'{"a": ["1", "2", "3"]}')
f = json_file(p,no_whitespace=.true.)
!f = json_file(p,no_whitespace=.true.) ! memory leak in gfortran?
call f%initialize(no_whitespace=.true.)
call f%add(p)
call f%print(int(error_unit,IK))
write(error_unit,'(A)') ''
call check_for_error()
call f%destroy()

call json%deserialize(p, CK_'{"b": ["4", "5", "6"]}')
f = json_file(p,json)
!f = json_file(p,json) ! memory leak in gfortran?
call f%initialize(json)
call f%add(p)
call f%print(int(error_unit,IK))
write(error_unit,'(A)') ''
call check_for_error()
call f%destroy()

f = json_file(CK_'{"x": [1,2,3]}',no_whitespace=.true.)
!f = json_file(CK_'{"x": [1,2,3]}',no_whitespace=.true.) ! memory leak in gfortran?
call f%initialize(no_whitespace=.true.)
call f%deserialize(CK_'{"x": [1,2,3]}')
call f%print(int(error_unit,IK))
write(error_unit,'(A)') ''
call check_for_error()
call f%destroy()

f = json_file(CK_'{"y": [4,5,6]}',json)
!f = json_file(CK_'{"y": [4,5,6]}',json) ! memory leak in gfortran?
call f%initialize(json)
call f%deserialize(CK_'{"y": [4,5,6]}')
call f%print(int(error_unit,IK))
write(error_unit,'(A)') ''
call check_for_error()
Expand All @@ -69,26 +77,34 @@ subroutine test_37(error_cnt)
! also test default character kind when unicode is enabled:

call json%deserialize(p, CDK_'{"a": ["1", "2", "3"]}')
f = json_file(p,no_whitespace=.true.)
!f = json_file(p,no_whitespace=.true.) ! memory leak in gfortran?
call f%initialize(no_whitespace=.true.)
call f%add(p)
call f%print(int(error_unit,IK))
write(error_unit,'(A)') ''
call check_for_error()
call f%destroy()

call json%deserialize(p, CDK_'{"b": ["4", "5", "6"]}')
f = json_file(p,json)
!f = json_file(p,json) ! memory leak in gfortran?
call f%initialize(json)
call f%add(p)
call f%print(int(error_unit,IK))
write(error_unit,'(A)') ''
call check_for_error()
call f%destroy()

f = json_file(CDK_'{"x": [1,2,3]}',no_whitespace=.true.)
!f = json_file(CDK_'{"x": [1,2,3]}',no_whitespace=.true.) ! memory leak in gfortran?
call f%initialize(no_whitespace=.true.)
call f%deserialize(CDK_'{"x": [1,2,3]}')
call f%print(int(error_unit,IK))
write(error_unit,'(A)') ''
call check_for_error()
call f%destroy()

f = json_file(CDK_'{"y": [4,5,6]}',json)
!f = json_file(CDK_'{"y": [4,5,6]}',json) ! memory leak in gfortran?
call f%initialize(json)
call f%deserialize(CDK_'{"y": [4,5,6]}')
call f%print(int(error_unit,IK))
write(error_unit,'(A)') ''
call check_for_error()
Expand Down
4 changes: 3 additions & 1 deletion src/tests/jf_test_39.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ subroutine test_39(error_cnt)

do i = 1, size(tests)

json = json_file(trim(tests(i)),verbose=.true.,stop_on_error=.true.)
!json = json_file(trim(tests(i)),verbose=.true.,stop_on_error=.true.) ! memory leak in gfortran?
call json%initialize(verbose=.true.,stop_on_error=.true.)
call json%deserialize(trim(tests(i)))
call json%print(int(error_unit,IK))
write(error_unit,'(A)') ''
if (json%failed()) then
Expand Down
4 changes: 3 additions & 1 deletion src/tests/jf_test_41.F90
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ subroutine test_41(error_cnt)
write(error_unit,'(A)') ''
write(error_unit,'(A)') 'copying to json_file...'

f = json_file(p)
!f = json_file(p) ! memory leak in gfortran?
call f%initialize()
call f%add(p)

call f2%add(p2)
nullify(p2) ! data is now in f
Expand Down
3 changes: 2 additions & 1 deletion src/tests/jf_test_46.F90
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ subroutine test_46(error_cnt)
! now, json_file routines:
!---------------------------------

json_f = json_file(str)
!json_f = json_file(str) ! memory leak in gfortran?
call json_f%deserialize(str)

! unicode:
call json_f%get(CK_'not_there', ival, found, default=99_IK)
Expand Down
7 changes: 7 additions & 0 deletions src/tests/jf_test_50.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ subroutine test_50(error_cnt)
type(json_core) :: json
type(json_value),pointer :: p

write(error_unit,'(A)') ''
write(error_unit,'(A)') '================================='
write(error_unit,'(A)') ' EXAMPLE 50'
write(error_unit,'(A)') '================================='
write(error_unit,'(A)') ''

call json%initialize(compress_vectors = .true.) ! so it will print each col on one line

call json%create_object(p,'') !create the root
call json_value_add_real_vec_2d(json, p, CK_'Pcir', pcir, by_col=.true.)
call json%print(p)
call json%destroy(p)

error_cnt = 0

Expand Down