소스 검색

Test CRYPTO_once_t collisions.

The existing tests never actually tested this case.

Change-Id: Idb9cf0cbbe32fdf5cd353656a95fbedbaac09376
Reviewed-on: https://boringssl-review.googlesource.com/7612
Reviewed-by: Emily Stark (Dunn) <estark@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
kris/onging/CECPQ3_patch15
David Benjamin 8 년 전
부모
커밋
3ed24f0502
1개의 변경된 파일14개의 추가작업 그리고 3개의 파일을 삭제
  1. +14
    -3
      crypto/thread_test.c

+ 14
- 3
crypto/thread_test.c 파일 보기

@@ -53,6 +53,7 @@ static int wait_for_thread(thread_t thread) {
#else

#include <pthread.h>
#include <unistd.h>

typedef pthread_t thread_t;

@@ -77,6 +78,14 @@ static unsigned g_once_init_called = 0;

static void once_init(void) {
g_once_init_called++;

/* Sleep briefly so one |call_once_thread| instance will call |CRYPTO_once|
* while the other is running this function. */
#if defined(OPENSSL_WINDOWS)
Sleep(1 /* milliseconds */);
#else
usleep(1000 /* microseconds */);
#endif
}

static CRYPTO_once_t g_test_once = CRYPTO_ONCE_INIT;
@@ -91,9 +100,11 @@ static int test_once(void) {
return 0;
}

thread_t thread;
if (!run_thread(&thread, call_once_thread) ||
!wait_for_thread(thread)) {
thread_t thread1, thread2;
if (!run_thread(&thread1, call_once_thread) ||
!run_thread(&thread2, call_once_thread) ||
!wait_for_thread(thread1) ||
!wait_for_thread(thread2)) {
fprintf(stderr, "thread failed.\n");
return 0;
}


불러오는 중...
취소
저장