diff --git a/Makefile.in b/Makefile.in index fcee49bca..d6b9fd70e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -492,6 +492,7 @@ PY_PROGRAMS = \ src/cppcheck_filtered \ src/flexfix \ src/vlcovgen \ + test_regress/t/*.pf \ nodist/code_coverage \ nodist/dot_importer \ nodist/fuzzer/actual_fail \ diff --git a/bin/verilator_ccache_report b/bin/verilator_ccache_report index 764accd27..dd6d47897 100755 --- a/bin/verilator_ccache_report +++ b/bin/verilator_ccache_report @@ -88,6 +88,7 @@ else: args.o.write("{:{width}}| {}s\n".format(k, v.total_seconds(), width=wnames)) - if i > 4: break + if i > 4: + break args.o.write("#" * 80 + "\n") diff --git a/test_regress/t/t_pipe_exit_bad.pf b/test_regress/t/t_pipe_exit_bad.pf old mode 100644 new mode 100755 index 9aa87394d..8f3c42b50 --- a/test_regress/t/t_pipe_exit_bad.pf +++ b/test_regress/t/t_pipe_exit_bad.pf @@ -1,5 +1,6 @@ -#!/usr/bin/env perl -use warnings; +#!/usr/bin/env python3 +# pylint: disable=C0114 +# # DESCRIPTION: Verilator: Verilog Test example --pipe-filter script # # Copyright 2010 by Wilson Snyder. This program is free software; you @@ -8,4 +9,6 @@ use warnings; # Version 2.0. # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 -die "%Error: t_pipe_exit_bad.pf: Intentional bad exit status...\n"; +import sys + +sys.exit("%Error: t_pipe_exit_bad.pf: Intentional bad exit status...") diff --git a/test_regress/t/t_pipe_exit_bad.pl b/test_regress/t/t_pipe_exit_bad.pl index ed3afdee3..79df707f7 100755 --- a/test_regress/t/t_pipe_exit_bad.pl +++ b/test_regress/t/t_pipe_exit_bad.pl @@ -13,7 +13,7 @@ scenarios(vlt => 1); top_filename("t/t_pipe_filter.v"); lint( - verilator_flags2 => ['-E --pipe-filter \'perl t/t_pipe_exit_bad.pf\' '], + verilator_flags2 => ['-E --pipe-filter \'python3 t/t_pipe_exit_bad.pf\' '], stdout_filename => $stdout_filename, fails => 1, expect => diff --git a/test_regress/t/t_pipe_filter.pf b/test_regress/t/t_pipe_filter.pf old mode 100644 new mode 100755 index 4e602fd7c..22af10c97 --- a/test_regress/t/t_pipe_filter.pf +++ b/test_regress/t/t_pipe_filter.pf @@ -1,5 +1,6 @@ -#!/usr/bin/env perl -use warnings; +#!/usr/bin/env python3 +# pylint: disable=C0103,C0114 +# # DESCRIPTION: Verilator: Verilog Test example --pipe-filter script # # Copyright 2010 by Wilson Snyder. This program is free software; you @@ -8,51 +9,54 @@ use warnings; # Version 2.0. # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 -use IO::File; -use strict; +import re +import sys -our $Debug = 0; +Debug = False -autoflush STDOUT; +if Debug: + sys.stderr.write("t_pipe_filter.pf: Hello from t_pipe_filter.pf\n") -print STDERR "t_pipe_filter.pf: Hello in Perl\n" if $Debug; -while (defined(my $cmd = )) { - print STDERR "t_pipe_filter.pf: gotcmd: $cmd" if $Debug; - if ($cmd =~ /^read "(.*)"/) { - my $filename = $1; - open(my $fh, "<$filename") - or die "t_pipe_filter.pf: %Error: $! $filename\n"; +for cmd in sys.stdin: + if Debug: + sys.stderr.write("t_pipe_filter.pf: gotcmd: " + cmd) - my $wholefile=""; - # It's faster to slurp the whole file then scan (if needed), - # then to read it into an array with getlines - { local $/; undef $/; $wholefile = <$fh>; } - close $fh; + match = re.match(r'read "(.*)"', cmd) + if match: + filename = match.group(1) - if ($wholefile =~ /example_lint/) { # else short circuit - my $lineno = 1; my $pos=0; - my @prefixes; - while (1) { - my $newpos=index($wholefile,"\n",$pos); - last if $newpos<$pos; - my $line = substr($wholefile,$pos,$newpos-$pos); - if ($line =~ /example_lint/) { + wholefile = "" + # It's faster to slurp the whole file then scan (if needed) + with open(filename) as fh: + wholefile = fh.read() + + if 'example_lint' in wholefile: # else short circuit + lineno = 1 + pos = 0 + prefixes = [] + while True: + newpos = wholefile.find('\n', pos) + if newpos < pos: + break + line = wholefile[pos:newpos] + if 'example_lint' in line: # We don't have a way to specify this yet, so just for now - #print STDERR $line; - push @prefixes, "int lint_off_line_${lineno} = 1;\n"; - } - $lineno++; - $pos = $newpos+1; - } - #print STDERR "Line count: $lineno\n"; - $wholefile = join('',@prefixes) . $wholefile; - } + # sys.stderr.write($line) + prefixes.append("int lint_off_line_" + str(lineno) + + " = 1;\n") - print STDOUT "Content-Length: ".length($wholefile)."\n".$wholefile."\n"; - } else { - die "t_pipe_filter.pf: %Error: Unknown command: $cmd\n"; - } -} + lineno += 1 + pos = newpos + 1 -print STDOUT "t_pipe_filter.pf: Fin\n" if $Debug; -exit(0); + # sys.stderr.write("Line count: %d\n" % lineno) + wholefile = ''.join(prefixes) + wholefile + + print("Content-Length: " + str(len(wholefile)) + "\n" + wholefile) + sys.stdout.flush() + else: + sys.exit("t_pipe_filter.pf: %Error: Unknown command: " + cmd) + +if Debug: + sys.stderr.write("t_pipe_filter.pf: Fin\n") + +sys.exit(0) diff --git a/test_regress/t/t_pipe_filter.pl b/test_regress/t/t_pipe_filter.pl index a85cf653e..c303cef67 100755 --- a/test_regress/t/t_pipe_filter.pl +++ b/test_regress/t/t_pipe_filter.pl @@ -13,7 +13,7 @@ scenarios(vlt => 1); my $stdout_filename = "$Self->{obj_dir}/$Self->{name}__test.vpp"; compile( - verilator_flags2 => ['-E --pipe-filter \'perl t/t_pipe_filter.pf\' '], + verilator_flags2 => ['-E --pipe-filter \'python3 t/t_pipe_filter.pf\' '], verilator_make_gmake => 0, make_top_shell => 0, make_main => 0,