Make installation relocatable, and the installation testable (#4927)

Fixes #4893
This commit is contained in:
Geza Lore 2024-03-01 00:08:28 +00:00 committed by GitHub
parent 3af0eb7fa0
commit f56f318217
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
43 changed files with 496 additions and 354 deletions

View File

@ -17,6 +17,8 @@ env:
CCACHE_COMPRESS: 1 CCACHE_COMPRESS: 1
CCACHE_DIR: ${{ github.workspace }}/.ccache CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_LIMIT_MULTIPLE: 0.95 CCACHE_LIMIT_MULTIPLE: 0.95
INSTALL_DIR: ${{ github.workspace }}/install
RELOC_DIR: ${{ github.workspace }}/relloc
defaults: defaults:
run: run:
@ -94,6 +96,7 @@ jobs:
compiler: compiler:
- { cc: clang, cxx: clang++ } - { cc: clang, cxx: clang++ }
- { cc: gcc, cxx: g++ } - { cc: gcc, cxx: g++ }
reloc: [0]
suite: [dist-vlt-0, dist-vlt-1, dist-vlt-2, vltmt-0, vltmt-1] suite: [dist-vlt-0, dist-vlt-1, dist-vlt-2, vltmt-0, vltmt-1]
include: include:
# Test with GCC 10 on ubuntu-20.04 # Test with GCC 10 on ubuntu-20.04
@ -102,14 +105,21 @@ jobs:
- {os: ubuntu-20.04, compiler: { cc: gcc-10, cxx: g++-10 }, suite: dist-vlt-2} - {os: ubuntu-20.04, compiler: { cc: gcc-10, cxx: g++-10 }, suite: dist-vlt-2}
- {os: ubuntu-20.04, compiler: { cc: gcc-10, cxx: g++-10 }, suite: vltmt-0} - {os: ubuntu-20.04, compiler: { cc: gcc-10, cxx: g++-10 }, suite: vltmt-0}
- {os: ubuntu-20.04, compiler: { cc: gcc-10, cxx: g++-10 }, suite: vltmt-1} - {os: ubuntu-20.04, compiler: { cc: gcc-10, cxx: g++-10 }, suite: vltmt-1}
# Test relocated installation - on most common platform only
- {os: ubuntu-22.04, compiler: { cc: gcc, cxx: g++ }, reloc: 1, suite: dist-vlt-0}
- {os: ubuntu-22.04, compiler: { cc: gcc, cxx: g++ }, reloc: 1, suite: dist-vlt-1}
- {os: ubuntu-22.04, compiler: { cc: gcc, cxx: g++ }, reloc: 1, suite: dist-vlt-2}
- {os: ubuntu-22.04, compiler: { cc: gcc, cxx: g++ }, reloc: 1, suite: vltmt-0}
- {os: ubuntu-22.04, compiler: { cc: gcc, cxx: g++ }, reloc: 1, suite: vltmt-1}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
name: Test | ${{ matrix.os }} | ${{ matrix.compiler.cc }} | ${{ matrix.suite }} name: Test | ${{ matrix.os }} | ${{ matrix.compiler.cc }} | ${{ matrix.reloc && 'reloc | ' || '' }} ${{ matrix.suite }}
env: env:
CI_BUILD_STAGE_NAME: test CI_BUILD_STAGE_NAME: test
CI_RUNS_ON: ${{ matrix.os }} CI_RUNS_ON: ${{ matrix.os }}
CI_RELOC: ${{ matrix.reloc }}
CC: ${{ matrix.compiler.cc }} CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }} CXX: ${{ matrix.compiler.cxx }}
CACHE_BASE_KEY: test-${{ matrix.os }}-${{ matrix.compiler.cc }}-${{ matrix.suite }} CACHE_BASE_KEY: test-${{ matrix.os }}-${{ matrix.compiler.cc }}-${{ matrix.reloc }}-${{ matrix.suite }}
CCACHE_MAXSIZE: 100M # Per build per suite (* 5 * 5 = 2500M in total) CCACHE_MAXSIZE: 100M # Per build per suite (* 5 * 5 = 2500M in total)
VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}.tar.gz VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}.tar.gz
steps: steps:

View File

