forked from VirtualPlanetaryLaboratory/vplanet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalgrind.py
58 lines (47 loc) · 1.33 KB
/
valgrind.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import subprocess
import sys
subdir = sorted([f.name for f in os.scandir('.') if f.is_dir()])
# First make debug
print('Making VPLanet...')
sys.stdout.flush()
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.")
tot_fail = 0
tot_test = 0
for sub in subdir:
tot_test += 1
sys.stdout.write(sub)
#sys.stdout.write("")
sys.stdout.flush()
os.chdir(sub)
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('../')
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)