1 |
#!/usr/bin/env python |
2 |
|
3 |
# This script runs LCOV to generate coverage testing results from the main CUnit test suites |
4 |
# implemented for ASCEND currently. |
5 |
|
6 |
LCOV="/usr/local/bin/lcov" |
7 |
GENHTML='/usr/local/bin/genhtml' |
8 |
SCONS_CALL=["scons","-j4","MALLOC_DEBUG=1","GCOV=1","CC=gcc","CXX=g++","test","ascend","models","solvers"] |
9 |
|
10 |
import os |
11 |
PREFIX=os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"..")) |
12 |
#print "PREFIX=",PREFIX |
13 |
ORIG=os.getcwd() |
14 |
os.chdir(PREFIX) |
15 |
|
16 |
DEVNULL = open(os.devnull,'w') |
17 |
|
18 |
tests = { |
19 |
'general':[ |
20 |
'general_color','general_dstring','general_hashpjw' |
21 |
,'general_list','general_listio','general_mem','general_pool' |
22 |
,'general_pairlist' |
23 |
,'general_pretty','general_stack','general_table','general_tm_time' |
24 |
,'general_ospath','general_env','general_ltmatrix','general_ascMalloc' |
25 |
],'utilities':[ |
26 |
'utilities_ascEnvVar','utilities_ascPrint' |
27 |
,'utilities_ascSignal','utilities_readln','utilities_set' |
28 |
,'utilities_error' |
29 |
],'linear':['linear_qrrank','linear_mtx'] |
30 |
,'compiler':[ |
31 |
'compiler_basics','compiler_expr','compiler_fixfree','compiler_fixassign' |
32 |
],'packages':['packages_defaultall'] |
33 |
,'solver':[ |
34 |
'solver_slv_common','solver_slvreq','solver_qrslv' |
35 |
,'solver_fprops','solver_lrslv' #'solver_ipopt', |
36 |
],'integrator':['integrator_lsode'] |
37 |
} |
38 |
|
39 |
import subprocess |
40 |
LCOV_STEM=[LCOV,'-d',PREFIX,'--no-external','--exclude','\<stdout\>'] |
41 |
LCOV_CD=LCOV_STEM + ['-c'] |
42 |
# clean |
43 |
print "CLEANING UP" |
44 |
subprocess.check_call(SCONS_CALL + ['-c'],stdout=DEVNULL) |
45 |
|
46 |
#build |
47 |
print "BUILD" |
48 |
subprocess.check_call(SCONS_CALL,stdout=DEVNULL,stderr=DEVNULL) |
49 |
|
50 |
if 0: |
51 |
#baseline |
52 |
print "BASELINE" |
53 |
F_BASELINE = 'mycov-0.info' |
54 |
mycall = LCOV_CD + ['-i','-o',F_BASELINE] |
55 |
#print "CALL:",mycall |
56 |
subprocess.check_call(mycall,stdout=DEVNULL) |
57 |
else: |
58 |
print "ZERO" |
59 |
mycall = LCOV_STEM + ['-z'] |
60 |
subprocess.check_call(mycall,stdout=DEVNULL) |
61 |
|
62 |
myenv = os.environ.copy() |
63 |
myenv['ASCENDLIBRARY']='models:solvers/qrslv:solvers/ipopt:solvers/lrslv' |
64 |
myenv['LD_LIBRARY_PATH']='.' |
65 |
|
66 |
for t in tests: |
67 |
print "TEST '%s'" % (t,) |
68 |
print " ".join(tests[t]) |
69 |
subprocess.check_call(['test/test']+tests[t],env=myenv,stdout=DEVNULL,stderr=DEVNULL) |
70 |
F = 'mycov-%s.info' % (t,) |
71 |
subprocess.check_call(LCOV_CD + ['-o',F,'-t',t],stdout=DEVNULL) |
72 |
F1 = 'mycov-%s-1.info' % (t,) |
73 |
subprocess.check_call([LCOV,'-r',F,'*stdout*','-o',F1],stdout=DEVNULL) |
74 |
|
75 |
subprocess.check_call([GENHTML |
76 |
,'-p',PREFIX |
77 |
,'-o','lcov-html' |
78 |
,'-t','ASCEND - CUnit test coverage' |
79 |
] + ['mycov-%s-1.info'%(t,) for t in tests] |
80 |
) |
81 |
|
82 |
os.chdir(ORIG) |
83 |
|