darling-dyld/unit-tests/bin/exit-non-zero-pass.pl
2022-04-18 20:33:29 -07:00

45 lines
695 B
Perl
Executable File

#!/usr/bin/perl -w
use strict;
sub PASS
{
my ($format, $args) = @_;
if(!defined $args)
{ $args = []; }
printf("PASS \"$format\"\n", @$args);
}
sub FAIL
{
my ($format, $args) = @_;
if(!defined $args)
{ $args = []; }
printf("FAIL \"$format\"\n", @$args);
}
my $pass_string = shift @ARGV;
my $fail_string = shift @ARGV;
# redirect stderr to stdout
open(STDERR, ">/tmp/exit-non-zero.tmp") || die("$!");
if(0 != system(@ARGV))
{
PASS($pass_string);
}
else
{
FAIL($fail_string);
}
close(STDERR) || die("$!");
open(OUT, "</tmp/exit-non-zero.tmp") || die("$!");
while(<OUT>)
{
print $_;
}
close(OUT) || die("$!");
unlink "/tmp/exit-non-zero.tmp";
exit 0;