1
0
mirror of https://github.com/wfjm/w11.git synced 2026-01-25 04:05:39 +00:00

tbrun,asm-11: use bailout, update exit codes

This commit is contained in:
wfjm 2018-11-11 09:39:40 +01:00
parent dd3a253dbc
commit f248ab9bb2
8 changed files with 142 additions and 173 deletions

View File

@ -35,8 +35,7 @@ The full set of tests is only run for tagged releases.
benches (fast interrupt source) and enables on the long run to port the
2.10BSD kernel profiling code to 2.11BSD.
- stay with vivado 2017.2 as default tool, 2017.2 to 2018.2 exhibit much
longer build times for w11 designs (see Xilinx Forum post
[884858](https://forums.xilinx.com/t5/Synthesis/vivado-2018-2-much-slower-than-2017-2-at-least-for-small-designs/m-p/884858))
longer build times for w11 designs (see [w11 blog posting](https://wfjm.github.io/blogs/w11/2018-09-01-vivado-2018.2-much-slower.html))
### New features
- travis support via `.travis.yml`
@ -48,6 +47,9 @@ The full set of tests is only run for tagged releases.
- pdp11_dmpcnt: an array of 32 counters of 32 bit width
- connected to 24 signals from inside pdp11_sys70 and 8 signals from outside
- dmpcntanal: analysis script
- add new disk scheme ram: (with Rw11VirtDiskRam)
- implements a ram-only-disk
- generates create_disk compatible test patterns
### Changes
- Makefile: `make all_tcl` now quiet, use setup_packages_filt
@ -70,6 +72,7 @@ The full set of tests is only run for tagged releases.
- use in rtl/bplib/*/tb/tb_* test benches
- remove s7_cmt_sfs_tb
- RtclRw11Unit: fix for clang: M_virt() now public
- Rw11VirtDisk: keep track of disk geometry
- backend code review:
- use for C++ compiles `-Wpedantic` (in addition to `-Wall` and `-Wextra`)
- fixes for uninitialized variables (coverity, all uncritical)

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl -w
# $Id: asm-11 985 2018-01-03 08:59:40Z mueller $
# $Id: asm-11 1065 2018-11-04 11:32:06Z mueller $
#
# Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
# Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
#
# This program is free software; you may redistribute and/or modify it under
# the terms of the GNU General Public License as published by the Free
@ -14,6 +14,7 @@
#
# Revision History:
# Date Rev Version Comment
# 2018-11-03 1065 1.0.5 add and use bailout
# 2015-11-01 712 1.0.4 BUGFIX: fix '.' handling in instructions
# 2014-07-26 575 1.0.3 add 'call' and 'return' to pst (as in macro-11)
# 2013-04-07 503 1.0.2 list dot for .even,.dot,.blkb,.blkw
@ -45,57 +46,11 @@ GetOptions(\%opts, "help",
"cof", "ocof=s",
"lsm", "olsm=s"
)
or exit 1;
or bailout("bad command options");
unshift @{$opts{I}}, "."; # ./ is first in include path
push @{$opts{I}}, "$ENV{RETROBASE}/tools/asm-11" if defined $ENV{RETROBASE};
sub create_fname;
sub read_file;
sub parse_line;
sub walign;
sub add_err;
sub prt_err;
sub setdot;
sub incdot;
sub getdot;
sub setsym;
sub getsym;
sub lst_checkmdef;
sub eval_exp;
sub check_llbl;
sub check_reg;
sub check_token;
sub pushback_token;
sub get_token;
sub get_token1;
sub to_rad50;
sub pass2;
sub pass2_out;
sub pass2_lst_beg;
sub pass2_lst_end;
sub pass2_lst_line;
sub out_w;
sub out_wop;
sub out_b;
sub out_opcode;
sub out_opcode_n;
sub out_opcode_o;
sub out_opdata;
sub emitw;
sub emitb;
sub write_lda;
sub write_cof;
sub write_lsm;
sub dump_rl;
sub dump_sym;
sub prt76o;
sub prt43o;
sub save66o;
sub savestr;
sub savestr1;
sub print_help;
# Permanant symbol table
my %pst = (
# directives
@ -323,15 +278,11 @@ my $out_start = 1; # absolute start address
autoflush STDOUT 1 if (-p STDOUT); # autoflush if output into pipe
if (exists $opts{help}) {
print_help;
print_help();
exit 0;
}
if (scalar(@ARGV) == 0) {
print STDERR "asm-11-F: no input files specified, quiting..\n";
print_help;
exit 1;
}
bailout("no input files specified") if scalar(@ARGV) == 0;
# find stem of last file name
$fstem = $ARGV[-1];
@ -419,12 +370,9 @@ sub read_file {
if ($fname eq "-") {
$fh = *STDIN;
} else {
if (not -r $fname) {
print STDERR "asm-11-F: '$fname' not found or readable, quiting..\n";
exit 1;
}
bailout("'$fname' not found or readable") if (not -r $fname);
$fh = new FileHandle;
$fh->open($fname) or die "failed to open '$fname'";
$fh->open($fname) or bailout("failed to open '$fname': $!");
}
push @flist, $fname;
@ -1675,10 +1623,7 @@ sub pass2 {
$fh = *STDOUT;
} else {
$fh = new FileHandle;
unless (open($fh, ">", $lst_fname)) {
print STDERR "asm-11-F: '$lst_fname' not writable, quiting..\n";
exit 1;
}
open($fh, ">", $lst_fname) or bailout("'$lst_fname' not writable: $!");
}
}
@ -2143,10 +2088,7 @@ sub write_lda {
$fh = *STDOUT;
} else {
$fh = new FileHandle;
unless (open($fh, ">:raw", $fname)) {
print STDERR "asm-11-F: '$fname' not writable, quiting..\n";
exit 1;
}
open($fh, ">:raw", $fname) or bailout("'$fname' not writable: $!");
}
my @blist;
@ -2224,10 +2166,7 @@ sub write_cof {
$fh = *STDOUT;
} else {
$fh = new FileHandle;
unless (open($fh, ">:raw", $fname)) {
print STDERR "asm-11-F: '$fname' not writable, quiting..\n";
exit 1;
}
open($fh, ">:raw", $fname) or bailout("'$fname' not writable: $!");
}
print $fh "sym {\n";
@ -2289,10 +2228,7 @@ sub write_lsm {
$fh = *STDOUT;
} else {
$fh = new FileHandle;
unless (open($fh, ">:raw", $fname)) {
print STDERR "asm-11-F: '$fname' not writable, quiting..\n";
exit 1;
}
open($fh, ">:raw", $fname) or bailout("'$fname' not writable: $!")
}
my %mem;
@ -2466,6 +2402,14 @@ sub savestr1 {
#-------------------------------------------------------------------------------
sub bailout {
my ($msg) = @_;
print STDERR "asm-11-F: $msg\n";
exit 1;
}
#-------------------------------------------------------------------------------
sub print_help {
print "usage: asm-11 [OPTIONS]... [FILE]...\n";
print " --I=path adds path to the .include search path\n";

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl -w
# $Id: asm-11_expect 985 2018-01-03 08:59:40Z mueller $
# $Id: asm-11_expect 1065 2018-11-04 11:32:06Z mueller $
#
# Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
# Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
#
# This program is free software; you may redistribute and/or modify it under
# the terms of the GNU General Public License as published by the Free
@ -14,6 +14,7 @@
#
# Revision History:
# Date Rev Version Comment
# 2018-11-03 1065 1.1 add and use bailout; update exit code usage
# 2013-03-29 500 1.0 Initial version
# 2013-03-24 499 0.1 First draft
#
@ -29,31 +30,24 @@ my %opts = ();
GetOptions(\%opts, "help",
"tline", "tcheck"
)
or exit 1;
sub do_help;
sub print_help;
or bailout("bad command options");
my $errcnt; # total error count
autoflush STDOUT 1 if (-p STDOUT); # autoflush if output into pipe
if (exists $opts{help}) {
print_help;
print_help();
exit 0;
}
if (scalar(@ARGV) == 0) {
print STDERR "asm-11_expect-F: no input files specified, quiting..\n";
print_help;
exit 1;
}
bailout("no input files specified") if scalar(@ARGV) == 0;
foreach my $fname (@ARGV) {
do_file($fname);
}
exit 1 if $errcnt > 0;
exit 2 if $errcnt > 0;
exit 0;
#-------------------------------------------------------------------------------
@ -78,12 +72,9 @@ sub do_file {
if ($fname eq "-") {
$fh = *STDIN;
} else {
if (not -r $fname) {
print STDERR "asm-11_expect-F: '$fname' not found or readable. EXIT\n";
exit 1;
}
bailout("'$fname' not found or readable") if (not -r $fname);
$fh = new FileHandle;
$fh->open($fname) or die "failed to open '$fname'";
$fh->open($fname) or bailout("failed to open '$fname': $!");
}
my @errmsg; # error message list
@ -290,6 +281,14 @@ sub do_file {
#-------------------------------------------------------------------------------
sub bailout {
my ($msg) = @_;
print STDERR "asm-11_expect-F: $msg\n";
exit 1;
}
#-------------------------------------------------------------------------------
sub print_help {
print "usage: asm-11_expect <file>\n";
print " --tline trace input lines\n";

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl -w
# $Id: tbfilt 985 2018-01-03 08:59:40Z mueller $
# $Id: tbfilt 1065 2018-11-04 11:32:06Z mueller $
#
# Copyright 2016- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
# Copyright 2016-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
#
# This program is free software; you may redistribute and/or modify it under
# the terms of the GNU General Public License as published by the Free
@ -14,6 +14,7 @@
#
# Revision History:
# Date Rev Version Comment
# 2018-11-03 1065 1.1 add and use bailout; update exit code usage
# 2016-09-10 806 1.0 Initial version
# 2016-08-05 795 0.1 First draft
#
@ -31,9 +32,8 @@ GetOptions(\%opts, "tee=s", "pcom",
"find=s", "all",
"summary", "wide", "compact", "format=s", "nohead"
)
or die "bad options";
or bailout("bad command options");
sub do_file;
sub conv_fd;
sub conv_ft;
sub conv_fs;
@ -93,17 +93,15 @@ while (length($format)) {
$format = $';
} else { last; };
}
if (length($format)) {
print STDERR "tbfilt-f: bad format '$format'\n";
exit 2;
}
bailout("bad format '$format'") if length($format);
autoflush STDOUT 1 if (-p STDOUT);
my $fh_tee;
if (defined $opts{tee} && $opts{tee} ne '') {
$fh_tee = new FileHandle;
$fh_tee->open($opts{tee},'>') or die "failed to open for write '$opts{tee}'";
$fh_tee->open($opts{tee},'>') or
bailout("failed to open for write '$opts{tee}': $!");
}
my @flist = @ARGV;
@ -128,7 +126,7 @@ if (defined $opts{find}) {
@flist = ();
}
open FIND,'-|',"find -regextype egrep -regex '$opts{find}'"
or die "failed to open find pipe";
or bailout("failed to open find pipe: $!");
while (<FIND>) {
chomp;
@ -138,10 +136,7 @@ if (defined $opts{find}) {
close FIND;
@flist = sort @flist;
if (scalar (@flist) == 0) {
print STDERR "tbfilt-E: no files found by -find or -all\n";
exit 2;
}
bailout("no files found by -find or -all") if (scalar (@flist) == 0);
} else {
push @flist, '-' if (scalar(@flist) == 0);
@ -162,13 +157,21 @@ if ($opts{summary} && (not $opts{nohead})) {
foreach my $fnam (@flist) {
my $nfail = do_file($fnam);
$exitcode = 1 if $nfail;
$exitcode = 2 if $nfail;
}
exit $exitcode;
#-------------------------------------------------------------------------------
sub bailout {
my ($msg) = @_;
print STDERR "tbfilt-F: $msg\n";
exit 1;
}
#-------------------------------------------------------------------------------
sub do_file {
my ($fnam) = @_;
@ -181,7 +184,7 @@ sub do_file {
$fh = *STDIN;
} else {
$fh = new FileHandle;
$fh->open($fnam,'<') or die "failed to open for read '$fnam'";
$fh->open($fnam,'<') or bailout("failed to open for read '$fnam': $!");
}
if ($manyfile && $notsumm) {

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl -w
# $Id: tbrun 985 2018-01-03 08:59:40Z mueller $
# $Id: tbrun 1066 2018-11-10 11:21:53Z mueller $
#
# Copyright 2016-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
# Copyright 2016-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
#
# This program is free software; you may redistribute and/or modify it under
# the terms of the GNU General Public License as published by the Free
@ -14,6 +14,7 @@
#
# Revision History:
# Date Rev Version Comment
# 2018-11-09 1066 1.1 add and use bailout; update exit code usage
# 2017-04-15 875 1.0.1 add --help option
# 2016-09-17 808 1.0 Initial version
# 2016-08-09 796 0.1 First draft
@ -37,28 +38,7 @@ GetOptions(\%opts, "tag=s@", "exclude=s@", "mode=s",
"rlmon", "rbmon", "bwait=i", "swait=i",
"help"
)
or die "bad options";
sub setup_tagfilter;
sub check_tagfilter;
sub check_modefilter;
sub include_file;
sub read_file;
sub load_yaml;
sub check_keys;
sub expand_vars;
sub merge_lines;
sub merge_expand;
sub key_or_def;
sub handle_include;
sub handle_default;
sub handle_itest;
sub tpr;
sub tpre;
sub print_trace;
sub run_tests_single;
sub run_tests_multi;
sub print_usage;
or bailout("bad command options");
my @tlist;
my @olist;
@ -103,7 +83,8 @@ my $ticker_on = -t STDOUT;
my $fh_tee;
if (defined $opts{tee} && $opts{tee} ne '') {
$fh_tee = new FileHandle;
$fh_tee->open($opts{tee},'>') or die "failed to open for write '$opts{tee}'";
$fh_tee->open($opts{tee},'>')
or bailout("failed to open for write '$opts{tee}': $!");
}
$opts{tag} = ['default'] unless defined $opts{tag};
@ -128,7 +109,7 @@ foreach my $fnam (@ARGV) {
$ntest = scalar(@tlist);
unless ($ntest) {
tpre(sprintf "tbrun-E: %d tests found, none selected\n", $nseen);
exit 2;
exit 1;
}
if (defined $opts{jobs}) {
@ -139,13 +120,17 @@ if (defined $opts{jobs}) {
if (defined $opts{dry}) {
tpr(sprintf "#tbrun-I: %d tests found, %d selected\n", $nseen,$ntest);
} else {
if ($nfail) {
tpr(sprintf "tbrun-I: %d tests failed of %d tests executed\n",$nfail,$ndone);
} else {
tpr(sprintf "tbrun-I: all tests passed, %d tests selected from %d found\n",
$ndone,$ntest);
}
}
if ($nfail) {
tpr(sprintf "tbrun-I: %d tests failed of %d tests executed\n",$nfail,$ndone);
}
exit $nfail ? 1 : 0;
exit ($nfail ? 2 : 0);
#-------------------------------------------------------------------------------
sub setup_tagfilter {
@ -202,14 +187,14 @@ sub check_modefilter {
sub include_file {
my ($fnam) = @_;
my $fdat = read_file($fnam);
exit 2 unless defined $fdat;
exit 1 unless defined $fdat;
my $ylst = load_yaml($fdat, $fnam);
exit 2 unless defined $ylst;
exit 1 unless defined $ylst;
my $oldcwd = getcwd();
if ($fnam =~ m|^(.*)/(.*)$|) {
chdir $1 or die "chdir to '$1' failed with '$!'";
chdir $1 or bailout("chdir to '$1' failed with '$!'");
}
my %defhash;
@ -223,11 +208,11 @@ sub include_file {
} else {
tpr(sprintf "tbrun-E: unknown list element in '%s'\n found keys: %s\n",
$fnam, join(',',sort keys %$yele));
exit 2;
exit 1;
}
}
chdir $oldcwd or die "chdir to '$oldcwd' failed with '$!'";
chdir $oldcwd or bailout("chdir to '$oldcwd' failed with '$!'");
return;
}
@ -307,7 +292,7 @@ sub lookup_var {
return $ENV{$vnam} if exists $ENV{$vnam};
}
tpre(sprintf "tbrun-E: can't replace '$vnam'\n");
exit 2;
exit 1;
}
#-------------------------------------------------------------------------------
@ -354,7 +339,7 @@ sub key_or_def {
#-------------------------------------------------------------------------------
sub handle_include {
my ($yele) = @_;
check_keys($yele, \%keys_include) or exit 2;
check_keys($yele, \%keys_include) or exit 1;
my $fnam = merge_expand($yele->{include}, undef);
include_file($fnam);
@ -365,8 +350,8 @@ sub handle_include {
#-------------------------------------------------------------------------------
sub handle_default {
my ($yele, $defhash) = @_;
check_keys($yele, \%keys_default) or exit 2;
check_keys($yele->{default}, \%keys_defhash) or exit 2;
check_keys($yele, \%keys_default) or exit 1;
check_keys($yele->{default}, \%keys_defhash) or exit 1;
foreach my $key (keys %{$yele->{default}}) {
$$defhash{$key} = $$yele{default}{$key};
}
@ -376,7 +361,7 @@ sub handle_default {
#-------------------------------------------------------------------------------
sub handle_itest {
my ($yele, $defhash) = @_;
check_keys($yele, \%keys_itest) or exit 2;
check_keys($yele, \%keys_itest) or exit 1;
$nseen += 1;
@ -485,7 +470,7 @@ sub run_tests_single {
my $cdir = $titem->{cd};
my $test = $titem->{test};
chdir $inicwd or die "chdir to '$inicwd' failed with '$!'";
chdir $inicwd or bailout("chdir to '$inicwd' failed with '$!'");
if ($opts{dry}) {
if ($cdir ne $drycd) {
@ -837,6 +822,13 @@ sub run_tests_multi {
return;
}
# ----------------------------------------------------------------------------
sub bailout {
my ($msg) = @_;
print STDERR "tbrun-F: $msg\n";
exit 1;
}
# ----------------------------------------------------------------------------
sub print_usage {
print "usage: tbrun [options] [dcsfile]\n";

View File

@ -1,11 +1,11 @@
.\" -*- nroff -*-
.\" $Id: asm-11_expect.1 550 2014-02-03 08:16:57Z mueller $
.\" $Id: asm-11_expect.1 1065 2018-11-04 11:32:06Z mueller $
.\"
.\" Copyright 2014- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
.\" Copyright 2014-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
.\"
.\" ------------------------------------------------------------------
.
.TH ASM-11_EXPECT 1 2013-03-30 "Retro Project" "Retro Project Manual"
.TH ASM-11_EXPECT 1 2018-11-03 "Retro Project" "Retro Project Manual"
.\" ------------------------------------------------------------------
.SH NAME
asm-11_expect \- expect checker for asm-11 test bench
@ -89,14 +89,14 @@ If a line starts with an expect comment it will be applied to the asm-11
statement in the following line. Or it is simply appended to a asm-11
statement.
.SS Comment examples
.IP "\fB;;\-\- DM\fR" 4
.IP "\fB;;!! DM\fR" 4
expect a D and a M error flag
.IP "\fB;;\-\- 001020:\fR"
.IP "\fB;;!! 001020:\fR"
expect that current location will be 001020, data not checked
.IP "\fB;;\-\- 074167 177762\fR"
.IP "\fB;;!! 074167 177762\fR"
expect that the listing data section shows two words, 074167 and 177762.
Address is not checked.
.IP "\fB;;\-\- 001004: 000207\fR"
.IP "\fB;;!! 001004: 000207\fR"
expect that current location will be 001004 and that the listing data section
shows one word with value 000207.
@ -143,9 +143,20 @@ the content of the comment, like
.EE
.
.\" ----------------------------------------------
.IP "\fB\-help\fR"
.IP "\fB\-\-help\fR"
print full help text and exit.
.
.SH EXIT STATUS
In case of an error the exit codes are:
.RS
.PD 0
.IP \fB1\fP 3
run time errors, like bad option, file not found, etc
.IP \fB2\fP 3
at least one expect FAILed, test bench has FAILed
.PD
.RE
.
.\" ------------------------------------------------------------------
.SH EXAMPLES
.IP "\fBasm-11_expect *.lst\fR" 4

View File

@ -1,11 +1,11 @@
.\" -*- nroff -*-
.\" $Id: tbfilt.1 845 2017-01-15 14:58:27Z mueller $
.\" $Id: tbfilt.1 1065 2018-11-04 11:32:06Z mueller $
.\"
.\" Copyright 2016- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
.\" Copyright 2016-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
.\"
.\" ------------------------------------------------------------------
.
.TH TBFILT 1 2016-08-27 "Retro Project" "Retro Project Manual"
.TH TBFILT 1 2018-11-03 "Retro Project" "Retro Project Manual"
.\" ------------------------------------------------------------------
.SH NAME
tbfilt \- filter for and analysis of test bench log files
@ -262,10 +262,15 @@ short file name (without path)
.
.\" ------------------------------------------------------------------
.SH EXIT STATUS
In case the test bench is considered FAILed an exit status 1 is returned.
In case of an error at startup, e.g. no input files or invalid format
specification, an error message to stderr or printed and an exit status
of 2 is returned.
In case of an error the exit codes are:
.RS
.PD 0
.IP \fB1\fP 3
run time errors, like bad option, file not found, etc
.IP \fB2\fP 3
at least one test FAILed, test bench has FAILed
.PD
.RE
.
.\" ------------------------------------------------------------------
.SH ENVIRONMENT

View File

@ -1,11 +1,11 @@
.\" -*- nroff -*-
.\" $Id: tbrun.1 875 2017-04-15 21:58:50Z mueller $
.\" $Id: tbrun.1 1065 2018-11-04 11:32:06Z mueller $
.\"
.\" Copyright 2016-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
.\" Copyright 2016-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
.\"
.\" ------------------------------------------------------------------
.
.TH TBRUN 1 2017-04-15 "Retro Project" "Retro Project Manual"
.TH TBRUN 1 2018-11-03 "Retro Project" "Retro Project Manual"
.\" ------------------------------------------------------------------
.SH NAME
tbrun \- test bench driver
@ -216,10 +216,22 @@ specifies startup wait for post-synthesis and higher simulations.
\fItwait\fR must be an integer, time unit is 1 ns. Will be forwarded
to \fBtbrun_tbwrri\fP(1) based test benches.
.
.
\" -- --help -------------------------------------
.IP \fB\-\-help\fP
print short help text.
.
.\" ------------------------------------------------------------------
.SH EXIT STATUS
In case of an error the exit codes are:
.RS
.PD 0
.IP \fB1\fP 3
run time errors, like bad option, file not found, etc
.IP \fB2\fP 3
at least one test FAILed, test bench has FAILed
.PD
.RE
.
.\" ------------------------------------------------------------------
.SH EXAMPLES
.IP "\fBtbrun" 4