@ -203,11 +203,21 @@ verilator.html:
verilator.pdf: Makefile verilator.pdf: Makefile
$(MAKE) -C docs verilator.pdf $(MAKE) -C docs verilator.pdf
# See uninstall also - don't put wildcards in this variable, it might uninstall other stuff # Public executables intended to be invoked directly by the user
VL_INST_BIN_FILES = verilator verilator_bin$(EXEEXT) verilator_bin_dbg$(EXEEXT) verilator_coverage_bin_dbg$(EXEEXT) \ # Don't put wildcards in these variables, it might cause an uninstall of other stuff
verilator_ccache_report verilator_coverage verilator_difftree verilator_gantt verilator_includer verilator_profcfunc VL_INST_PUBLIC_SCRIPT_FILES = verilator \
# Some scripts go into both the search path and pkgdatadir, verilator_coverage \
# so they can be found by the user, and under $VERILATOR_ROOT. verilator_gantt \
verilator_profcfunc \
VL_INST_PUBLIC_BIN_FILES = verilator_bin$(EXEEXT) \
verilator_bin_dbg$(EXEEXT) \
verilator_coverage_bin_dbg$(EXEEXT) \
# Private executabels intended to be invoked by internals
# Don't put wildcards in these variables, it might cause an uninstall of other stuff
VL_INST_PRIVATE_SCRIPT_FILES = verilator_ccache_report \
verilator_includer \
VL_INST_INC_BLDDIR_FILES = \ VL_INST_INC_BLDDIR_FILES = \
include/verilated_config.h \ include/verilated_config.h \
@ -226,19 +236,34 @@ VL_INST_DATA_SRCDIR_FILES = \
examples/*/Makefile* \ examples/*/Makefile* \
examples/*/vl_* \ examples/*/vl_* \
installbin: mkbindirs:
$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
( cd ${srcdir}/bin ; $(INSTALL_PROGRAM) verilator $(DESTDIR)$(bindir)/verilator )
( cd ${srcdir}/bin ; $(INSTALL_PROGRAM) verilator_coverage $(DESTDIR)$(bindir)/verilator_coverage )
( cd ${srcdir}/bin ; $(INSTALL_PROGRAM) verilator_gantt $(DESTDIR)$(bindir)/verilator_gantt )
( cd ${srcdir}/bin ; $(INSTALL_PROGRAM) verilator_profcfunc $(DESTDIR)$(bindir)/verilator_profcfunc )
( cd bin ; $(INSTALL_PROGRAM) verilator_bin$(EXEEXT) $(DESTDIR)$(bindir)/verilator_bin$(EXEEXT) )
( cd bin ; $(INSTALL_PROGRAM) verilator_bin_dbg$(EXEEXT) $(DESTDIR)$(bindir)/verilator_bin_dbg$(EXEEXT) )
( cd bin ; $(INSTALL_PROGRAM) verilator_coverage_bin_dbg$(EXEEXT) $(DESTDIR)$(bindir)/verilator_coverage_bin_dbg$(EXEEXT) )
$(MKINSTALLDIRS) $(DESTDIR)$(pkgdatadir)/bin $(MKINSTALLDIRS) $(DESTDIR)$(pkgdatadir)/bin
( cd ${srcdir}/bin ; $(INSTALL_PROGRAM) verilator_includer $(DESTDIR)$(pkgdatadir)/bin/verilator_includer ) $(MKINSTALLDIRS) $(DESTDIR)$(bindir)
( cd ${srcdir}/bin ; $(INSTALL_PROGRAM) verilator_ccache_report $(DESTDIR)$(pkgdatadir)/bin/verilator_ccache_report )
( cd ${srcdir}/bin ; $(INSTALL_PROGRAM) verilator_difftree $(DESTDIR)$(pkgdatadir)/bin/verilator_difftree ) installbin: | mkbindirs
cd $(srcdir)/bin; \
for p in $(VL_INST_PUBLIC_SCRIPT_FILES) ; do \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkgdatadir)/bin/$$p; \
done
cd bin; \
for p in $(VL_INST_PUBLIC_BIN_FILES) ; do \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkgdatadir)/bin/$$p; \
done
cd $(srcdir)/bin; \
for p in $(VL_INST_PRIVATE_SCRIPT_FILES) ; do \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkgdatadir)/bin/$$p; \
done
installredirect: installbin | mkbindirs
cp ${srcdir}/bin/redirect ${srcdir}/bin/redirect.tmp
perl -p -i -e 'use File::Spec;' \
-e' $$path = File::Spec->abs2rel("$(realpath $(DESTDIR)$(pkgdatadir)/bin)", "$(realpath $(DESTDIR)$(bindir))");' \
-e 's/RELPATH.*/"$$path";/g' -- "${srcdir}/bin/redirect.tmp"
cd $(srcdir)/bin; \
for p in $(VL_INST_PUBLIC_SCRIPT_FILES) $(VL_INST_PUBLIC_BIN_FILES) ; do \
$(INSTALL_PROGRAM) redirect.tmp $(DESTDIR)$(bindir)/$$p; \
done
rm ${srcdir}/bin/redirect.tmp
# Man files can either be part of the original kit, or built in current directory # Man files can either be part of the original kit, or built in current directory
# So important we use $^ so VPATH is searched # So important we use $^ so VPATH is searched
@ -281,8 +306,11 @@ installdata:
# We don't trust rm -rf, so rmdir instead as it will fail if user put in other files # We don't trust rm -rf, so rmdir instead as it will fail if user put in other files
uninstall: uninstall:
-cd $(DESTDIR)$(bindir) && rm -f $(VL_INST_BIN_FILES) -cd $(DESTDIR)$(bindir) && rm -f $(VL_INST_PUBLIC_SCRIPT_FILES)
-cd $(DESTDIR)$(pkgdatadir)/bin && rm -f $(VL_INST_BIN_FILES) -cd $(DESTDIR)$(bindir) && rm -f $(VL_INST_PUBLIC_BIN_FILES)
-cd $(DESTDIR)$(pkgdatadir)/bin && rm -f $(VL_INST_PUBLIC_SCRIPT_FILES)
-cd $(DESTDIR)$(pkgdatadir)/bin && rm -f $(VL_INST_PUBLIC_BIN_FILES)
-cd $(DESTDIR)$(pkgdatadir)/bin && rm -f $(VL_INST_PRIVATE_SCRIPT_FILES)
-cd $(DESTDIR)$(mandir)/man1 && rm -f $(VL_INST_MAN_FILES) -cd $(DESTDIR)$(mandir)/man1 && rm -f $(VL_INST_MAN_FILES)
-cd $(DESTDIR)$(pkgdatadir) && rm -f $(VL_INST_INC_BLDDIR_FILES) -cd $(DESTDIR)$(pkgdatadir) && rm -f $(VL_INST_INC_BLDDIR_FILES)
-cd $(DESTDIR)$(pkgdatadir) && rm -f $(VL_INST_INC_SRCDIR_FILES) -cd $(DESTDIR)$(pkgdatadir) && rm -f $(VL_INST_INC_SRCDIR_FILES)
@ -311,7 +339,7 @@ uninstall:
-rmdir $(DESTDIR)$(pkgconfigdir) -rmdir $(DESTDIR)$(pkgconfigdir)
install: all_nomsg install-all install: all_nomsg install-all
install-all: installbin installman installdata install-msg install-all: installbin installredirect installman installdata install-msg
install-here: installman info install-here: installman info

22
bin/redirect Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env perl
######################################################################
#
# Copyright 2003-2024 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
#
######################################################################
require 5.006_001;
use warnings;
use FindBin qw($RealBin $RealScript);
use strict;
my $relpath = RELPATH; # Substituted during Verilator 'make install'
unshift @ARGV, $RealScript;
exec { "$RealBin/$relpath/$RealScript" } @ARGV;
die "%Error: Exec failed,";

View File

