Advertisement
Guest User

runValgrind

a guest
Oct 30th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -ne 2 ]; then
  4.         echo "incorrect number of command line arguments" >&2
  5.         exit 1
  6. fi
  7.  
  8. cat $1 | while read nextLine; do
  9.         if [ ! -r "$nextLine.in" ]; then
  10.                 echo "file not found" >&2
  11.                 exit 1
  12.         fi
  13.         output=`valgrind --log-fd=1 --leak-check=full --show-reachable=yes $2 < $nextLine.in`
  14.         errorCheck=`echo "$output" | tail -1 | egrep -c '.*ERROR SUMMARY: [1-9]* .'`
  15.         if [ $errorCheck -eq 1 ]; then
  16.                 echo "Memory leak detected: $nextLine.in"
  17.                 echo "$output"
  18.         fi
  19. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement