Tests: Move driver.pl tee into perl to avoid process issue, bug650.
This commit is contained in:
parent
85e2a6bb45
commit
3bd3d01968
|
|
@ -861,30 +861,50 @@ sub _run {
|
||||||
print " > $param{logfile}" if $param{logfile};
|
print " > $param{logfile}" if $param{logfile};
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
|
# Execute command redirecting output, keeping order between stderr and stdout.
|
||||||
|
# Must do low-level IO so GCC interaction works (can't be line-based)
|
||||||
|
my $status;
|
||||||
|
{
|
||||||
|
pipe(PARENTRD, CHILDWR) or die "%Error: Can't Pipe, stopped";
|
||||||
|
autoflush PARENTRD 1;
|
||||||
|
autoflush CHILDWR 1;
|
||||||
|
my $logfh;
|
||||||
if ($param{logfile}) {
|
if ($param{logfile}) {
|
||||||
open(SAVEOUT, ">&STDOUT") or die "%Error: Can't dup stdout";
|
$logfh = IO::File->new(">$param{logfile}") or die "%Error: Can't open $param{logfile}";
|
||||||
open(SAVEERR, ">&STDERR") or die "%Error: Can't dup stderr";
|
|
||||||
if (0) {close(SAVEOUT); close(SAVEERR);} # Prevent unused warning
|
|
||||||
if ($param{tee}) {
|
|
||||||
open(STDOUT, "|tee $param{logfile}") or die "%Error: Can't redirect stdout";
|
|
||||||
} else {
|
|
||||||
open(STDOUT, ">$param{logfile}") or die "%Error: Can't open $param{logfile}";
|
|
||||||
}
|
}
|
||||||
open(STDERR, ">&STDOUT") or die "%Error: Can't dup stdout";
|
my $pid=fork();
|
||||||
|
if ($pid) { # Parent
|
||||||
|
close CHILDWR;
|
||||||
|
while (1) {
|
||||||
|
my $buf = '';
|
||||||
|
my $got = sysread PARENTRD,$buf,10000;
|
||||||
|
last if $got==0;
|
||||||
|
print $buf if $param{tee};
|
||||||
|
print $logfh $buf if $logfh;
|
||||||
|
}
|
||||||
|
close PARENTRD;
|
||||||
|
close $logfh if $logfh;
|
||||||
|
}
|
||||||
|
else { # Child
|
||||||
|
close PARENTRD;
|
||||||
|
close $logfh if $logfh;
|
||||||
|
# Reset signals
|
||||||
|
$SIG{ALRM} = 'DEFAULT';
|
||||||
|
$SIG{CHLD} = 'DEFAULT';
|
||||||
|
# Logging
|
||||||
|
open(STDOUT, ">&CHILDWR") or croak "%Error: Can't redirect stdout, stopped";
|
||||||
|
open(STDERR, ">&STDOUT") or croak "%Error: Can't dup stdout, stopped";
|
||||||
autoflush STDOUT 1;
|
autoflush STDOUT 1;
|
||||||
autoflush STDERR 1;
|
autoflush STDERR 1;
|
||||||
}
|
|
||||||
|
|
||||||
system "$command";
|
system "$command";
|
||||||
my $status = $?;
|
exit ($? ? 10 : 0); # $?<<8 misses coredumps
|
||||||
|
}
|
||||||
|
waitpid($pid,0);
|
||||||
|
$status = $? || 0;
|
||||||
|
}
|
||||||
flush STDOUT;
|
flush STDOUT;
|
||||||
flush STDERR;
|
flush STDERR;
|
||||||
|
|
||||||
if ($param{logfile}) {
|
|
||||||
open (STDOUT, ">&SAVEOUT");
|
|
||||||
open (STDERR, ">&SAVEERR");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$param{fails} && $status) {
|
if (!$param{fails} && $status) {
|
||||||
$self->error("Exec of $param{cmd}[0] failed\n");
|
$self->error("Exec of $param{cmd}[0] failed\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,11 @@ if (!-r "$root/.git") {
|
||||||
# Check empty
|
# Check empty
|
||||||
my @files;
|
my @files;
|
||||||
$finds = `find $destdir -type f -print`;
|
$finds = `find $destdir -type f -print`;
|
||||||
foreach my $f (split /\n/, $finds) {
|
foreach my $file (split /\n/, $finds) {
|
||||||
print "\tLEFT: $f\n";
|
next if $file =~ /\.status/; # Made by driver.pl, not Verilator
|
||||||
$f =~ s!^$cwd!.!;
|
print "\tLEFT: $file\n";
|
||||||
push @files, $f;
|
$file =~ s!^$cwd!.!;
|
||||||
|
push @files, $file;
|
||||||
}
|
}
|
||||||
if ($#files >= 0) {
|
if ($#files >= 0) {
|
||||||
$Self->error("Uninstall missed files: ",join(' ',@files));
|
$Self->error("Uninstall missed files: ",join(' ',@files));
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ compile (
|
||||||
|
|
||||||
foreach my $file (glob("$Self->{obj_dir}/*t_lint_only*")) {
|
foreach my $file (glob("$Self->{obj_dir}/*t_lint_only*")) {
|
||||||
next if $file =~ /simx_compile.log/; # Made by driver.pl, not Verilator
|
next if $file =~ /simx_compile.log/; # Made by driver.pl, not Verilator
|
||||||
|
next if $file =~ /\.status/; # Made by driver.pl, not Verilator
|
||||||
$Self->error("%Error: Created $file, but --lint-only shouldn't create files");
|
$Self->error("%Error: Created $file, but --lint-only shouldn't create files");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue