summaryrefslogtreecommitdiff
path: root/t/000_setup.t
blob: 4dc43291428a06e176053a2eaad3b48a5a4696e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl -w

use strict;
use English qw( -no_match_vars );

use lib './t';
use MyTest;
use MyTestSpecific;
use Cwd;
use File::Path qw (make_path);
use File::Copy;

TEST
{
    make_path('test/gnupghome', { mode => 0700 });
    my $agentconf = IO::File->new( "> test/gnupghome/gpg-agent.conf" );
    $agentconf->write("pinentry-program " . getcwd() . "/test/fake-pinentry.pl\n");
    $agentconf->close();
    copy('test/gpg.conf', 'test/gnupghome/gpg.conf');
    # reset the state of any long-lived gpg-agent, ignoring errors:
    system('gpgconf', '--homedir=test/gnupghome', '--quiet', '--kill', 'gpg-agent');

    reset_handles();

    my $pid = $gnupg->import_keys(command_args => [ 'test/public_keys.pgp', 'test/secret_keys.pgp', 'test/new_secret.pgp' ],
                                  options => [ 'batch'],
                                  handles => $handles);
    waitpid $pid, 0;

    return $CHILD_ERROR == 0;
};