Commit aa90e858 authored by norvell's avatar norvell
Browse files

Merge branch...

Merge branch '286-add-dry-run-memory-measurement-to-catch-unbalanced-malloc-free-in-smoke-test' into 'main'

Modify smoke_test.sh to include dry-run of memory analysis, finding unbalanced memory alloc/dealloc

See merge request !384
parents 67e4ff90 bee66278
Loading
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -57,8 +57,20 @@ cfg=./scripts/config/ci_linux.json
dly_profile=./scripts/dly_error_profiles/dly_error_profile_10.dat

if [ $BUILD -eq 1 ];then
	# Enable memory macros to find unbalanced memory allocations/deallocations
	# Does not implement full memory analysis
	make clean
	
    # Replace free -> free_, malloc -> malloc_, calloc -> calloc_
	./scripts/prepare_mem_dryrun.py

	# Enable WMOPS and disable DEBUGGING
	sed -i.bak -e "s/\/\*\s*\(#define\s*WMOPS\)\s*\*\//\1/g" lib_com/options.h
	sed -i.bak -e "s/\/\/\s*\(#define\s*WMOPS\)/\1/g"        lib_com/options.h
#	sed -i.bak -e "s/\s*\(#define\s*DEBUGGING\)/\/\*\1*\//g" lib_com/options.h

	make all -j

fi

./scripts/runIvasCodec.py -p $cfg -U 1 $WORKERS | tee smoke_test_output.txt
+1 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@
#define STABILIZE_GIPD                                  /* FhG: Contribution 22: gIPD stabilization */
#define FIX_292_VBAP_CALLOC_REMOVAL                     /* Nokia: Fixes issue 292 by removing the remnant callocs */
#define FIX_293_EXT_RENDERER_CLI                        /* FhG: Fix bugs in external renderer CLI */
#define FIX_268                                         /* Issue 268: Add low cost dry-run of memory analysis */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+3 −0
Original line number Diff line number Diff line
@@ -45,6 +45,9 @@
#include "debug.h"
#endif
#include "jbm_jb4_inputbuffer.h"
#ifdef FIX_268
#include "wmc_auto.h"
#endif

#define WMC_TOOL_SKIP

+29 −0
Original line number Diff line number Diff line
#!/bin/python3

import re, os, fnmatch

sub = ['free','malloc','calloc']
dirs = ['./lib_com','./lib_enc','./lib_dec','./lib_rend']
suffix = '*.c'

skip = 0

for d in dirs:
    print(d)
    for path, ds, files in os.walk(d):
        for filename in fnmatch.filter(files, suffix):
            fileIn = os.path.join(path, filename)
            with open(fileIn, 'r') as f_in:
                lines = f_in.readlines()
            with open(fileIn, 'w') as f_out:
                for line in lines:
                    if re.search(r'#define\W+WMC_TOOL_SKIP', line):
                        skip = 1
                    elif re.search(r'#undef\W+WMC_TOOL_SKIP', line):
                        skip = 0
                    else:
                        if not skip:
                            for s in sub:
                                line = re.sub(r'\b%s\b' % (s), '%s' % (s+'_'), line)
                    f_out.write(line)
     
+28 −0
Original line number Diff line number Diff line
#!/bin/python3

import argparse
import re

parser = argparse.ArgumentParser(description='Substitute strings in files, skipping blocks in WMC_TOOL_SKIP')
parser.add_argument('input',type=str,help='C source file')
parser.add_argument('target',type=str,help='Target string to replace')
parser.add_argument('dest',type=str,help='Destination string to insert')
args = parser.parse_args()
fileIn  = args.input
target  = args.target
dest    = args.dest

skip = 0

with open(fileIn, 'r') as f_in:
    lines = f_in.readlines()
with open(fileIn, 'w') as f_out:
    for line in lines:
        if re.search(r'#define\W+WMC_TOOL_SKIP', line):
            skip = 1
        elif re.search(r'#undef\W+WMC_TOOL_SKIP', line):
            skip = 0
        else:
            if not skip:
                line = re.sub(r'\b%s\b' % (target), '%s' % (dest), line)
        f_out.write(line)
 No newline at end of file