From 46f719ceaaa658a2c51cf974b548b635fc276593 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 13 May 2023 20:15:03 -0400 Subject: [PATCH] Tests: Fix some coverage holes --- test_regress/t/t_array_pattern_bad3.out | 13 ++++++++++++ test_regress/t/t_array_pattern_bad3.pl | 19 +++++++++++++++++ test_regress/t/t_array_pattern_bad3.v | 25 +++++++++++++++++++++++ test_regress/t/t_clocked_release_combo.pl | 2 +- test_regress/t/t_dist_warn_coverage.pl | 7 +++---- test_regress/t/t_dpi_import_mix_bad.out | 4 ++++ test_regress/t/t_dpi_import_mix_bad.pl | 19 +++++++++++++++++ test_regress/t/t_dpi_import_mix_bad.v | 18 ++++++++++++++++ 8 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 test_regress/t/t_array_pattern_bad3.out create mode 100755 test_regress/t/t_array_pattern_bad3.pl create mode 100644 test_regress/t/t_array_pattern_bad3.v create mode 100644 test_regress/t/t_dpi_import_mix_bad.out create mode 100755 test_regress/t/t_dpi_import_mix_bad.pl create mode 100644 test_regress/t/t_dpi_import_mix_bad.v diff --git a/test_regress/t/t_array_pattern_bad3.out b/test_regress/t/t_array_pattern_bad3.out new file mode 100644 index 000000000..dd393b336 --- /dev/null +++ b/test_regress/t/t_array_pattern_bad3.out @@ -0,0 +1,13 @@ +%Error: t/t_array_pattern_bad3.v:20:15: Assignment pattern key used multiple times: 1 + : ... In instance t + 20 | 1: '1}; + | ^ +%Error: t/t_array_pattern_bad3.v:21:13: Assignment pattern with too many elements + : ... In instance t + 21 | arr = '{'0, '1, '0, '1}; + | ^~ +%Error: t/t_array_pattern_bad3.v:22:13: Assignment pattern missed initializing elements: 2 + : ... In instance t + 22 | arr = '{'0, '1}; + | ^~ +%Error: Exiting due to diff --git a/test_regress/t/t_array_pattern_bad3.pl b/test_regress/t/t_array_pattern_bad3.pl new file mode 100755 index 000000000..a60503a1f --- /dev/null +++ b/test_regress/t/t_array_pattern_bad3.pl @@ -0,0 +1,19 @@ +#!/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(linter => 1); + +lint( + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_array_pattern_bad3.v b/test_regress/t/t_array_pattern_bad3.v new file mode 100644 index 000000000..a646ecca9 --- /dev/null +++ b/test_regress/t/t_array_pattern_bad3.v @@ -0,0 +1,25 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2018 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +// bug1364 + +module t (/*AUTOARG*/ + // Inputs + clk, res + ); + input clk; + input res; + + int arr[3]; + initial begin + arr = '{default: '0, + 1: '0, + 1: '1}; // Bad + arr = '{'0, '1, '0, '1}; // Bad, too many + arr = '{'0, '1}; // Bad, too few + end + +endmodule diff --git a/test_regress/t/t_clocked_release_combo.pl b/test_regress/t/t_clocked_release_combo.pl index fcd9221f5..859050d63 100755 --- a/test_regress/t/t_clocked_release_combo.pl +++ b/test_regress/t/t_clocked_release_combo.pl @@ -2,7 +2,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } # DESCRIPTION: Verilator: Verilog Test driver/expect definition # -# Copyright 2023 by Antmicro Ltd. This program is free software; you +# Copyright 2023 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. diff --git a/test_regress/t/t_dist_warn_coverage.pl b/test_regress/t/t_dist_warn_coverage.pl index 234e2bce3..bddd75ed5 100755 --- a/test_regress/t/t_dist_warn_coverage.pl +++ b/test_regress/t/t_dist_warn_coverage.pl @@ -38,14 +38,11 @@ foreach my $s ( 'Array initialization has too few elements, need element ', 'Assert not allowed under another assert', 'Assigned pin is neither input nor output', - 'Assignment pattern key used multiple times: ', 'Assignment pattern with no members', - 'Assignment pattern with too many elements', 'Attempted parameter setting of non-parameter: Param ', 'Can\'t find typedef: ', 'Can\'t find varpin scope of ', 'Can\'t resolve module reference: \'', - 'Cannot mix DPI import, DPI export, class methods, and/or public ', 'Cannot write preprocessor output: ', 'Circular logic when ordering code (non-cutable edge loop)', 'Deferred assertions must use \'#0\' (IEEE 1800-2017 16.4)', @@ -161,12 +158,14 @@ sub check { print(" Line is: ", $line, "\n") if $Debug; } } + print "\n"; for my $msg (sort keys %Suppressed) { if (!$used_suppressed{$msg}) { print "Suppression not used: '$msg'\n"; } - } + } + print "\n"; } sub read_messages { diff --git a/test_regress/t/t_dpi_import_mix_bad.out b/test_regress/t/t_dpi_import_mix_bad.out new file mode 100644 index 000000000..ef362e51b --- /dev/null +++ b/test_regress/t/t_dpi_import_mix_bad.out @@ -0,0 +1,4 @@ +%Error: t/t_dpi_import_mix_bad.v:11:32: Cannot mix DPI import, DPI export, class methods, and/or public on same function: 't.foo' + 11 | import "DPI-C" function int foo (int i); + | ^~~ +%Error: Exiting due to diff --git a/test_regress/t/t_dpi_import_mix_bad.pl b/test_regress/t/t_dpi_import_mix_bad.pl new file mode 100755 index 000000000..a60503a1f --- /dev/null +++ b/test_regress/t/t_dpi_import_mix_bad.pl @@ -0,0 +1,19 @@ +#!/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(linter => 1); + +lint( + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_dpi_import_mix_bad.v b/test_regress/t/t_dpi_import_mix_bad.v new file mode 100644 index 000000000..e924d2f94 --- /dev/null +++ b/test_regress/t/t_dpi_import_mix_bad.v @@ -0,0 +1,18 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// Copyright 2009 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 + +module t (); + + import "DPI-C" function int foo (int i); + export "DPI-C" function foo; // Bad mix + + initial begin + $stop; + end + +endmodule