| 1 | #!/usr/bin/perl -w |
|---|
| 2 | |
|---|
| 3 | use Test::More "no_plan"; |
|---|
| 4 | |
|---|
| 5 | use English; |
|---|
| 6 | use FindBin qw($Bin); |
|---|
| 7 | use File::Temp qw/tempdir/; |
|---|
| 8 | use IPC::Open3; |
|---|
| 9 | use POSIX ":sys_wait_h"; |
|---|
| 10 | |
|---|
| 11 | sub execscript ($$$$); |
|---|
| 12 | |
|---|
| 13 | my $tmphome = tempdir(CLEANUP => 1); |
|---|
| 14 | $ENV{HOME} = $tmphome; |
|---|
| 15 | |
|---|
| 16 | sub cleanup ($;$) { |
|---|
| 17 | my ($signal, $exitcode) = @_; |
|---|
| 18 | $exitcode = 0 unless (defined $exitcode); |
|---|
| 19 | my $cleanup = "/bin/rm -rf $tmphome"; |
|---|
| 20 | system ($cleanup); |
|---|
| 21 | |
|---|
| 22 | exit $exitcode; |
|---|
| 23 | } |
|---|
| 24 | $SIG{__DIE__} = \&cleanup; |
|---|
| 25 | $SIG{'INT'} = \&cleanup; |
|---|
| 26 | $SIG{'QUIT'} = \&cleanup; |
|---|
| 27 | |
|---|
| 28 | my @in = <DATA>; |
|---|
| 29 | is (@in, 2, "no of addresses"); |
|---|
| 30 | my (@out, @err); |
|---|
| 31 | |
|---|
| 32 | execscript ("blib/script/pl-init test\@localhost $ENV{USER}\@localhost", [], \@out, \@err); |
|---|
| 33 | is (@err, 0, "init errors"); |
|---|
| 34 | execscript ("blib/script/pl-subscribe --nowelcome --nomail test\@localhost", \@in, \@out, \@err); |
|---|
| 35 | is (@err, 0, "subscribe errors"); |
|---|
| 36 | cleanup('NONE', 0); |
|---|
| 37 | |
|---|
| 38 | sub execscript ( $$$$ ) { |
|---|
| 39 | my ($script, $pIn, $pOut, $pErr) = @_; |
|---|
| 40 | |
|---|
| 41 | my $pid |
|---|
| 42 | = open3 (*IN, *OUT, *ERR, |
|---|
| 43 | $script) |
|---|
| 44 | or die "Cannot start script (\"$script\"): $ERRNO"; |
|---|
| 45 | |
|---|
| 46 | print IN @{$pIn}; |
|---|
| 47 | close IN; |
|---|
| 48 | |
|---|
| 49 | @{$pOut} = <OUT>; |
|---|
| 50 | close OUT; |
|---|
| 51 | @{$pErr} = <ERR>; |
|---|
| 52 | close ERR; |
|---|
| 53 | |
|---|
| 54 | print STDERR @{$pErr} if @{$pErr}; |
|---|
| 55 | |
|---|
| 56 | waitpid ($pid, 0) |
|---|
| 57 | or die "Cannot stop (\"$script\"): $ERRNO"; |
|---|
| 58 | |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | __DATA__ |
|---|
| 62 | Gerd Aschemann <aschemann@localhost> |
|---|
| 63 | Anselm Lingnau <anselm@localhost> |
|---|