Internal coverage: Cleanup some savable errors and coverage.

This commit is contained in:
Wilson Snyder 2020-10-13 19:26:16 -04:00
parent 3d8dc2774b
commit 8750352495
10 changed files with 175 additions and 10 deletions

View File

@ -42,9 +42,10 @@
// clang-format on
// CONSTANTS
static const char* const VLTSAVE_HEADER_STR
= "verilatorsave01\n"; ///< Value of first bytes of each file
static const char* const VLTSAVE_TRAILER_STR = "vltsaved"; ///< Value of last bytes of each file
/// Value of first bytes of each file (must be multiple of 8 bytes)
static const char* const VLTSAVE_HEADER_STR = "verilatorsave01\n";
/// Value of last bytes of each file (must be multiple of 8 bytes)
static const char* const VLTSAVE_TRAILER_STR = "vltsaved";
//=============================================================================
//=============================================================================
@ -64,10 +65,10 @@ VerilatedDeserialize& VerilatedDeserialize::readAssert(const void* __restrict da
size_t size) VL_MT_UNSAFE_ONE {
if (VL_UNLIKELY(readDiffers(datap, size))) {
std::string fn = filename();
std::string msg
= "Can't deserialize save-restore file as was made from different model:" + filename();
std::string msg = "Can't deserialize save-restore file as was made from different model: "
+ filename();
VL_FATAL_MT(fn.c_str(), 0, "", msg.c_str());
close();
// Die before we close() as close would infinite loop
}
return *this; // For function chaining
}
@ -88,9 +89,11 @@ void VerilatedDeserialize::header() VL_MT_UNSAFE_ONE {
if (VL_UNLIKELY(os.readDiffers(VLTSAVE_HEADER_STR, strlen(VLTSAVE_HEADER_STR)))) {
std::string fn = filename();
std::string msg
= std::string("Can't deserialize; file has wrong header signature: ") + filename();
= std::string(
"Can't deserialize; file has wrong header signature, or file not found: ")
+ filename();
VL_FATAL_MT(fn.c_str(), 0, "", msg.c_str());
close();
// Die before we close() as close would infinite loop
}
os.read(Verilated::serialized1Ptr(), Verilated::serialized1Size());
os.read(Verilated::serialized2Ptr(), Verilated::serialized2Size());
@ -109,7 +112,7 @@ void VerilatedDeserialize::trailer() VL_MT_UNSAFE_ONE {
std::string msg = std::string("Can't deserialize; file has wrong end-of-file signature: ")
+ filename();
VL_FATAL_MT(fn.c_str(), 0, "", msg.c_str());
close();
// Die before we close() as close would infinite loop
}
}

View File

@ -6,11 +6,17 @@
module t (/*AUTOARG*/
// Inputs
clk
clk, model
);
/*verilator no_inline_module*/ // So we'll get hiearachy we can test
input clk;
// Parameter so we can test for different model error
parameter MODEL_WIDTH = 10;
input [MODEL_WIDTH-1:0] model;
initial $write("Model width = %d\n", MODEL_WIDTH);
sub sub (/*AUTOINST*/
// Inputs
.clk (clk));

View File

@ -0,0 +1,4 @@
Model width = 40
Restoring model from 'obj_vlt/t_savable_format1_bad/saved.vltsv'
%Error: obj_vlt/t_savable_format1_bad/saved.vltsv:0: Can't deserialize save-restore file as was made from different model: obj_vlt/t_savable_format1_bad/saved.vltsv
Aborting...

View File

@ -0,0 +1,39 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1);
top_filename("t/t_savable.v");
compile(
v_flags2 => ["--savable"],
save_time => 500,
);
execute(
check_finished => 0,
all_run_flags => ['+save_time=500'],
);
-r "$Self->{obj_dir}/saved.vltsv" or error("Saved.vltsv not created\n");
compile(
v_flags2 => ["--savable -GMODEL_WIDTH=40"],
save_time => 500,
);
execute(
all_run_flags => ['+save_restore=1'],
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;

View File

@ -0,0 +1,4 @@
Model width = 10
Restoring model from 'obj_vlt/t_savable_format2_bad/saved.vltsv'
%Error: obj_vlt/t_savable_format2_bad/saved.vltsv:0: Can't deserialize; file has wrong header signature, or file not found: obj_vlt/t_savable_format2_bad/saved.vltsv
Aborting...

View File

@ -0,0 +1,37 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1);
top_filename("t/t_savable.v");
compile(
v_flags2 => ["--savable"],
save_time => 500,
);
execute(
check_finished => 0,
all_run_flags => ['+save_time=500'],
);
-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"]);
execute(
all_run_flags => ['+save_restore=1'],
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;

View File

@ -0,0 +1,4 @@
Model width = 10
Restoring model from 'obj_vlt/t_savable_format3_bad/saved.vltsv'
%Error: obj_vlt/t_savable_format3_bad/saved.vltsv:0: Can't deserialize; file has wrong end-of-file signature: obj_vlt/t_savable_format3_bad/saved.vltsv
Aborting...

View File

@ -0,0 +1,37 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1);
top_filename("t/t_savable.v");
compile(
v_flags2 => ["--savable"],
save_time => 500,
);
execute(
check_finished => 0,
all_run_flags => ['+save_time=500'],
);
-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"]);
execute(
all_run_flags => ['+save_restore=1'],
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;

View File

@ -0,0 +1,4 @@
Model width = 10
Restoring model from 'obj_vlt/t_savable_open_bad/saved.vltsv'
%Error: obj_vlt/t_savable_open_bad/saved.vltsv:0: Can't deserialize; file has wrong header signature, or file not found: obj_vlt/t_savable_open_bad/saved.vltsv
Aborting...

View File

@ -0,0 +1,27 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1);
top_filename("t/t_savable.v");
compile(
v_flags2 => ["--savable"],
save_time => 500,
);
execute(
all_run_flags => ['+save_restore=1'],
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;