testsuite: grep the output patterns only when needed
For some testcase, it is checked if the output contains or not
some given pattern, or we're checking the number of time a
pattern is present in the output.
This is done with grep and some glue.
But for most testcases there is nothing to check and this
grepping is just wasted CPU cycles.
Fix this by using the already known tags to see if we need to
do this grepping or not.
This speedup the testsuite by another 15%.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>