Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #!/bin/bash
  2. #
  3. # This is a simple script used to test libdom memory leakage.
  4. # Usage:
  5. # You should firstly run "run-test.sh", which will genrate a test output directory. In that
  6. # directory, there are C source files and corresponding executables.
  7. # Go to the test output directory. For example , for core, level 1, it is output/level1/core
  8. # And run this script as ../../../leak-test.sh "log-file"
  9. #
  10. #  This file is part of libdom test suite.
  11. #  Licensed under the MIT License,
  12. #                 http://www.opensource.org/licenses/mit-license.php
  13. #  Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
  14.  
  15. log=$1;
  16. totla=0;
  17. leak=0;
  18. ok=0;
  19. while read f; do
  20.         #Test defnitely lost
  21.         echo -n "$f: " >&3;
  22.         echo -n "$f: ";
  23.         dl=$(valgrind "$f" 2>&1 | grep "definitely lost" | sed -e 's/definitely lost//g' -e 's/bytes in//g' -e 's/blocks.//g' -e 's/^.*://g'  -e 's/ //g' -e 's/,//g');
  24.         pl=$(valgrind "$f" 2>&1 | grep "possibly lost" | sed -e 's/possibly lost//g' -e 's/bytes in//g' -e 's/blocks.//g' -e 's/^.*://g'  -e 's/ //g' -e 's/,//g');
  25.  
  26.         total=$((total+1));
  27.         if [ "$dl" -eq "00" -a "$pl" -eq "00" ]; then
  28.                 echo "ok..."  >&3;
  29.                 echo "ok...";
  30.                 ok=$((ok+1));
  31.         else
  32.                 echo "leaked!" >&3;
  33.                 echo "leaked!";
  34.                 leak=$((leak+1));
  35.         fi
  36.  
  37. done 3>"$log" < <(find ./ -perm -o=x  -type f -print);
  38.  
  39. echo "Total: $total" >>"$log";
  40. echo "Leak:  $leak" >>"$log";
  41. echo "Ok:        $ok" >>"$log";
  42.  
  43. echo "Total: $total";
  44. echo "Leak:  $leak";
  45. echo "Ok:        $ok";
  46.