From 7fe49de4204c20c30c30bac6fd8cddda83db4a6e Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 4 Jun 2020 20:23:55 -0400 Subject: [PATCH] Tests: Tests to fix misc internal coverage holes. --- nodist/code_coverage.dat | 13 ++++++++++--- src/V3Trace.cpp | 2 +- test_regress/t/t_f_bad.out | 2 ++ test_regress/t/t_f_bad.pl | 20 ++++++++++++++++++++ test_regress/t/t_flag_define.pl | 2 +- test_regress/t/t_flag_define.v | 10 ++++++++++ test_regress/t/t_flag_main_sc_bad.out | 2 ++ test_regress/t/t_flag_main_sc_bad.pl | 23 +++++++++++++++++++++++ test_regress/t/t_flag_nofile_bad.out | 1 + test_regress/t/t_flag_nofile_bad.pl | 21 +++++++++++++++++++++ test_regress/t/t_flag_verilate.pl | 2 +- test_regress/t/t_flag_werror_bad3.out | 1 + test_regress/t/t_flag_werror_bad3.pl | 22 ++++++++++++++++++++++ test_regress/t/t_flag_woff_bad.out | 1 + test_regress/t/t_flag_woff_bad.pl | 20 ++++++++++++++++++++ test_regress/t/t_flag_wwarn_bad.out | 1 + test_regress/t/t_flag_wwarn_bad.pl | 22 ++++++++++++++++++++++ test_regress/t/t_func_return_bad.out | 21 +++++++++++++++------ test_regress/t/t_func_return_bad.v | 10 ++++++++++ test_regress/t/t_increment_bad.pl | 0 20 files changed, 184 insertions(+), 12 deletions(-) create mode 100644 test_regress/t/t_f_bad.out create mode 100755 test_regress/t/t_f_bad.pl create mode 100644 test_regress/t/t_flag_main_sc_bad.out create mode 100755 test_regress/t/t_flag_main_sc_bad.pl create mode 100644 test_regress/t/t_flag_nofile_bad.out create mode 100755 test_regress/t/t_flag_nofile_bad.pl create mode 100644 test_regress/t/t_flag_werror_bad3.out create mode 100755 test_regress/t/t_flag_werror_bad3.pl create mode 100644 test_regress/t/t_flag_woff_bad.out create mode 100755 test_regress/t/t_flag_woff_bad.pl create mode 100644 test_regress/t/t_flag_wwarn_bad.out create mode 100755 test_regress/t/t_flag_wwarn_bad.pl mode change 100644 => 100755 test_regress/t/t_increment_bad.pl diff --git a/nodist/code_coverage.dat b/nodist/code_coverage.dat index 49d6535ec..252956799 100644 --- a/nodist/code_coverage.dat +++ b/nodist/code_coverage.dat @@ -21,8 +21,8 @@ source_globs("src/*.cpp", "include/*/*.c", ); -remove_source("/usr/include/*"); -remove_source("/usr/lib/*"); +# Note *'s are removed when using fastcov +remove_source("/usr/*"); remove_source("*/include/sysc/*"); remove_source("*/V3ClkGater.cpp"); remove_source("*/V3ClkGater.h"); @@ -42,6 +42,13 @@ remove_source("*examples/*"); # Would just be removed with remove_source in later step remove_gcda_regexp(qr!test_regress/.*/(Vt_|Vtop_).*\.gcda!); -exclude_line_regexp(qr/(\bv3fatalSrc\b|\bfatalSrc\b|\bVL_UNCOVERABLE\b|\bVL_FATAL|\bUASSERT|\bERROR_RSVD_WORD\bV3ERROR_NA)/); +exclude_line_regexp(qr/(\bv3fatalSrc\b + |\bfatalSrc\b + |\bVL_UNCOVERABLE\b + |\bVL_FATAL + |\bUASSERT + |\bERROR_RSVD_WORD + |\bV3ERROR_NA + |\bUINFO\b)/x); 1; diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index e1fd88052..de8e2e50d 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -511,7 +511,7 @@ private: } else if (type == AstCFuncType::TRACE_CHANGE) { registration += "Chg"; } else { - funcp->v3fatal("Don't know how to register this type of function"); + funcp->v3fatalSrc("Don't know how to register this type of function"); } registration += "Cb(&" + protect(name) + ", __VlSymsp);\n"; AstCStmt* const stmtp = new AstCStmt(flp, registration); diff --git a/test_regress/t/t_f_bad.out b/test_regress/t/t_f_bad.out new file mode 100644 index 000000000..5de3d32b9 --- /dev/null +++ b/test_regress/t/t_f_bad.out @@ -0,0 +1,2 @@ +%Error: Cannot open -f command file: file_will_not_exist.vc +%Error: Exiting due to diff --git a/test_regress/t/t_f_bad.pl b/test_regress/t/t_f_bad.pl new file mode 100755 index 000000000..bebe33c0c --- /dev/null +++ b/test_regress/t/t_f_bad.pl @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2008 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); + +lint( + verilator_flags2 => ["--lint-only -f file_will_not_exist.vc"], + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_flag_define.pl b/test_regress/t/t_flag_define.pl index f20d08a16..35f485834 100755 --- a/test_regress/t/t_flag_define.pl +++ b/test_regress/t/t_flag_define.pl @@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di scenarios(vlt => 1); compile( - v_flags2 => ["-f t/t_flag_define.vc"], + v_flags2 => ["-f t/t_flag_define.vc -DCMD_DEF -DCMD_UNDEF -UCMD_UNDEF +define+CMD_DEF2"], ); execute( diff --git a/test_regress/t/t_flag_define.v b/test_regress/t/t_flag_define.v index f837114b6..1c1073eb4 100644 --- a/test_regress/t/t_flag_define.v +++ b/test_regress/t/t_flag_define.v @@ -108,6 +108,16 @@ module t; $write("%%Error: Missing define\n"); $stop; `endif +`ifndef CMD_DEF + $write("%%Error: Missing define\n"); $stop; +`endif +`ifndef CMD_DEF2 + $write("%%Error: Missing define\n"); $stop; +`endif +`ifdef CMD_UNDEF + $write("%%Error: Extra define\n"); $stop; +`endif + $write("*-* All Finished *-*\n"); $finish; end diff --git a/test_regress/t/t_flag_main_sc_bad.out b/test_regress/t/t_flag_main_sc_bad.out new file mode 100644 index 000000000..aa5c05318 --- /dev/null +++ b/test_regress/t/t_flag_main_sc_bad.out @@ -0,0 +1,2 @@ +%Error: --main not usable with SystemC. Suggest see examples for sc_main(). +%Error: Exiting due to diff --git a/test_regress/t/t_flag_main_sc_bad.pl b/test_regress/t/t_flag_main_sc_bad.pl new file mode 100755 index 000000000..8c8eb97ca --- /dev/null +++ b/test_regress/t/t_flag_main_sc_bad.pl @@ -0,0 +1,23 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2019 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); + +compile( + verilator_flags2 => ['--exe --build --main --sc'], + verilator_make_cmake => 0, + verilator_make_gmake => 0, + make_main => 0, + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_flag_nofile_bad.out b/test_regress/t/t_flag_nofile_bad.out new file mode 100644 index 000000000..f73aa067d --- /dev/null +++ b/test_regress/t/t_flag_nofile_bad.out @@ -0,0 +1 @@ +%Error: verilator: No Input Verilog file specified on command line, see verilator --help for more information diff --git a/test_regress/t/t_flag_nofile_bad.pl b/test_regress/t/t_flag_nofile_bad.pl new file mode 100755 index 000000000..d7a09e4a2 --- /dev/null +++ b/test_regress/t/t_flag_nofile_bad.pl @@ -0,0 +1,21 @@ +#!/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); + +run(cmd => ["../bin/verilator --lint-only"], + fails => 1, + logfile => "$Self->{obj_dir}/sim.log", + expect_filename => $Self->{golden_filename}, + verilator_run => 1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_flag_verilate.pl b/test_regress/t/t_flag_verilate.pl index 3a709c0f0..59b78738a 100755 --- a/test_regress/t/t_flag_verilate.pl +++ b/test_regress/t/t_flag_verilate.pl @@ -48,7 +48,7 @@ compile( # Don't call cmake nor gmake from driver.pl. Just build here verilator_make_gmake => 0, verilator_flags2 => ['--exe --cc --build --no-verilate', '../' . $Self->{main_filename}, - '--debugi 1 --dump-tree'], + '--debugi 1 --dump-tree --dump-tree-addrids'], ); # The previous run must not verilated, only build is expected. diff --git a/test_regress/t/t_flag_werror_bad3.out b/test_regress/t/t_flag_werror_bad3.out new file mode 100644 index 000000000..8b2a23cf5 --- /dev/null +++ b/test_regress/t/t_flag_werror_bad3.out @@ -0,0 +1 @@ +%Error: Unknown warning specified: -Werror-NOSUCHERRORASTHIS diff --git a/test_regress/t/t_flag_werror_bad3.pl b/test_regress/t/t_flag_werror_bad3.pl new file mode 100755 index 000000000..d031c654f --- /dev/null +++ b/test_regress/t/t_flag_werror_bad3.pl @@ -0,0 +1,22 @@ +#!/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_flag_werror.v"); + +lint( + fails => 1, + verilator_flags => [qw(-cc -Werror-NOSUCHERRORASTHIS)], + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_flag_woff_bad.out b/test_regress/t/t_flag_woff_bad.out new file mode 100644 index 000000000..25c278a31 --- /dev/null +++ b/test_regress/t/t_flag_woff_bad.out @@ -0,0 +1 @@ +%Error: Unknown warning specified: -Wno-NOSUCHERRORASTHIS diff --git a/test_regress/t/t_flag_woff_bad.pl b/test_regress/t/t_flag_woff_bad.pl new file mode 100755 index 000000000..d1c151c64 --- /dev/null +++ b/test_regress/t/t_flag_woff_bad.pl @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2008 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); + +lint( + verilator_flags2 => ["--lint-only -Wno-NOSUCHERRORASTHIS"], + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_flag_wwarn_bad.out b/test_regress/t/t_flag_wwarn_bad.out new file mode 100644 index 000000000..4913b9bb2 --- /dev/null +++ b/test_regress/t/t_flag_wwarn_bad.out @@ -0,0 +1 @@ +%Error: Unknown warning specified: -Wwarn-NOSUCHERRORASTHIS diff --git a/test_regress/t/t_flag_wwarn_bad.pl b/test_regress/t/t_flag_wwarn_bad.pl new file mode 100755 index 000000000..541ce84cf --- /dev/null +++ b/test_regress/t/t_flag_wwarn_bad.pl @@ -0,0 +1,22 @@ +#!/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_flag_werror.v"); + +lint( + fails => 1, + verilator_flags => [qw(-cc -Wwarn-NOSUCHERRORASTHIS)], + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_func_return_bad.out b/test_regress/t/t_func_return_bad.out index 952689dc5..64a547a1a 100644 --- a/test_regress/t/t_func_return_bad.out +++ b/test_regress/t/t_func_return_bad.out @@ -1,10 +1,19 @@ -%Error: t/t_func_return_bad.v:10:7: Return isn't underneath a task or function - 10 | return; +%Error: t/t_func_return_bad.v:10:7: Return underneath a task shouldn't have return value + 10 | return 1; | ^~~~~~ -%Error: t/t_func_return_bad.v:11:7: continue isn't underneath a loop - 11 | continue; +%Error: t/t_func_return_bad.v:13:7: Return underneath a function should have return value + 13 | return; + | ^~~~~~ +%Error: t/t_func_return_bad.v:17:7: Return isn't underneath a task or function + 17 | return; + | ^~~~~~ +%Error: t/t_func_return_bad.v:18:7: continue isn't underneath a loop + 18 | continue; | ^~~~~~~~ -%Error: t/t_func_return_bad.v:12:7: break isn't underneath a loop - 12 | break; +%Error: t/t_func_return_bad.v:19:7: break isn't underneath a loop + 19 | break; | ^~~~~ +%Error: t/t_func_return_bad.v:22:7: disable isn't underneath a begin with name: 'foo' + 22 | disable foo; + | ^~~~~~~ %Error: Exiting due to diff --git a/test_regress/t/t_func_return_bad.v b/test_regress/t/t_func_return_bad.v index 34cba2533..bbdcf6ffd 100644 --- a/test_regress/t/t_func_return_bad.v +++ b/test_regress/t/t_func_return_bad.v @@ -6,9 +6,19 @@ module t (/*AUTOARG*/); + task t1; + return 1; // Shouldn't return value + endtask + function int f1; + return; // Should return value + endfunction + initial begin return; // Not under function continue; // Not under loop break; // Not under loop + begin : foo + end + disable foo; // Disabling outside block end endmodule diff --git a/test_regress/t/t_increment_bad.pl b/test_regress/t/t_increment_bad.pl old mode 100644 new mode 100755