@ -15,6 +15,7 @@ use Getopt::Long;
use FindBin qw($RealBin $RealScript); use FindBin qw($RealBin $RealScript);
use IO::File; use IO::File;
use Pod::Usage; use Pod::Usage;
use Cwd qw(realpath);
use strict; use strict;
use vars qw($Debug @Opt_Verilator_Sw); use vars qw($Debug @Opt_Verilator_Sw);
@ -67,6 +68,18 @@ if (! GetOptions(
pod2usage(-exitstatus => 2, -verbose => 0); pod2usage(-exitstatus => 2, -verbose => 0);
} }
my $verilator_root = realpath("$RealBin/..");
if (defined $ENV{VERILATOR_ROOT}) {
if ((!-d $ENV{VERILATOR_ROOT}) || $verilator_root ne realpath($ENV{VERILATOR_ROOT})) {
warn "%Error: verilator: VERILATOR_ROOT is set to inconsistent path. Suggest leaving it unset.\n";
warn "%Error: VERILATOR_ROOT=$ENV{VERILATOR_ROOT}\n";
exit 1;
}
} else {
print "export VERILATOR_ROOT='$verilator_root'\n" if $Debug;
$ENV{VERILATOR_ROOT} = $verilator_root;
}
if ($opt_gdbbt && !gdb_works()) { if ($opt_gdbbt && !gdb_works()) {
warn "-Info: --gdbbt ignored: gdb doesn't seem to be working\n" if $Debug; warn "-Info: --gdbbt ignored: gdb doesn't seem to be working\n" if $Debug;
$opt_gdbbt = 0; $opt_gdbbt = 0;
@ -151,30 +164,13 @@ sub debug {
# Builds # Builds
sub verilator_bin { sub verilator_bin {
my $bin = "";
# Use VERILATOR_ROOT if defined, else assume verilator_bin is in the search path
my $basename = ($ENV{VERILATOR_BIN} my $basename = ($ENV{VERILATOR_BIN}
|| ($Debug ? "verilator_bin_dbg" : "verilator_bin")); || ($Debug ? "verilator_bin_dbg" : "verilator_bin"));
if (defined($ENV{VERILATOR_ROOT})) { if (-x "$RealBin/$basename" || -x "$RealBin/$basename.exe") {
my $dir = $ENV{VERILATOR_ROOT}; return "$RealBin/$basename";
if (-x "$dir/bin/$basename"
|| -x "$dir/bin/$basename.exe") { # From a "make install" into VERILATOR_ROOT
$bin = "$dir/bin/$basename";
} else {
$bin = "$dir/$basename"; # From pointing to kit directory
}
} else { } else {
if (-x "$RealBin/$basename" return $basename; # Find in PATH
|| -x "$RealBin/$basename.exe") {
$bin = "$RealBin/$basename"; # From path/to/verilator with verilator_bin installed
} else {
$bin = $basename; # Find in PATH
}
# Note we don't look under bin/$basename which would be right if running
# in the kit dir. Running that would likely break, since
# VERILATOR_ROOT wouldn't be set and Verilator won't find internal files.
} }
return $bin;
} }
####################################################################### #######################################################################

View File

@ -40,7 +40,7 @@ if [ "$CI_BUILD_STAGE_NAME" = "build" ]; then
if [ "$COVERAGE" != 1 ]; then if [ "$COVERAGE" != 1 ]; then
autoconf autoconf
./configure --enable-longtests --enable-ccwarn ./configure --enable-longtests --enable-ccwarn --prefix="$INSTALL_DIR"
ccache -z ccache -z
"$MAKE" -j "$NPROC" -k "$MAKE" -j "$NPROC" -k
# 22.04: ccache -s -v # 22.04: ccache -s -v
@ -87,23 +87,37 @@ elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then
# Run sanitize on Ubuntu 22.04 only # Run sanitize on Ubuntu 22.04 only
[ "$CI_RUNS_ON" = 'ubuntu-22.04' ] && sanitize='--sanitize' || sanitize='' [ "$CI_RUNS_ON" = 'ubuntu-22.04' ] && sanitize='--sanitize' || sanitize=''
TEST_REGRESS=test_regress
if [ "$CI_RELOC" == 1 ]; then
# Testing that the installation is relocatable.
"$MAKE" install
mkdir -p "$RELOC_DIR"
mv "$INSTALL_DIR" "$RELOC_DIR/relocated-install"
export VERILATOR_ROOT="$RELOC_DIR/relocated-install/share/verilator"
TEST_REGRESS="$RELOC_DIR/test_regress"
mv test_regress "$TEST_REGRESS"
# Feeling brave?
find . -delete
ls -la .
fi
# Run the specified test # Run the specified test
ccache -z ccache -z
case $TESTS in case $TESTS in
dist-vlt-0) dist-vlt-0)
"$MAKE" -C test_regress SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=0/3 "$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=0/3
;; ;;
dist-vlt-1) dist-vlt-1)
"$MAKE" -C test_regress SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=1/3 "$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=1/3
;; ;;
dist-vlt-2) dist-vlt-2)
"$MAKE" -C test_regress SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=2/3 "$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=2/3
;; ;;
vltmt-0) vltmt-0)
"$MAKE" -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=0/2 "$MAKE" -C "$TEST_REGRESS" SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=0/2
;; ;;
vltmt-1) vltmt-1)
"$MAKE" -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=1/2 "$MAKE" -C "$TEST_REGRESS" SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=1/2
;; ;;
coverage-all) coverage-all)
nodist/code_coverage --stages 1- nodist/code_coverage --stages 1-

View File

@ -16,7 +16,7 @@
default: test default: test
# This must point to the root of the VERILATOR kit # This must point to the root of the VERILATOR kit
VERILATOR_ROOT := $(shell pwd)/.. VERILATOR_ROOT ?= $(shell pwd)/..
export VERILATOR_ROOT export VERILATOR_ROOT
# Pick up PERL and other variable settings # Pick up PERL and other variable settings

View File

@ -12,6 +12,8 @@ BEGIN {
} }
$ENV{MAKE} ||= "make"; $ENV{MAKE} ||= "make";
$ENV{CXX} ||= "c++"; $ENV{CXX} ||= "c++";
!defined $ENV{TEST_REGRESS} or die "TEST_REGRESS environment variable is already set";
$ENV{TEST_REGRESS} = Cwd::getcwd();
} }
use Getopt::Long; use Getopt::Long;
@ -2484,7 +2486,7 @@ sub _vcd_read {
our $_Cxx_Version; our $_Cxx_Version;
sub cxx_version { sub cxx_version {
$_Cxx_Version ||= `$ENV{MAKE} -C $ENV{VERILATOR_ROOT}/test_regress -f Makefile print-cxx-version`; $_Cxx_Version ||= `$ENV{MAKE} -C $ENV{TEST_REGRESS} -f Makefile print-cxx-version`;
return $_Cxx_Version; return $_Cxx_Version;
} }

View File

@ -16,7 +16,7 @@ scenarios(simulator => 1);
$DEBUG_QUIET = "--debug --debugi 0 --gdbbt --no-dump-tree"; $DEBUG_QUIET = "--debug --debugi 0 --gdbbt --no-dump-tree";
run(cmd => ["perl", "../bin/verilator", $DEBUG_QUIET, "-V"], run(cmd => ["perl", "$ENV{VERILATOR_ROOT}/bin/verilator", $DEBUG_QUIET, "-V"],
verilator_run => 1, verilator_run => 1,
); );

View File

@ -10,8 +10,13 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(dist => 1); scenarios(dist => 1);
rerunnable(0); rerunnable(0);
my $root = "..";
if ($ENV{VERILATOR_TEST_NO_ATTRIBUTES}) { if ($ENV{VERILATOR_TEST_NO_ATTRIBUTES}) {
skip("Skipping due to VERILATOR_TEST_NO_ATTRIBUTES"); skip("Skipping due to VERILATOR_TEST_NO_ATTRIBUTES");
} elsif (!-r "$root/.git") {
skip("Not in a git repository");
} else { } else {
check(); check();
} }

View File

@ -10,53 +10,59 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator => 1); scenarios(simulator => 1);
compile( my $root = "..";
verilator_flags2 => ['--assert'],
nc_flags2 => ['+assert'],
vcs_flags2 => ['-assert svaext'],
fails => 1,
expect_filename => $Self->{golden_filename},
);
extract( if (!-r "$root/.git") {
in => $Self->{top_filename}, skip("Not in a git repository");
out => "../docs/gen/ex_USERWARN_faulty.rst", } else {
regexp => qr/\$warn.*User/); compile(
verilator_flags2 => ['--assert'],
nc_flags2 => ['+assert'],
vcs_flags2 => ['-assert svaext'],
fails => 1,
expect_filename => $Self->{golden_filename},
);
extract( extract(
in => $Self->{top_filename}, in => $Self->{top_filename},
out => "../docs/gen/ex_USERERROR_faulty.rst", out => "../docs/gen/ex_USERWARN_faulty.rst",
regexp => qr/\$error.*User/); regexp => qr/\$warn.*User/);
extract( extract(
in => $Self->{top_filename}, in => $Self->{top_filename},
out => "../docs/gen/ex_USERINFO_faulty.rst", out => "../docs/gen/ex_USERERROR_faulty.rst",
regexp => qr/\$info.*User/); regexp => qr/\$error.*User/);
extract( extract(
in => $Self->{top_filename}, in => $Self->{top_filename},
out => "../docs/gen/ex_USERFATAL_faulty.rst", out => "../docs/gen/ex_USERINFO_faulty.rst",
regexp => qr/\$fatal.*User/); regexp => qr/\$info.*User/);
extract( extract(
in => $Self->{golden_filename}, in => $Self->{top_filename},
out => "../docs/gen/ex_USERWARN_msg.rst", out => "../docs/gen/ex_USERFATAL_faulty.rst",
regexp => qr/USERWARN:.* User/); regexp => qr/\$fatal.*User/);
extract( extract(
in => $Self->{golden_filename}, in => $Self->{golden_filename},
out => "../docs/gen/ex_USERERROR_msg.rst", out => "../docs/gen/ex_USERWARN_msg.rst",
regexp => qr/USERERROR:.* User/); regexp => qr/USERWARN:.* User/);
extract( extract(
in => $Self->{golden_filename}, in => $Self->{golden_filename},
out => "../docs/gen/ex_USERINFO_msg.rst", out => "../docs/gen/ex_USERERROR_msg.rst",
regexp => qr/-Info:.* User/); regexp => qr/USERERROR:.* User/);
extract( extract(
in => $Self->{golden_filename}, in => $Self->{golden_filename},
out => "../docs/gen/ex_USERFATAL_msg.rst", out => "../docs/gen/ex_USERINFO_msg.rst",
regexp => qr/USERFATAL/); regexp => qr/-Info:.* User/);
extract(
in => $Self->{golden_filename},
out => "../docs/gen/ex_USERFATAL_msg.rst",
regexp => qr/USERFATAL/);
}
ok(1); ok(1);
1; 1;

