| Index: third_party/grpc/test/core/surface/init_test.c
|
| diff --git a/third_party/tcmalloc/vendor/src/base/synchronization_profiling.h b/third_party/grpc/test/core/surface/init_test.c
|
| similarity index 64%
|
| copy from third_party/tcmalloc/vendor/src/base/synchronization_profiling.h
|
| copy to third_party/grpc/test/core/surface/init_test.c
|
| index cf02c218a111806189f71f7b528a83b5ceb164a4..d4451e45672e931db2471838b3cf00a8b367fd78 100644
|
| --- a/third_party/tcmalloc/vendor/src/base/synchronization_profiling.h
|
| +++ b/third_party/grpc/test/core/surface/init_test.c
|
| @@ -1,4 +1,6 @@
|
| -/* Copyright (c) 2010, Google Inc.
|
| +/*
|
| + *
|
| + * Copyright 2015, Google Inc.
|
| * All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| @@ -27,24 +29,50 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| *
|
| - * ---
|
| - * Author: Chris Ruemmler
|
| */
|
|
|
| -#ifndef BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_
|
| -#define BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_
|
| +#include <grpc/grpc.h>
|
| +#include <grpc/support/log.h>
|
| +#include "test/core/util/test_config.h"
|
| +
|
| +static int g_flag;
|
| +
|
| +static void test(int rounds) {
|
| + int i;
|
| + for (i = 0; i < rounds; i++) {
|
| + grpc_init();
|
| + }
|
| + for (i = 0; i < rounds; i++) {
|
| + grpc_shutdown();
|
| + }
|
| +}
|
|
|
| -#include "base/basictypes.h"
|
| +static void test_mixed(void) {
|
| + grpc_init();
|
| + grpc_init();
|
| + grpc_shutdown();
|
| + grpc_init();
|
| + grpc_shutdown();
|
| + grpc_shutdown();
|
| +}
|
|
|
| -namespace base {
|
| +static void plugin_init(void) { g_flag = 1; }
|
| +static void plugin_destroy(void) { g_flag = 2; }
|
|
|
| -// We can do contention-profiling of SpinLocks, but the code is in
|
| -// mutex.cc, which is not always linked in with spinlock. Hence we
|
| -// provide a weak definition, which are used if mutex.cc isn't linked in.
|
| +static void test_plugin() {
|
| + grpc_register_plugin(plugin_init, plugin_destroy);
|
| + grpc_init();
|
| + GPR_ASSERT(g_flag == 1);
|
| + grpc_shutdown();
|
| + GPR_ASSERT(g_flag == 2);
|
| +}
|
|
|
| -// Submit the number of cycles the spinlock spent contending.
|
| -ATTRIBUTE_WEAK extern void SubmitSpinLockProfileData(const void *, int64);
|
| -extern void SubmitSpinLockProfileData(const void *contendedlock,
|
| - int64 wait_cycles) {}
|
| +int main(int argc, char **argv) {
|
| + grpc_test_init(argc, argv);
|
| + test(1);
|
| + test(2);
|
| + test(3);
|
| + test_mixed();
|
| + test_plugin();
|
| + return 0;
|
| }
|
| -#endif // BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_
|
|
|