xref: /aosp_15_r20/external/ltp/tools/create_valgrind_check.awk (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker#!/usr/bin/awk -f
2*49cdfc7eSAndroid Build Coastguard Worker#
3*49cdfc7eSAndroid Build Coastguard Worker#    Script for adding necessary valgrind calls before commands.
4*49cdfc7eSAndroid Build Coastguard Worker#
5*49cdfc7eSAndroid Build Coastguard Worker#    Copyright (C) 2012, Linux Test Project.
6*49cdfc7eSAndroid Build Coastguard Worker#
7*49cdfc7eSAndroid Build Coastguard Worker#    This program is free software; you can redistribute it and/or modify
8*49cdfc7eSAndroid Build Coastguard Worker#    it under the terms of the GNU General Public License as published by
9*49cdfc7eSAndroid Build Coastguard Worker#    the Free Software Foundation; either version 2 of the License, or
10*49cdfc7eSAndroid Build Coastguard Worker#    (at your option) any later version.
11*49cdfc7eSAndroid Build Coastguard Worker#
12*49cdfc7eSAndroid Build Coastguard Worker#    This program is distributed in the hope that it will be useful,
13*49cdfc7eSAndroid Build Coastguard Worker#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*49cdfc7eSAndroid Build Coastguard Worker#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*49cdfc7eSAndroid Build Coastguard Worker#    GNU General Public License for more details.
16*49cdfc7eSAndroid Build Coastguard Worker#
17*49cdfc7eSAndroid Build Coastguard Worker#    You should have received a copy of the GNU General Public License along
18*49cdfc7eSAndroid Build Coastguard Worker#    with this program; if not, write to the Free Software Foundation, Inc.,
19*49cdfc7eSAndroid Build Coastguard Worker#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20*49cdfc7eSAndroid Build Coastguard Worker#
21*49cdfc7eSAndroid Build Coastguard Worker# Ngie Cooper, April 2012
22*49cdfc7eSAndroid Build Coastguard Worker#
23*49cdfc7eSAndroid Build Coastguard Worker
24*49cdfc7eSAndroid Build Coastguard Worker# XXX: this script doesn't handle items that would be executed via pan with
25*49cdfc7eSAndroid Build Coastguard Worker# /bin/sh properly.
26*49cdfc7eSAndroid Build Coastguard WorkerNF && ! /^#/ {
27*49cdfc7eSAndroid Build Coastguard Worker	print
28*49cdfc7eSAndroid Build Coastguard Worker	if (CHECK_LEVEL == 1 || CHECK_LEVEL == 3) {
29*49cdfc7eSAndroid Build Coastguard Worker		s=$1 "_valgrind_memory_leak_check  valgrind -q --leak-check=full --trace-children=yes"
30*49cdfc7eSAndroid Build Coastguard Worker		for (i = 2; i <= NF; i++) {
31*49cdfc7eSAndroid Build Coastguard Worker			s = s " " $i
32*49cdfc7eSAndroid Build Coastguard Worker		}
33*49cdfc7eSAndroid Build Coastguard Worker		print s
34*49cdfc7eSAndroid Build Coastguard Worker	}
35*49cdfc7eSAndroid Build Coastguard Worker	if (CHECK_LEVEL == 2 || CHECK_LEVEL == 3) {
36*49cdfc7eSAndroid Build Coastguard Worker		s=$1 "_valgrind_thread_concurrency_check  valgrind -q --tool=helgrind --trace-children=yes"
37*49cdfc7eSAndroid Build Coastguard Worker		for (i = 2; i <= NF; i++) {
38*49cdfc7eSAndroid Build Coastguard Worker			s = s " " $i
39*49cdfc7eSAndroid Build Coastguard Worker		}
40*49cdfc7eSAndroid Build Coastguard Worker		print s
41*49cdfc7eSAndroid Build Coastguard Worker	}
42*49cdfc7eSAndroid Build Coastguard Worker}
43