View File

@ -24,7 +24,7 @@ execute(
# Read the input .v file and do any CHECK_COVER requests # Read the input .v file and do any CHECK_COVER requests
inline_checks(); inline_checks();
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"--annotate-points", "--annotate-points",
"--annotate", "$Self->{obj_dir}/annotated", "--annotate", "$Self->{obj_dir}/annotated",
"$Self->{obj_dir}/coverage.dat"], "$Self->{obj_dir}/coverage.dat"],
@ -34,7 +34,7 @@ run(cmd => ["../bin/verilator_coverage",
files_identical("$Self->{obj_dir}/annotated/t_cover_line.v", $Self->{golden_filename}); files_identical("$Self->{obj_dir}/annotated/t_cover_line.v", $Self->{golden_filename});
# Also try lcov # Also try lcov
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"--write-info", "$Self->{obj_dir}/coverage.info", "--write-info", "$Self->{obj_dir}/coverage.info",
"$Self->{obj_dir}/coverage.dat"], "$Self->{obj_dir}/coverage.dat"],
verilator_run => 1, verilator_run => 1,

View File

@ -24,7 +24,7 @@ execute(
# Read the input .v file and do any CHECK_COVER requests # Read the input .v file and do any CHECK_COVER requests
inline_checks(); inline_checks();
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"--annotate-points", "--annotate-points",
"--annotate", "$Self->{obj_dir}/annotated", "--annotate", "$Self->{obj_dir}/annotated",
"$Self->{obj_dir}/coverage.dat", "$Self->{obj_dir}/coverage.dat",

View File

@ -20,7 +20,7 @@ execute(
check_finished => 1, check_finished => 1,
); );
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"--annotate-points", "--annotate-points",
"--annotate", "$Self->{obj_dir}/annotated", "--annotate", "$Self->{obj_dir}/annotated",
"$Self->{obj_dir}/coverage.dat", "$Self->{obj_dir}/coverage.dat",

View File

