I would like to add Valgrind to my automated test suite, but as I understand it, Valgrind only tests the target binary according to the options that I supply for said binary. For instance, if I run:
valgrind --leak-check=yes ./target_bin -option1 option_arg
Valgrind will catch memory leaks in functions called when option1
is invoked; but if I run the same command with option2
instead of option1
, different functions are invoked and Valgrind will analyze those instead.
If I am going to add Valgrind to an automated test suite, do I need to write a bash script with every single permutation of my program's options, such as:
valgrind --leak-check=yes ./target_bin -option1 option_arg
valgrind --leak-check=yes ./target_bin -option2 option_arg
valgrind --leak-check=yes ./target_bin -option3 option_arg -option4
Or am I missing something super obvious in the Valgrind documentation? If the above solution is the correct answer, are there any ways of tracking these kinds of permutations? Because I can see this script getting very large very quickly
CodePudding user response:
Valgrind does not support this functionality because it's much easier to implement in shell scripts. You could do something like
for args in \
'-option1 option_arg' \
'-option2 option_arg' \
'-option3 option_arg -option4'; do
valgrind --leak-check=yes ./target_bin $args
done