mirror of https://github.com/grpc/grpc.git
The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)
https://grpc.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.5 KiB
72 lines
1.5 KiB
10 years ago
|
/*
|
||
|
*
|
||
8 years ago
|
* Copyright 2015 gRPC authors.
|
||
10 years ago
|
*
|
||
8 years ago
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
10 years ago
|
*
|
||
8 years ago
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
10 years ago
|
*
|
||
8 years ago
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
10 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
#include <grpc/grpc.h>
|
||
9 years ago
|
#include <grpc/support/log.h>
|
||
10 years ago
|
#include "test/core/util/test_config.h"
|
||
|
|
||
9 years ago
|
static int g_flag;
|
||
|
|
||
10 years ago
|
static void test(int rounds) {
|
||
|
int i;
|
||
|
for (i = 0; i < rounds; i++) {
|
||
|
grpc_init();
|
||
|
}
|
||
|
for (i = 0; i < rounds; i++) {
|
||
|
grpc_shutdown();
|
||
|
}
|
||
|
}
|
||
|
|
||
9 years ago
|
static void test_mixed(void) {
|
||
10 years ago
|
grpc_init();
|
||
|
grpc_init();
|
||
|
grpc_shutdown();
|
||
|
grpc_init();
|
||
|
grpc_shutdown();
|
||
|
grpc_shutdown();
|
||
|
}
|
||
|
|
||
9 years ago
|
static void plugin_init(void) { g_flag = 1; }
|
||
|
static void plugin_destroy(void) { g_flag = 2; }
|
||
9 years ago
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
8 years ago
|
static void test_repeatedly() {
|
||
7 years ago
|
for (int i = 0; i < 1000; i++) {
|
||
8 years ago
|
grpc_init();
|
||
|
grpc_shutdown();
|
||
|
}
|
||
|
}
|
||
|
|
||
7 years ago
|
int main(int argc, char** argv) {
|
||
10 years ago
|
grpc_test_init(argc, argv);
|
||
|
test(1);
|
||
|
test(2);
|
||
|
test(3);
|
||
10 years ago
|
test_mixed();
|
||
9 years ago
|
test_plugin();
|
||
8 years ago
|
test_repeatedly();
|
||
10 years ago
|
return 0;
|
||
10 years ago
|
}
|