@ -26,7 +26,7 @@ file_grep_not("$Self->{obj_dir}/coverage.dat", "largeish");
file_grep($Self->{stats}, qr/Coverage, Toggle points joined\s+(\d+)/i, 23) file_grep($Self->{stats}, qr/Coverage, Toggle points joined\s+(\d+)/i, 23)
if $Self->{vlt_all}; if $Self->{vlt_all};
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"--annotate", "$Self->{obj_dir}/annotated", "--annotate", "$Self->{obj_dir}/annotated",
"$Self->{obj_dir}/coverage.dat", "$Self->{obj_dir}/coverage.dat",
], ],
@ -35,7 +35,7 @@ run(cmd => ["../bin/verilator_coverage",
files_identical("$Self->{obj_dir}/annotated/$Self->{name}.v", $Self->{golden_filename}); files_identical("$Self->{obj_dir}/annotated/$Self->{name}.v", $Self->{golden_filename});
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"--annotate-points", "--annotate-points",
"--annotate", "$Self->{obj_dir}/annotated-points", "--annotate", "$Self->{obj_dir}/annotated-points",
"$Self->{obj_dir}/coverage.dat", "$Self->{obj_dir}/coverage.dat",

View File

@ -10,84 +10,90 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vlt_all => 1); scenarios(vlt_all => 1);
$Self->{sim_time} = 2000000; my $root = "..";
# Read optimizations if (!-r "$root/.git") {
my @optimizations = (); skip("Not in a git repository");
{ } else {
my $hdrFile = "../src/V3DfgPeephole.h"; $Self->{sim_time} = 2000000;
my $hdrFh = IO::File->new("<$hdrFile") or error("$! $hdrFile");
my $prevOpt = ""; # Read optimizations
my $lineno = 0; my @optimizations = ();
while (defined(my $line = $hdrFh->getline)) { {
$lineno = $lineno + 1; my $hdrFile = "../src/V3DfgPeephole.h";
next if $line !~ /^\s*_FOR_EACH_DFG_PEEPHOLE_OPTIMIZATION_APPLY\(macro, (\w+)\)/; my $hdrFh = IO::File->new("<$hdrFile") or error("$! $hdrFile");
my $opt = $1; my $prevOpt = "";
error("$hdrFile:$linenno: '$opt; is not in sorted order") if $prevOpt gt $opt; my $lineno = 0;
$prevOpt = $opt; while (defined(my $line = $hdrFh->getline)) {
push @optimizations, $opt; $lineno = $lineno + 1;
next if $line !~ /^\s*_FOR_EACH_DFG_PEEPHOLE_OPTIMIZATION_APPLY\(macro, (\w+)\)/;
my $opt = $1;
error("$hdrFile:$linenno: '$opt; is not in sorted order") if $prevOpt gt $opt;
$prevOpt = $opt;
push @optimizations, $opt;
}
error("no optimizations defined in $hdrFile") if scalar @optimizations == 0;
} }
error("no optimizations defined in $hdrFile") if scalar @optimizations == 0;
}
# Generate the equivalence checks and declaration boilerplate # Generate the equivalence checks and declaration boilerplate
my $rdFile = "$Self->{top_filename}"; my $rdFile = "$Self->{top_filename}";
my $plistFile = "$Self->{obj_dir}/portlist.vh"; my $plistFile = "$Self->{obj_dir}/portlist.vh";
my $pdeclFile = "$Self->{obj_dir}/portdecl.vh"; my $pdeclFile = "$Self->{obj_dir}/portdecl.vh";
my $checkFile = "$Self->{obj_dir}/checks.h"; my $checkFile = "$Self->{obj_dir}/checks.h";
my $rdFh = IO::File->new("<$rdFile") or error("$! $rdFile"); my $rdFh = IO::File->new("<$rdFile") or error("$! $rdFile");
my $plistFh = IO::File->new(">$plistFile") or error("$! $plistFile"); my $plistFh = IO::File->new(">$plistFile") or error("$! $plistFile");
my $pdeclFh = IO::File->new(">$pdeclFile") or error("$! $pdeclFile"); my $pdeclFh = IO::File->new(">$pdeclFile") or error("$! $pdeclFile");
my $checkFh = IO::File->new(">$checkFile") or error("$! $checkFile"); my $checkFh = IO::File->new(">$checkFile") or error("$! $checkFile");
while (defined(my $line = $rdFh->getline)) { while (defined(my $line = $rdFh->getline)) {
next if $line !~ /^\s*.*`signal\((\w+),/; next if $line !~ /^\s*.*`signal\((\w+),/;
my $signal = $1; my $signal = $1;
print $plistFh "$signal,\n"; print $plistFh "$signal,\n";
print $pdeclFh "output $signal;\n"; print $pdeclFh "output $signal;\n";
print $checkFh "if (ref.$signal != opt.$signal) {\n"; print $checkFh "if (ref.$signal != opt.$signal) {\n";
print $checkFh " std::cout << \"Mismatched $signal\" << std::endl;\n"; print $checkFh " std::cout << \"Mismatched $signal\" << std::endl;\n";
print $checkFh " std::cout << \"Ref: 0x\" << std::hex << (ref.$signal + 0) << std::endl;\n"; print $checkFh " std::cout << \"Ref: 0x\" << std::hex << (ref.$signal + 0) << std::endl;\n";
print $checkFh " std::cout << \"Opt: 0x\" << std::hex << (opt.$signal + 0) << std::endl;\n"; print $checkFh " std::cout << \"Opt: 0x\" << std::hex << (opt.$signal + 0) << std::endl;\n";
print $checkFh " std::exit(1);\n"; print $checkFh " std::exit(1);\n";
print $checkFh "}\n"; print $checkFh "}\n";
} }
close $rdFile; close $rdFile;
close $wrFile; close $wrFile;
# Compile un-optimized # Compile un-optimized
compile( compile(
verilator_flags2 => ["--stats", "--build", "-fno-dfg", "+incdir+$Self->{obj_dir}", verilator_flags2 => ["--stats", "--build", "-fno-dfg", "+incdir+$Self->{obj_dir}",
"-Mdir", "$Self->{obj_dir}/obj_ref", "--prefix", "Vref"], "-Mdir", "$Self->{obj_dir}/obj_ref", "--prefix", "Vref"],
); );
# Compile optimized - also builds executable # Compile optimized - also builds executable
compile( compile(
verilator_flags2 => ["--stats", "--build", "--exe", "+incdir+$Self->{obj_dir}", verilator_flags2 => ["--stats", "--build", "--exe", "+incdir+$Self->{obj_dir}",
"-Mdir", "$Self->{obj_dir}/obj_opt", "--prefix", "Vopt", "-Mdir", "$Self->{obj_dir}/obj_opt", "--prefix", "Vopt",
"-fno-const-before-dfg", # Otherwise V3Const makes testing painful "-fno-const-before-dfg", # Otherwise V3Const makes testing painful
"--dump-dfg", # To fill code coverage "--dump-dfg", # To fill code coverage
"-CFLAGS \"-I .. -I ../obj_ref\"", "-CFLAGS \"-I .. -I ../obj_ref\"",
"../obj_ref/Vref__ALL.a", "../obj_ref/Vref__ALL.a",
"../../t/$Self->{name}.cpp"], "../../t/$Self->{name}.cpp"],
); );
# Execute test to check equivalence # Execute test to check equivalence
execute( execute(
executable => "$Self->{obj_dir}/obj_opt/Vopt", executable => "$Self->{obj_dir}/obj_opt/Vopt",
check_finished => 1, check_finished => 1,
); );
sub check { sub check {
my $name = shift; my $name = shift;
$name = lc $name; $name = lc $name;
$name =~ s/_/ /g; $name =~ s/_/ /g;
file_grep("$Self->{obj_dir}/obj_opt/Vopt__stats.txt", qr/DFG\s+(pre|post) inline Peephole, ${name}\s+([1-9]\d*)/i); file_grep("$Self->{obj_dir}/obj_opt/Vopt__stats.txt", qr/DFG\s+(pre|post) inline Peephole, ${name}\s+([1-9]\d*)/i);
} }
# Check all optimizations defined in # Check all optimizations defined in
foreach my $opt (@optimizations) { foreach my $opt (@optimizations) {
check($opt); check($opt);
}
} }
ok(1); ok(1);

View File

@ -10,11 +10,16 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(dist => 1); scenarios(dist => 1);
run(cmd => ["cd $Self->{obj_dir} && $ENV{VERILATOR_ROOT}/bin/verilator_difftree" if (!-x "$ENV{VERILATOR_ROOT}/bin/verilator_difftree") {
. " $Self->{t_dir}/t_difftree.a.tree $Self->{t_dir}/t_difftree.b.tree > diff.log"], skip("No verilator_difftree available")
check_finished => 0); }
else {
run(cmd => ["cd $Self->{obj_dir} && $ENV{VERILATOR_ROOT}/bin/verilator_difftree"
. " $Self->{t_dir}/t_difftree.a.tree $Self->{t_dir}/t_difftree.b.tree > diff.log"],
check_finished => 0);
files_identical("$Self->{obj_dir}/diff.log", $Self->{golden_filename}, 'logfile'); files_identical("$Self->{obj_dir}/diff.log", $Self->{golden_filename}, 'logfile');
}
ok(1); ok(1);

View File

@ -13,8 +13,13 @@ use JSON::PP;
use IO::File; use IO::File;
scenarios(dist => 1); scenarios(dist => 1);
my $root = "..";
if ($ENV{VERILATOR_TEST_NO_ATTRIBUTES}) { if ($ENV{VERILATOR_TEST_NO_ATTRIBUTES}) {
skip("Skipping due to VERILATOR_TEST_NO_ATTRIBUTES"); skip("Skipping due to VERILATOR_TEST_NO_ATTRIBUTES");
} elsif (!-r "$root/.git") {
skip("Not in a git repository");
} else { } else {
check(); check();
} }

View File

@ -10,83 +10,87 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(dist => 1); scenarios(dist => 1);
my $root = ".."; if (!-r "$root/.git") {
my $Debug; skip("Not in a git repository");
} else {
my $root = "..";
my $Debug;
### Must trim output before and after our file list ### Must trim output before and after our file list
my %files = %{get_source_files($root)}; my %files = %{get_source_files($root)};
my $any = 0; my $any = 0;
foreach my $file (sort keys %files) { foreach my $file (sort keys %files) {
my $filename = "$root/$file"; my $filename = "$root/$file";
next if !-f $filename; # git file might be deleted but not yet staged next if !-f $filename; # git file might be deleted but not yet staged
my $contents = file_contents($filename); my $contents = file_contents($filename);
if ($file =~ /(\.out|\.dat)$/) { if ($file =~ /(\.out|\.dat)$/) {
# Ignore golden files # Ignore golden files
next; next;
} elsif ($contents =~ /[\001\002\003\004\005\006]/) { } elsif ($contents =~ /[\001\002\003\004\005\006]/) {
# Ignore binary files # Ignore binary files
next;
}
if ($contents !~ /\n$/s && $contents ne "") {
$warns{$file} = "Missing trailing newline in $file";
}
if ($contents =~ /[ \t]\n/
|| $contents =~ m/\n\n+$/) { # Regexp repeated below
my $eol_ws_exempt = ($file =~ /spelling.txt$/
|| $file =~ m!/gtkwave/!);
next if $eol_ws_exempt;
if ($ENV{HARNESS_UPDATE_GOLDEN}) {
my $changes = undef;
$changes = 1 if ($contents =~ s/[ \t]+\n/\n/g);
$changes = 1 if (!$eol_ws_exempt && $contents =~ s/\n\n+$/\n/g);
next if (!$changes);
$warns{$file} = "Updated whitespace at $file";
write_wholefile($filename, $contents);
next; next;
} }
my @lines = split(/\n/, $contents); if ($contents !~ /\n$/s && $contents ne "") {
my $line_no = 0; $warns{$file} = "Missing trailing newline in $file";
foreach my $line (@lines) { }
$line_no++; if ($contents =~ /[ \t]\n/
# Trim trailing carriage-return (ASCII 0x0d) and form feed (0x0c), || $contents =~ m/\n\n+$/) { # Regexp repeated below
# as we expect a few of those my $eol_ws_exempt = ($file =~ /spelling.txt$/
$line =~ s/[\x{d}\x{c}]//g; || $file =~ m!/gtkwave/!);
if ($line =~ /\s$/) { next if $eol_ws_exempt;
$warns{$file} = "Trailing whitespace at $file:$line_no"; if ($ENV{HARNESS_UPDATE_GOLDEN}) {
$warns{$file} .= " (last character is ASCII " . ord(substr($line, -1, 1)) . ")"; my $changes = undef;
$changes = 1 if ($contents =~ s/[ \t]+\n/\n/g);
$changes = 1 if (!$eol_ws_exempt && $contents =~ s/\n\n+$/\n/g);
next if (!$changes);
$warns{$file} = "Updated whitespace at $file";
write_wholefile($filename, $contents);
next;
}
my @lines = split(/\n/, $contents);
my $line_no = 0;
foreach my $line (@lines) {
$line_no++;
# Trim trailing carriage-return (ASCII 0x0d) and form feed (0x0c),
# as we expect a few of those
$line =~ s/[\x{d}\x{c}]//g;
if ($line =~ /\s$/) {
$warns{$file} = "Trailing whitespace at $file:$line_no";
$warns{$file} .= " (last character is ASCII " . ord(substr($line, -1, 1)) . ")";
}
}
if ($contents =~ m/\n\n+$/ && !$eol_ws_exempt) { # Regexp repeated above
$warns{$file} = "Trailing newlines at EOF in $file";
} }
} }
if ($contents =~ m/\n\n+$/ && !$eol_ws_exempt) { # Regexp repeated above # Unicode checker; should this be done in another file?
$warns{$file} = "Trailing newlines at EOF in $file"; # No way to auto-fix.
# Files with \r are flagged elsewhere, right?
if ($contents =~ /[^[:alnum:][:punct:] \t\r\n]/) {
my $unicode_exempt = ($file =~ /Changes$/
|| $file =~ /CONTRIBUTORS$/
|| $file =~ /contributors.rst$/
|| $file =~ /spelling.txt$/);
next if $unicode_exempt;
$warns{$file} = "Warning: non-ASCII contents in $file\n";
} }
++$any;
} }
# Unicode checker; should this be done in another file? $any > 50 or error("Too few source files found");
# No way to auto-fix.
# Files with \r are flagged elsewhere, right?
if ($contents =~ /[^[:alnum:][:punct:] \t\r\n]/) {
my $unicode_exempt = ($file =~ /Changes$/
|| $file =~ /CONTRIBUTORS$/
|| $file =~ /contributors.rst$/
|| $file =~ /spelling.txt$/);
next if $unicode_exempt;
$warns{$file} = "Warning: non-ASCII contents in $file\n";
}
++$any;
}
$any > 50 or error("Too few source files found");
if (keys %warns) { if (keys %warns) {
# First warning lists everything as that's shown in the driver summary # First warning lists everything as that's shown in the driver summary
if ($ENV{HARNESS_UPDATE_GOLDEN}) { if ($ENV{HARNESS_UPDATE_GOLDEN}) {
error("Updated files with whitespace errors: ", join(' ', sort keys %warns)); error("Updated files with whitespace errors: ", join(' ', sort keys %warns));
error("To auto-fix: HARNESS_UPDATE_GOLDEN=1 {command} or --golden"); error("To auto-fix: HARNESS_UPDATE_GOLDEN=1 {command} or --golden");
} else { } else {
error("Files have whitespace errors: ", join(' ', sort keys %warns)); error("Files have whitespace errors: ", join(' ', sort keys %warns));
error("To auto-fix: HARNESS_UPDATE_GOLDEN=1 {command} or --golden"); error("To auto-fix: HARNESS_UPDATE_GOLDEN=1 {command} or --golden");
} }
foreach my $file (sort keys %warns) { foreach my $file (sort keys %warns) {
error($warns{$file}); error($warns{$file});
}
} }
} }

View File

@ -1,8 +1,8 @@
// Test that environment substitutions work // Test that environment substitutions work
# This is also a comment (in several simulators) # This is also a comment (in several simulators)
-f $VERILATOR_ROOT/test_regress/t/t_flag_f__2.vc -f $TEST_REGRESS/t/t_flag_f__2.vc
// Env var with .v file, and parens // Env var with .v file, and parens
// Double slash below is intentional, as allowed in other tools // Double slash below is intentional, as allowed in other tools
${VERILATOR_ROOT}/test_regress/t//t_flag_f__3.v ${TEST_REGRESS}/t//t_flag_f__3.v
// Test -f // Test -f
-F $VERILATOR_ROOT/test_regress/t/tsub/t_flag_f_tsub.vc -F $TEST_REGRESS/t/tsub/t_flag_f_tsub.vc

View File

@ -13,7 +13,7 @@ scenarios(vlt => 1);
setenv('FOOBARTEST', "gotit"); setenv('FOOBARTEST', "gotit");
run( run(
cmd => ["../bin/verilator --getenv FOOBARTEST"], cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator --getenv FOOBARTEST"],
expect => 'gotit expect => 'gotit
', ',
logfile => "$Self->{obj_dir}/simx.log", logfile => "$Self->{obj_dir}/simx.log",
@ -22,7 +22,7 @@ run(
foreach my $var (qw(MAKE PERL SYSTEMC SYSTEMC_ARCH SYSTEMC_LIBDIR VERILATOR_ROOT)) { foreach my $var (qw(MAKE PERL SYSTEMC SYSTEMC_ARCH SYSTEMC_LIBDIR VERILATOR_ROOT)) {
run( run(
cmd => ["../bin/verilator --getenv ${var}"], cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator --getenv ${var}"],
logfile => "$Self->{obj_dir}/simx.log", logfile => "$Self->{obj_dir}/simx.log",
verilator_run => 1, verilator_run => 1,
); );

View File

@ -30,13 +30,16 @@ sub check {
file_grep($logfile, qr/(DISTRIBUTION|usage:)/i); file_grep($logfile, qr/(DISTRIBUTION|usage:)/i);
} }
check("perl", "../bin/verilator"); check("perl", "$ENV{VERILATOR_ROOT}/bin/verilator");
check("perl", "../bin/verilator_coverage"); check("perl", "$ENV{VERILATOR_ROOT}/bin/verilator_coverage");
check("python3", "../bin/verilator_ccache_report"); check("python3", "$ENV{VERILATOR_ROOT}/bin/verilator_ccache_report");
check("python3", "../bin/verilator_difftree"); check("python3", "$ENV{VERILATOR_ROOT}/bin/verilator_gantt");
check("python3", "../bin/verilator_gantt"); check("python3", "$ENV{VERILATOR_ROOT}/bin/verilator_profcfunc");
check("python3", "../bin/verilator_profcfunc");
if (-x "$ENV{VERILATOR_ROOT}/bin/verilator_difftree") {
check("python3", "$ENV{VERILATOR_ROOT}/bin/verilator_difftree");
}
ok(1); ok(1);
1; 1;

View File

@ -9,7 +9,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
run(fails => 0, run(fails => 0,
cmd => ["../bin/verilator", "--help", "--valgrind"], cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator", "--help", "--valgrind"],
tee => 0, tee => 0,
verilator_run => 1, verilator_run => 1,
); );

View File

@ -10,7 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vlt => 1); scenarios(vlt => 1);
run(cmd => ["../bin/verilator --lint-only"], run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator --lint-only"],
fails => 1, fails => 1,
logfile => "$Self->{obj_dir}/sim.log", logfile => "$Self->{obj_dir}/sim.log",
expect_filename => $Self->{golden_filename}, expect_filename => $Self->{golden_filename},

View File

@ -10,7 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vlt => 1); scenarios(vlt => 1);
run(cmd => ["../bin/verilator", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator",
"t_flag_noop_bad.v"], "t_flag_noop_bad.v"],
fails => 1, fails => 1,
logfile => "$Self->{obj_dir}/sim.log", logfile => "$Self->{obj_dir}/sim.log",

View File

@ -12,7 +12,7 @@ scenarios(vlt => 1);
if ($Self->have_coroutines) { if ($Self->have_coroutines) {
run( run(
cmd => ["../bin/verilator --get-supported COROUTINES"], cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator --get-supported COROUTINES"],
expect => '1 expect => '1
', ',
logfile => "$Self->{obj_dir}/vlt_coroutines.log", logfile => "$Self->{obj_dir}/vlt_coroutines.log",
@ -22,7 +22,7 @@ if ($Self->have_coroutines) {
if ($Self->have_sc) { if ($Self->have_sc) {
run( run(
cmd => ["../bin/verilator --get-supported SYSTEMC"], cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator --get-supported SYSTEMC"],
expect => '1 expect => '1
', ',
logfile => "$Self->{obj_dir}/vlt_systemc.log", logfile => "$Self->{obj_dir}/vlt_systemc.log",
@ -31,7 +31,7 @@ if ($Self->have_sc) {
} }
run( run(
cmd => ["../bin/verilator --get-supported DOES_NOT_EXIST"], cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator --get-supported DOES_NOT_EXIST"],
expect => '', expect => '',
logfile => "$Self->{obj_dir}/vlt_does_not_exist.log", logfile => "$Self->{obj_dir}/vlt_does_not_exist.log",
verilator_run => 1, verilator_run => 1,

View File

@ -12,11 +12,11 @@ scenarios(dist => 1);
foreach my $prog ( foreach my $prog (
# See also t_flag_help.pl # See also t_flag_help.pl
"../bin/verilator", "$ENV{VERILATOR_ROOT}/bin/verilator",
"../bin/verilator_coverage", "$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
#"../bin/verilator_difftree", #"$ENV{VERILATOR_ROOT}/bin/verilator_difftree",
#"../bin/verilator_gantt", #"$ENV{VERILATOR_ROOT}/bin/verilator_gantt",
#"../bin/verilator_profcfunc", #"$ENV{VERILATOR_ROOT}/bin/verilator_profcfunc",
) { ) {
run(fails => 0, run(fails => 0,
cmd => ["perl", $prog, cmd => ["perl", $prog,

View File

@ -10,24 +10,30 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vlt => 1); scenarios(vlt => 1);
compile( my $root = "..";
verilator_flags2 => ["--prof-cfuncs"],
);
execute( if (!-r "$root/.git") {
fails => 1, skip("Not in a git repository");
expect_filename => $Self->{golden_filename}, } else {
); compile(
verilator_flags2 => ["--prof-cfuncs"],
);
extract( execute(
in => $Self->{top_filename}, fails => 1,
out => "../docs/gen/ex_DIDNOTCONVERGE_faulty.rst", expect_filename => $Self->{golden_filename},
lines => "16-17"); );
extract( extract(
in => $Self->{golden_filename}, in => $Self->{top_filename},
out => "../docs/gen/ex_DIDNOTCONVERGE_msg.rst", out => "../docs/gen/ex_DIDNOTCONVERGE_faulty.rst",
lines => "1-2"); lines => "16-17");
extract(
in => $Self->{golden_filename},
out => "../docs/gen/ex_DIDNOTCONVERGE_msg.rst",
lines => "1-2");
}
ok(1); ok(1);
1; 1;

View File

@ -10,21 +10,27 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vlt => 1); scenarios(vlt => 1);
top_filename("t/t_lint_didnotconverge_bad.v"); my $root = "..";
compile( if (!-r "$root/.git") {
make_flags => 'CPPFLAGS_ADD=-UVL_DEBUG', skip("Not in a git repository");
); } else {
top_filename("t/t_lint_didnotconverge_bad.v");
execute( compile(
fails => 1, make_flags => 'CPPFLAGS_ADD=-UVL_DEBUG',
expect_filename => $Self->{golden_filename}, );
);
extract( execute(
in => $Self->{golden_filename}, fails => 1,
out => "../docs/gen/ex_DIDNOTCONVERGE_nodbg_msg.rst", expect_filename => $Self->{golden_filename},
lines => "1"); );
extract(
in => $Self->{golden_filename},
out => "../docs/gen/ex_DIDNOTCONVERGE_nodbg_msg.rst",
lines => "1");
}
ok(1); ok(1);
1; 1;

View File

@ -10,20 +10,26 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(linter => 1); scenarios(linter => 1);
lint( my $root = "..";
fails => 1,
expect_filename => $Self->{golden_filename},
);
extract( if (!-r "$root/.git") {
in => $Self->{top_filename}, skip("Not in a git repository");
out => "../docs/gen/ex_MULTIDRIVEN_faulty.rst", } else {
lines => "31-36"); lint(
fails => 1,
expect_filename => $Self->{golden_filename},
);
extract( extract(
in => $Self->{golden_filename}, in => $Self->{top_filename},
out => "../docs/gen/ex_MULTIDRIVEN_msg.rst", out => "../docs/gen/ex_MULTIDRIVEN_faulty.rst",
lines => "10,11,14"); lines => "31-36");
extract(
in => $Self->{golden_filename},
out => "../docs/gen/ex_MULTIDRIVEN_msg.rst",
lines => "10,11,14");
}
ok(1); ok(1);
1; 1;

View File

@ -10,21 +10,27 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vlt => 1); scenarios(vlt => 1);
lint( my $root = "..";
verilator_flags2 => ["--no-timing"],
fails => 1,
expect_filename => $Self->{golden_filename},
);
extract( if (!-r "$root/.git") {
in => $Self->{top_filename}, skip("Not in a git repository");
out => "../docs/gen/ex_STMTDLY_faulty.rst", } else {
lines => "10"); lint(
verilator_flags2 => ["--no-timing"],
fails => 1,
expect_filename => $Self->{golden_filename},
);
extract( extract(
in => $Self->{golden_filename}, in => $Self->{top_filename},
out => "../docs/gen/ex_STMTDLY_msg.rst", out => "../docs/gen/ex_STMTDLY_faulty.rst",
lines => "1"); lines => "10");
extract(
in => $Self->{golden_filename},
out => "../docs/gen/ex_STMTDLY_msg.rst",
lines => "1");
}
ok(1); ok(1);
1; 1;

View File

@ -10,27 +10,33 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(linter => 1); scenarios(linter => 1);
lint( my $root = "..";
verilator_flags2 => ["--lint-only"],
fails => $Self->{vlt_all},
expect_filename => $Self->{golden_filename},
);
extract( if (!-r "$root/.git") {
in => $Self->{top_filename}, skip("Not in a git repository");
out => "../docs/gen/ex_WIDTHEXPAND_1_faulty.rst", } else {
lines => "8-10"); lint(
verilator_flags2 => ["--lint-only"],
fails => $Self->{vlt_all},
expect_filename => $Self->{golden_filename},
);
extract( extract(
in => $Self->{golden_filename}, in => $Self->{top_filename},
out => "../docs/gen/ex_WIDTHEXPAND_1_msg.rst", out => "../docs/gen/ex_WIDTHEXPAND_1_faulty.rst",
lineno_adjust => -7, lines => "8-10");
regexp => qr/Warning-WIDTH/);
extract( extract(
in => $Self->{top_filename}, in => $Self->{golden_filename},
out => "../docs/gen/ex_WIDTHEXPAND_1_fixed.rst", out => "../docs/gen/ex_WIDTHEXPAND_1_msg.rst",
lines => "18"); lineno_adjust => -7,
regexp => qr/Warning-WIDTH/);
extract(
in => $Self->{top_filename},
out => "../docs/gen/ex_WIDTHEXPAND_1_fixed.rst",
lines => "18");
}
ok(1); ok(1);
1; 1;

View File

@ -12,7 +12,7 @@ scenarios(vlt => 1);
# This doesn't use the general compile rule as we want to make sure we form # This doesn't use the general compile rule as we want to make sure we form
# prefix properly using post-escaped identifiers # prefix properly using post-escaped identifiers
run(cmd => ["../bin/verilator", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator",
"--cc", "--cc",
"--Mdir " . $Self->{obj_dir} . "/t_mod_dollar", "--Mdir " . $Self->{obj_dir} . "/t_mod_dollar",
"--exe --build --main", "--exe --build --main",

View File

@ -12,7 +12,7 @@ scenarios(vlt => 1);
# Hit the debug statements in the preprocessor for internal coverage # Hit the debug statements in the preprocessor for internal coverage
run(cmd => ["../bin/verilator", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator",
"-E", "-E",
"t/t_preproc_debugi.v", "t/t_preproc_debugi.v",
"--debug", "--debug",

View File

@ -10,22 +10,28 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(linter => 1); scenarios(linter => 1);
lint( my $root = "..";
verilator_flags2 => ["--lint-only -Wwarn-VARHIDDEN"],
fails => $Self->{vlt_all},
expect_filename => $Self->{golden_filename},
);
extract( if (!-r "$root/.git") {
in => $Self->{top_filename}, skip("Not in a git repository");
out => "../docs/gen/ex_VARHIDDEN_faulty.rst", } else {
regexp => qr/(module t|integer|endmodule)/); lint(
verilator_flags2 => ["--lint-only -Wwarn-VARHIDDEN"],
fails => $Self->{vlt_all},
expect_filename => $Self->{golden_filename},
);
extract( extract(
in => $Self->{golden_filename}, in => $Self->{top_filename},
out => "../docs/gen/ex_VARHIDDEN_msg.rst", out => "../docs/gen/ex_VARHIDDEN_faulty.rst",
lineno_adjust => -6, regexp => qr/(module t|integer|endmodule)/);
regexp => qr/(var_bad_hide)/);
extract(
in => $Self->{golden_filename},
out => "../docs/gen/ex_VARHIDDEN_msg.rst",
lineno_adjust => -6,
regexp => qr/(var_bad_hide)/);
}
ok(1); ok(1);
1; 1;

View File

@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator_st => 1); scenarios(simulator_st => 1);
compile( compile(
verilator_flags2 => ['+incdir+../include'], verilator_flags2 => ["+incdir+$ENV{VERILATOR_ROOT}/include"],
); );
execute( execute(

View File

@ -15,7 +15,7 @@ foreach my $basename ("t_vlcov_data_a.dat",
"t_vlcov_data_c.dat", "t_vlcov_data_c.dat",
"t_vlcov_data_d.dat", "t_vlcov_data_d.dat",
) { ) {
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"t/${basename}", "t/${basename}",
"--debug", "--debug",
"--debugi 9", "--debugi 9",

View File

@ -10,7 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vlt => 1); scenarios(vlt => 1);
run(cmd => ["../bin/verilator_coverage", '--invalid-dash'], run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage", '--invalid-dash'],
logfile => $Self->{run_log_filename}, logfile => $Self->{run_log_filename},
fails => 1, fails => 1,
expect_filename => $Self->{golden_filename}, expect_filename => $Self->{golden_filename},

View File

@ -10,7 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(dist => 1); scenarios(dist => 1);
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"--write-info", "$Self->{obj_dir}/coverage.info", "--write-info", "$Self->{obj_dir}/coverage.info",
"t/t_vlcov_data_a.dat", "t/t_vlcov_data_a.dat",
"t/t_vlcov_data_b.dat", "t/t_vlcov_data_b.dat",

View File

@ -10,7 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(dist => 1); scenarios(dist => 1);
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"--no-unlink", "--nounlink", "--no-unlink", "--nounlink",
"--write", "$Self->{obj_dir}/coverage.dat", "--write", "$Self->{obj_dir}/coverage.dat",
"t/t_vlcov_data_a.dat", "t/t_vlcov_data_a.dat",

View File

@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(dist => 1); scenarios(dist => 1);
run(fails => 1, run(fails => 1,
cmd => ["../bin/verilator_coverage", cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"t/t_NOT_FOUND",], "t/t_NOT_FOUND",],
logfile => $Self->{run_log_filename}, logfile => $Self->{run_log_filename},
expect_filename => $Self->{golden_filename}, expect_filename => $Self->{golden_filename},

View File

@ -10,7 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(dist => 1); scenarios(dist => 1);
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"--rank", "--rank",
"t/t_vlcov_data_a.dat", "t/t_vlcov_data_a.dat",
"t/t_vlcov_data_b.dat", "t/t_vlcov_data_b.dat",

View File

@ -15,7 +15,7 @@ foreach my $basename ("t_vlcov_data_a.dat",
"t_vlcov_data_c.dat", "t_vlcov_data_c.dat",
"t_vlcov_data_d.dat", "t_vlcov_data_d.dat",
) { ) {
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"t/${basename}", "t/${basename}",
"--write", "$Self->{obj_dir}/${basename}" "--write", "$Self->{obj_dir}/${basename}"
], ],

View File

@ -15,7 +15,7 @@ scenarios(dist => 1);
my $tmp = "$Self->{obj_dir}/copied.dat"; my $tmp = "$Self->{obj_dir}/copied.dat";
File::Copy::copy("$Self->{t_dir}/t_vlcov_data_a.dat", $tmp); File::Copy::copy("$Self->{t_dir}/t_vlcov_data_a.dat", $tmp);
run(cmd => ["../bin/verilator_coverage", run(cmd => ["$ENV{VERILATOR_ROOT}/bin/verilator_coverage",
"--unlink", "--unlink",
$tmp, $tmp,
"--write", "$Self->{obj_dir}/output.dat"], "--write", "$Self->{obj_dir}/output.dat"],