[Xfce4-commits] <midori:master> Set MIDORI_TEST to valgrind or callgrind to run memory checks

Christian Dywan noreply at xfce.org
Sat Dec 15 20:20:02 CET 2012


Updating branch refs/heads/master
         to bae4ccba8e57d20adf1bd3339dd804b39ab4ce22 (commit)
       from f7788bfb1dabd519b2de7457bc2bb62e76c6809e (commit)

commit bae4ccba8e57d20adf1bd3339dd804b39ab4ce22
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Dec 15 20:15:04 2012 +0100

    Set MIDORI_TEST to valgrind or callgrind to run memory checks

 wscript |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/wscript b/wscript
index 831e610..bcf2f9e 100644
--- a/wscript
+++ b/wscript
@@ -636,7 +636,40 @@ def shutdown ():
                     pass
             else:
                 Utils.pprint ('GREEN', label + '.......OK')
+                filename = test.unit_tests[label][0]
+                if not 'extension' in filename:
+                    continue
+                if is_mingw (Build.bld.env):
+                    filename += '.exe'
+                if os.environ.get ('MIDORI_TEST') == 'valgrind':
+                    args = ['valgrind', '-q', '--leak-check=no', '--num-callers=4', '--show-possibly-lost=no', '--undef-value-errors=yes', '--track-origins=yes', filename]
+                elif os.environ.get ('MIDORI_TEST') == 'callgrind':
+                    args = ['valgrind', '--tool=callgrind', '--callgrind-out-file=%s.callgrind' % filename, filename]
+                else:
+                    continue
+                try:
+                    if is_mingw (Build.bld.env):
+                        args.insert (0, 'wine')
+                    pp = subprocess.Popen (args, cwd=Build.bld.env['PREFIX'] + os.sep + 'bin', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+                    skip = False
+                    for line in iter(pp.stdout.readline, ''):
+                        if line[:2] != '==':
+                            continue
+                        if line == '':
+                            skip = False
+                        elif 'Conditional jump or move' in line:
+                            skip = True
+                        elif 'Uninitialised value was created by a stack allocation' in line:
+                            skip = True
+                        elif not skip:
+                            sys.stdout.write (line[9:])
+                except OSError:
+                    Utils.pprint ('YELLOW', 'Install valgrind to perform memory checks')
+                except KeyboardInterrupt:
+                    pass
 
+        if not 'MIDORI_TEST' in os.environ:
+            Utils.pprint ('BLUE', 'Set MIDORI_TEST to "valgrind" or "callgrind" to perform memory checks')
         # if test.num_tests_failed > 0 or test.num_tests_err > 0:
         #     sys.exit (1)
 


More information about the Xfce4-commits mailing list