43fe83
From 948fae5a1104dbfe93d060e447920fb65fb5c8a5 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <948fae5a1104dbfe93d060e447920fb65fb5c8a5.1377873638.git.jdenemar@redhat.com>
43fe83
From: "Daniel P. Berrange" <berrange@redhat.com>
43fe83
Date: Tue, 13 Aug 2013 11:32:49 +0100
43fe83
Subject: [PATCH] Fix parallel runs of TLS test suites
43fe83
43fe83
For https://bugzilla.redhat.com/show_bug.cgi?id=994158
43fe83
43fe83
Use a separate keyfile name for the two TLS test suites so that
43fe83
they don't clash when running tests in parallel
43fe83
43fe83
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
43fe83
(cherry picked from commit eaa99a17dbad06d973f335a632fd47605556096c)
43fe83
---
43fe83
 tests/virnettlscontexttest.c | 10 ++++++----
43fe83
 tests/virnettlshelpers.c     |  6 ++----
43fe83
 tests/virnettlshelpers.h     |  6 ++----
43fe83
 tests/virnettlssessiontest.c | 10 ++++++----
43fe83
 4 files changed, 16 insertions(+), 16 deletions(-)
43fe83
43fe83
diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c
43fe83
index 9ade785..53792ee 100644
43fe83
--- a/tests/virnettlscontexttest.c
43fe83
+++ b/tests/virnettlscontexttest.c
43fe83
@@ -40,6 +40,8 @@
43fe83
 
43fe83
 # define VIR_FROM_THIS VIR_FROM_RPC
43fe83
 
43fe83
+# define KEYFILE "key-ctx.pem"
43fe83
+
43fe83
 struct testTLSContextData {
43fe83
     bool isServer;
43fe83
     const char *cacrt;
43fe83
@@ -66,7 +68,7 @@ static int testTLSContextInit(const void *opaque)
43fe83
         ctxt = virNetTLSContextNewServer(data->cacrt,
43fe83
                                          NULL,
43fe83
                                          data->crt,
43fe83
-                                         keyfile,
43fe83
+                                         KEYFILE,
43fe83
                                          NULL,
43fe83
                                          true,
43fe83
                                          true);
43fe83
@@ -74,7 +76,7 @@ static int testTLSContextInit(const void *opaque)
43fe83
         ctxt = virNetTLSContextNewClient(data->cacrt,
43fe83
                                          NULL,
43fe83
                                          data->crt,
43fe83
-                                         keyfile,
43fe83
+                                         KEYFILE,
43fe83
                                          true,
43fe83
                                          true);
43fe83
     }
