X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/c38e3ce98599a410a47dc10253faa4d5830f13b2..427c49bcad63d042b29ada2ac27e3dfc4845c779:/regressions/t/security.pl diff --git a/regressions/t/security.pl b/regressions/t/security.pl new file mode 100755 index 00000000..d0892f0a --- /dev/null +++ b/regressions/t/security.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl -w +# +# Copyright (c) 2006-2007 Apple Inc. All Rights Reserved. +# + +my $pid = $$; + +END { + return unless $$ == $pid; + rm_test($_) for @TOCLEAN; +} + +use strict; +use Test::More; +use IPC::Run3; + +sub plan_security { + + unless (1) { + plan skip_all => "security not installed"; + exit; + }; + plan @_; +} + +use Carp; +our @TOCLEAN; +END { + return unless $$ == $pid; + $SIG{__WARN__} = sub { 1 }; + cleanup_test($_) for @TOCLEAN; +} + +our $output = ''; + +sub build_test { + my $xd = "/tmp/test-$pid"; + my $security = 'security'; + $ENV{HOME} = $xd; + push @TOCLEAN, [$xd, $security]; + return ($xd, $security); +} + +sub rm_test { + my ($xd, $security) = @{+shift}; + #rmtree [$xd]; +} + +sub cleanup_test { + return unless $ENV{TEST_VERBOSE}; + my ($xd, $security) = @{+shift}; +} + +sub is_output { + my ($security, $cmd, $arg, $expected, $test) = @_; + $output = ''; + run3([$security, $cmd, @$arg], \undef, \$output, \$output); +# open(STDOUT, ">&STDERR") || die "couldn't dup strerr: $!"; +# open(my $out, '-|', $security, $cmd, @$arg); +# while (<$out>) { $output .= $_; } + + my $cmp = (grep {ref ($_) eq 'Regexp'} @$expected) + ? \&is_deeply_like : \&is_deeply; + @_ = ([sort split (/\r?\n/, $output)], [sort @$expected], $test || join(' ', $cmd, @$arg)); + goto &$cmp; +} + +1;