2 ################################################################################
4 ## Copyright (c) International Business Machines Corp., 2009 ##
6 ## This program is free software; you can redistribute it and/or modify ##
7 ## it under the terms of the GNU General Public License as published by ##
8 ## the Free Software Foundation; either version 2 of the License, or ##
9 ## (at your option) any later version. ##
11 ## This program is distributed in the hope that it will be useful, but ##
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
13 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
14 ## for more details. ##
16 ## You should have received a copy of the GNU General Public License ##
17 ## along with this program; if not, write to the Free Software ##
18 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
20 ################################################################################
22 # File : create_valgrind_check ##
24 # Usage: create_valgrind_check\ ##
25 # <LTP_COMMAND_FILE> <VALGRIND_CHECK_TYPE> ##
27 # Description: This is a simple perl script which will take ltp command file ##
28 # as input and then create a final command file while will have ##
29 # the following entries for each test tag: ##
30 # 1) <tag_name> <test_binary_name> ##
31 # 2) <tag_name_valgrind_check_type> <valgrind test_binary_name> ##
33 # Author: Subrata Modak <subrata@linux.vnet.ibm.com> ##
35 # History: Aug 23 2009 - Created - Subrata Modak. ##
36 ################################################################################
38 my $command_file = shift (@ARGV) || syntax
();
39 my $valgrind_check_type = shift (@ARGV) || syntax
();
42 print "syntax: create_valgrind_check\
43 <LTP_COMMAND_FILE> <VALGRIND_CHECK_TYPE>\n";
47 sub print_memory_leak_check
{
49 @sub_tag_and_actual_command = split(/\ /, $sub_line);
50 my $sub_token_counter = 0;
51 foreach my $sub_token (@sub_tag_and_actual_command) {
52 if ($sub_token_counter == 0 ) {#print the tagname now
53 print $sub_token . "_valgrind_memory_leak_check " .
54 " valgrind -q --leak-check=full --trace-children=yes ";
58 print " " . $sub_token . " ";
63 sub print_thread_concurrency_check
{
65 @sub_tag_and_actual_command = split(/\ /, $sub_line);
66 my $sub_token_counter = 0;
67 foreach my $sub_token (@sub_tag_and_actual_command) {
68 if ($sub_token_counter == 0 ) {#print the tagname now
69 print $sub_token . "_valgrind_thread_concurrency_check " .
70 " valgrind -q --tool=helgrind --trace-children=yes ";
74 print " " . $sub_token . " ";
79 open (FILE
, $command_file) || die "Cannot open file: $command_file\n";
80 while ($line = <FILE
>) {
85 if ($line =~ /^\n$/) {
89 print "$line\n"; #Print one instance for normal execution
91 if ($valgrind_check_type == 3) {
92 #Print for both Memory Leak and Thread Concurrency Checks
93 print_memory_leak_check
($line);
94 print_thread_concurrency_check
($line);
96 if ($valgrind_check_type == 2) {
97 #Print only for Thread concurrency Check
98 print_thread_concurrency_check
($line);
100 if ($valgrind_check_type == 1) {
101 #Print only for Memory leak Check
102 print_memory_leak_check
($line);