43fe83
@@ -109,7 +111,7 @@ mymain(void)
43fe83
 {
43fe83
     int ret = 0;
43fe83
 
43fe83
-    testTLSInit();
43fe83
+    testTLSInit(KEYFILE);
43fe83
 
43fe83
 # define DO_CTX_TEST(_isServer, _caCrt, _crt, _expectFail)              \
43fe83
     do {                                                                \
43fe83
@@ -617,7 +619,7 @@ mymain(void)
43fe83
     testTLSDiscardCert(&clientcertlevel2breq);
43fe83
     unlink("cacertchain.pem");
43fe83
 
43fe83
-    testTLSCleanup();
43fe83
+    testTLSCleanup(KEYFILE);
43fe83
 
43fe83
     return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
43fe83
 }
43fe83
diff --git a/tests/virnettlshelpers.c b/tests/virnettlshelpers.c
43fe83
index 39a2df6..8a10340 100644
43fe83
--- a/tests/virnettlshelpers.c
43fe83
+++ b/tests/virnettlshelpers.c
43fe83
@@ -34,8 +34,6 @@
43fe83
 
43fe83
 # define VIR_FROM_THIS VIR_FROM_RPC
43fe83
 
43fe83
-const char *keyfile = abs_builddir "/virnettlscontexttest-key.pem";
43fe83
-
43fe83
 /*
43fe83
  * These store some static data that is needed when
43fe83
  * encoding extensions in the x509 certs
43fe83
@@ -99,7 +97,7 @@ static gnutls_x509_privkey_t testTLSLoadKey(void)
43fe83
 }
43fe83
 
43fe83
 
43fe83
-void testTLSInit(void)
43fe83
+void testTLSInit(const char *keyfile)
43fe83
 {
43fe83
     gnutls_global_init();
43fe83
 
43fe83
@@ -112,7 +110,7 @@ void testTLSInit(void)
43fe83
 }
43fe83
 
43fe83
 
43fe83
-void testTLSCleanup(void)
43fe83
+void testTLSCleanup(const char *keyfile)
43fe83
 {
43fe83
     asn1_delete_structure(&pkix_asn1);
43fe83
     unlink(keyfile);
43fe83
diff --git a/tests/virnettlshelpers.h b/tests/virnettlshelpers.h
43fe83
index 7c3f8da..3f6afb9 100644
43fe83
--- a/tests/virnettlshelpers.h
43fe83
+++ b/tests/virnettlshelpers.h
43fe83
@@ -28,8 +28,6 @@
43fe83
 
43fe83
 # include "rpc/virnettlscontext.h"
43fe83
 
43fe83
-extern const char *keyfile;
43fe83
-
43fe83
 /*
43fe83
  * This contains parameter about how to generate
43fe83
  * certificates.
43fe83
@@ -76,7 +74,7 @@ void testTLSWriteCertChain(const char *filename,
43fe83
                            size_t ncerts);
43fe83
 void testTLSDiscardCert(struct testTLSCertReq *req);
43fe83
 
43fe83
-void testTLSInit(void);
43fe83
-void testTLSCleanup(void);
43fe83
+void testTLSInit(const char *keyfile);
43fe83
+void testTLSCleanup(const char *keyfile);
43fe83
 
43fe83
 #endif
43fe83
diff --git a/tests/virnettlssessiontest.c b/tests/virnettlssessiontest.c
43fe83
index bc176aa..9b171ed 100644
43fe83
--- a/tests/virnettlssessiontest.c
43fe83
+++ b/tests/virnettlssessiontest.c
43fe83
@@ -38,6 +38,8 @@
43fe83
 
43fe83
 # define VIR_FROM_THIS VIR_FROM_RPC
43fe83
 
43fe83
+# define KEYFILE "key-sess.pem"
43fe83
+
43fe83
 struct testTLSSessionData {
43fe83
     const char *servercacrt;
43fe83
     const char *clientcacrt;
43fe83
@@ -107,7 +109,7 @@ static int testTLSSessionInit(const void *opaque)
43fe83
     serverCtxt = virNetTLSContextNewServer(data->servercacrt,
43fe83
                                            NULL,
43fe83
                                            data->servercrt,
43fe83
-                                           keyfile,
43fe83
+                                           KEYFILE,
43fe83
                                            data->wildcards,
43fe83
                                            false,
43fe83
                                            true);
43fe83
@@ -115,7 +117,7 @@ static int testTLSSessionInit(const void *opaque)
43fe83
     clientCtxt = virNetTLSContextNewClient(data->clientcacrt,
43fe83
                                            NULL,
43fe83
                                            data->clientcrt,
43fe83
-                                           keyfile,
43fe83
+                                           KEYFILE,
43fe83
                                            false,
43fe83
                                            true);
43fe83
 
43fe83
@@ -236,7 +238,7 @@ mymain(void)
43fe83
 {
43fe83
     int ret = 0;
43fe83
 
43fe83
-    testTLSInit();
43fe83
+    testTLSInit(KEYFILE);
43fe83
 
43fe83
 # define DO_SESS_TEST(_caCrt, _serverCrt, _clientCrt, _expectServerFail, \
43fe83
                       _expectClientFail, _hostname, _wildcards)         \
43fe83
@@ -474,7 +476,7 @@ mymain(void)
43fe83
     testTLSDiscardCert(&clientcertlevel2breq);
43fe83
     unlink("cacertchain.pem");
43fe83
 
43fe83
-    testTLSCleanup();
43fe83
+    testTLSCleanup(KEYFILE);
43fe83
 
43fe83
     return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
43fe83
 }
43fe83
-- 
43fe83
1.8.3.2
43fe83