Skip to content

Commit

Permalink
Merge pull request #210 from VirtualPlanetaryLaboratory/dev
Browse files Browse the repository at this point in the history
valgrind test and yml file
  • Loading branch information
RoryBarnes authored Jan 13, 2022
2 parents ecd5515 + 455bd73 commit 375b264
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 10 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: valgrind

on:
release:
types: [published]

jobs:
valgrind:
name: Run Valgrind on Ubuntu
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python
id: setup_python
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: vplanet
environment-file: environment.yml
python-version: 3.8

- name: Install valgrind
id: install
if: steps.setup_python.outcome == 'success'
shell: bash -l {0}
run: |
sudo apt-get install valgrind
- name: Run valgrind test
if: steps.install.outcome == 'success'
shell: bash -l {0}
run: |
cd tests/
python -m unittest valgrind.py
37 changes: 27 additions & 10 deletions tests/valgrind.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
import os
import sys

subdir = [f.name for f in os.scandir('.') if f.is_dir()]
subdir = sorted([f.name for f in os.scandir('.') if f.is_dir()])

# First make debug
sys.stdout.write('Making VPLanet...')
print('Making VPLanet...')
sys.stdout.flush()
os.chdir('..')
subprocess.run(['make debug >& /dev/null'], shell=True)
os.chdir('tests')
os.chdir('../')
#print(os.getcwd())
#subprocess.run(['make opt >& /dev/null'], shell=True)
with open('make_log','w') as m:

subprocess.run('make opt',shell=True, stderr= m,stdout= m)
subprocess.run(['rm','make_log'])

os.chdir('tests/')

print('done.')

Expand All @@ -19,24 +25,35 @@
for sub in subdir:
tot_test += 1
sys.stdout.write(sub)
#sys.stdout.write("")
sys.stdout.flush()
os.chdir(sub)
fout = sub+'.valgrind'
cmd='valgrind --track-origins=yes ../../vplanet vpl.in >& '+fout
subprocess.run(cmd, shell=True)
fout = sub +'.valgrind'
#cmd='/usr/bin/valgrind --track-origins=yes ../../bin/vplanet vpl.in &> '+ fout
cmd='/usr/bin/valgrind --track-origins=yes ../../bin/vplanet vpl.in '

#print(cmd)
#cmd = cmd.split()

with open(fout,"w+") as f:
subprocess.run(cmd, shell=True,stdout=f,stderr=f)
f = open(fout, "r")
last_line = f.readlines()[-1]
#print(last_line)
f.close()
words = last_line.split()
n_errors = int(words[3])
if n_errors > 0:
tot_fail += 1
print(': '+repr(n_errors)+' error(s)')
os.chdir('..')
os.chdir('../')


sys.stdout.write('Done! ')
print('Done! ')

if (tot_fail == 0):
print('VPLanet is mem-check-clean!')
assert(True)
else:
print(repr(tot_fail)+'/'+repr(tot_test)+' test(s) failed.')
assert(False)

0 comments on commit 375b264

Please sign in to comment.