Changeset 15719


Ignore:
Timestamp:
08/06/13 10:07:11 (12 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added valgrind procedure, to automatically check for memory leaks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/test/NightlyRun/runme.m

    r15499 r15719  
    2121%                      'gia'   : validation of gia tests
    2222%                      ...
    23 %      'procedure'     'check' : run the test (default)
    24 %                      'update': update the archive
     23%      'procedure'     'check' :   run the test (default)
     24%                      'update':   update the archive
     25%                      'valgrind': check for memory leaks (default value of md.debug.valgrind needs to be changed manually)
    2526%
    2627%   Usage:
     
    5657%GET procedure {{{
    5758procedure=getfieldvalue(options,'procedure','check');
    58 if ~ismember(procedure,{'check','update'})
     59if ~ismember(procedure,{'check','update','valgrind'})
    5960        disp('runme warning: procedure not supported, defaulting to test ''check''')
    6061        procedure='check';
     
    148149                        disp(sprintf(['File ./../Archives/' archive_name '.nc saved\n']));
    149150
     151                %CHECK for memory leaks?
     152                elseif strcmpi(procedure,'valgrind'),
     153                        fields = fieldnames(md.results);
     154                        for i=1:numel(fields)
     155                                if ~isfield(md.results.(fields{i}),'errlog'),
     156                                        disp(['Skipping ' fields{i}]);
     157                                        continue;
     158                                else
     159                                        disp(['Extracting results of ' fields{i}]);
     160                                end
     161                                errlog = cellstr(md.results.(fields{i}).errlog);
     162                                lines  = strfind(errlog,'definitely lost:');
     163                                lines  = find(~cellfun(@isempty,lines));
     164                                total  = 0;
     165                                for j=1:numel(lines)
     166                                        Line    = errlog(lines(j));
     167                                        Numbers = sscanf(Line{1},'==%i==   definitely lost: %s bytes in %i blocks',[1 Inf]);
     168                                        total   = total+ str2num(strrep(char(Numbers(2:end-1)),',',''));
     169                                end
     170                                if total==0,
     171                                        disp(sprintf(['SUCCESS difference: 0 < 0 test id: %i test name: %s field: valgrind'],id,id_string));
     172                                else
     173                                        disp(sprintf(['ERROR   difference: %i > 0 test id: %i test name: %s field: valgrind'],total,id,id_string));
     174                                        disp('STOP');
     175                                        return;
     176                                end
     177                        end
     178
    150179                %ELSE: CHECK TEST
    151180                else,
Note: See TracChangeset for help on using the changeset viewer.