Skip to content

Commit

Permalink
crypto,fcrypt, gpgme: kill gpg-agent after unit test is done.
Browse files Browse the repository at this point in the history
Hopefully once and for all fixes the infamous ElektraInitiative#1973 .
  • Loading branch information
petermax2 committed Sep 23, 2018
1 parent a23119b commit cb9c983
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/plugins/crypto/test_internals.h
Expand Up @@ -33,6 +33,7 @@ static KeySet * newPluginConfiguration (void);
test_init (PLUGIN_NAME); \
test_incomplete_config (PLUGIN_NAME); \
test_crypto_operations (PLUGIN_NAME); \
test_teardown (); \
} \
else \
{ \
Expand Down Expand Up @@ -149,6 +150,11 @@ static void test_init (const char * pluginName)
keyDel (parentKey);
}

static void test_teardown (void)
{
succeed_if (system ("gpg-connect-agent --quiet KILLAGENT /bye") == 0, "failed to kill the gpg-agent");
}

static void test_incomplete_config (const char * pluginName)
{
Plugin * plugin = NULL;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/fcrypt/testmod_fcrypt.c
Expand Up @@ -115,6 +115,11 @@ static int isTestFileCorrect (const char * file)
return returnValue;
}

static void test_teardown (void)
{
succeed_if (system ("gpg-connect-agent --quiet KILLAGENT /bye") == 0, "failed to kill the gpg-agent");
}

static void test_init (void)
{
Plugin * plugin = NULL;
Expand Down Expand Up @@ -300,6 +305,7 @@ int main (int argc, char ** argv)
test_file_crypto_operations ();
test_file_signature_operations ();
test_file_faulty_signature ();
test_teardown ();

print_result (ELEKTRA_PLUGIN_NAME);
return nbError;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/gpgme/testmod_gpgme.c
Expand Up @@ -81,6 +81,11 @@ static KeySet * newTestdataKeySet (void)
return ksNew (4, kUnchanged, kNull, kString, kBin, KS_END);
}

static void test_teardown (void)
{
succeed_if (system ("gpg-connect-agent --quiet KILLAGENT /bye") == 0, "failed to kill the gpg-agent");
}

static void test_import_key (void)
{
gpgme_error_t err;
Expand Down Expand Up @@ -282,6 +287,7 @@ int main (int argc, char ** argv)
test_init ();
test_incomplete_config ();
test_encryption_decryption ();
test_teardown ();

print_result ("gpgme");
return nbError;
Expand Down

0 comments on commit cb9c983

Please sign in to comment.