Tests: Use internal sed as external croaks on binary.

This commit is contained in:
Wilson Snyder 2020-10-14 09:30:15 -04:00
parent d4d3ae4dfc
commit 7e5f562500
4 changed files with 24 additions and 3 deletions

View File

@ -2079,6 +2079,7 @@ sub files_identical {
&& !/^-node:/
&& !/^dot [^\n]+\n/
&& !/^In file: .*\/sc_.*:\d+/
&& !/^libgcov.*/
} @l1;
@l1 = map {
s/(Internal Error: [^\n]+\.cpp):[0-9]+:/$1:#:/;
@ -2318,6 +2319,21 @@ sub write_wholefile {
my $fh = IO::File->new(">$filename") or die "%Error: $! writing $filename,";
print $fh $contents;
$fh->close;
delete $_File_Contents_Cache{$filename};
}
sub file_sed {
my $self = (ref $_[0]? shift : $Self);
my $infilename = shift;
my $outfilename = shift;
my $editcb = shift;
my $contents = $self->file_contents($infilename);
{
$_ = $contents;
$editcb->($contents);
$contents = $_;
}
$self->write_wholefile($outfilename, $contents);
}
#######################################################################

View File

@ -25,7 +25,9 @@ execute(
-r "$Self->{obj_dir}/saved.vltsv" or error("Saved.vltsv not created\n");
# Break the header
run(cmd => ["sed -i.bak 's/verilatorsave01/verilatorsavBAD/' $Self->{obj_dir}/saved.vltsv"]);
file_sed("$Self->{obj_dir}/saved.vltsv",
"$Self->{obj_dir}/saved.vltsv",
sub { s/verilatorsave01/verilatorsavBAD/g; });
execute(
all_run_flags => ['+save_restore=1'],

View File

@ -25,7 +25,9 @@ execute(
-r "$Self->{obj_dir}/saved.vltsv" or error("Saved.vltsv not created\n");
# Break the header
run(cmd => ["sed -i.bak 's/vltsaved/vltNOTed/' $Self->{obj_dir}/saved.vltsv"]);
file_sed("$Self->{obj_dir}/saved.vltsv",
"$Self->{obj_dir}/saved.vltsv",
sub { s/vltsaved/vltNOTed/g; });
execute(
all_run_flags => ['+save_restore=1'],

View File

@ -20,7 +20,8 @@ compile(
files_identical("$out_filename", $Self->{golden_filename});
run(cmd=>["sed 's/\\/\\/ lint_off/lint_off/g' $out_filename > $waiver_filename"]);
file_sed($out_filename, $waiver_filename,
sub { s/\/\/ lint_off/lint_off/g; });
compile(
v_flags2 => [$waiver_filename],