X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Fcrypto_init.cc;fp=src%2Fceph%2Fsrc%2Ftest%2Fcrypto_init.cc;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=781175ebd18de099af8b17f68d4514e6b8a409df;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/test/crypto_init.cc b/src/ceph/src/test/crypto_init.cc deleted file mode 100644 index 781175e..0000000 --- a/src/ceph/src/test/crypto_init.cc +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include -#include -#include -#include - -#include "include/types.h" -#include "common/code_environment.h" -#include "global/global_context.h" -#include "global/global_init.h" -#include "include/msgr.h" -#include "gtest/gtest.h" -#include "auth/Crypto.h" -#include "common/ceph_crypto.h" - -#ifdef USE_NSS -void *init_crypto(void *p) { - ceph::crypto::init(g_ceph_context); - return NULL; -} - -// Tests for a race condition in libnss when calling crypto_init -// multiple times simultaneously from different threads. -TEST(CRYPTO_INIT, NSS_RACE) { - std::vector args; - auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, - CODE_ENVIRONMENT_UTILITY, - CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); - // Most reliably reproduced with more threads than cores. - long n_thread = sysconf(_SC_NPROCESSORS_ONLN) * 2; - pthread_t *ts = (pthread_t*)malloc(n_thread * sizeof(pthread_t)); - int i; - for (i = 0; i < n_thread; i++) { - pthread_create(&ts[i], NULL, init_crypto, NULL); - } - for (i = 0; i < n_thread; i++) { - int k; - void *p = (void*)&k; - pthread_join(ts[i], &p); - } - free(ts); -} - -#endif - -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -}