use File::Temp;
sub _dummy_valgrind_code {
- my ($version) = @_;
+ my ($version, $body) = @_;
my $perl = $^X;
unless (-e $perl and -x $perl) {
}
}
+ if (defined $body) {
+ $body = "\n$body";
+ } else {
+ $body = '';
+ }
+
return <<" FAKE_VG";
#!$perl
if (\@ARGV == 1 && \$ARGV[0] eq '--version') {
print "valgrind-$version\n";
-}
+ exit 0;
+}$body
FAKE_VG
}
my $exe_name = $args{exe_name};
my $version = $args{version} || '3.1.0';
+ my $body = $args{body};
my $self = { };
$self->{tmp_dir} = File::Spec->catpath($vol, $dir, '');
}
- my $code = _dummy_valgrind_code($version);
+ my $code = _dummy_valgrind_code($version, $body);
return 'Could not generate the dummy valgrind executable' unless $code;
return 'Temporary file already exists' if -s $self->{tmp_file};