LCOV - code coverage report
Current view: top level - test/core/iomgr - endpoint_pair_test.c (source / functions) Hit Total Coverage
Test: tmp.zDYK9MVh93 Lines: 24 24 100.0 %
Date: 2015-10-10 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  * Copyright 2015, Google Inc.
       4             :  * All rights reserved.
       5             :  *
       6             :  * Redistribution and use in source and binary forms, with or without
       7             :  * modification, are permitted provided that the following conditions are
       8             :  * met:
       9             :  *
      10             :  *     * Redistributions of source code must retain the above copyright
      11             :  * notice, this list of conditions and the following disclaimer.
      12             :  *     * Redistributions in binary form must reproduce the above
      13             :  * copyright notice, this list of conditions and the following disclaimer
      14             :  * in the documentation and/or other materials provided with the
      15             :  * distribution.
      16             :  *     * Neither the name of Google Inc. nor the names of its
      17             :  * contributors may be used to endorse or promote products derived from
      18             :  * this software without specific prior written permission.
      19             :  *
      20             :  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
      21             :  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
      22             :  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
      23             :  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
      24             :  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
      25             :  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
      26             :  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      27             :  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      28             :  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      29             :  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
      30             :  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      31             :  *
      32             :  */
      33             : 
      34             : #include "src/core/iomgr/tcp_posix.h"
      35             : 
      36             : #include <grpc/grpc.h>
      37             : #include <grpc/support/alloc.h>
      38             : #include <grpc/support/log.h>
      39             : #include <grpc/support/time.h>
      40             : #include <grpc/support/useful.h>
      41             : #include "src/core/iomgr/endpoint_pair.h"
      42             : #include "test/core/util/test_config.h"
      43             : #include "test/core/iomgr/endpoint_tests.h"
      44             : 
      45             : static grpc_pollset g_pollset;
      46             : 
      47          33 : static void clean_up(void) {}
      48             : 
      49          33 : static grpc_endpoint_test_fixture create_fixture_endpoint_pair(
      50             :     size_t slice_size) {
      51          33 :   grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
      52             :   grpc_endpoint_test_fixture f;
      53          33 :   grpc_endpoint_pair p = grpc_iomgr_create_endpoint_pair("test", slice_size);
      54             : 
      55          33 :   f.client_ep = p.client;
      56          33 :   f.server_ep = p.server;
      57          33 :   grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, &g_pollset);
      58          33 :   grpc_endpoint_add_to_pollset(&exec_ctx, f.server_ep, &g_pollset);
      59          33 :   grpc_exec_ctx_finish(&exec_ctx);
      60             : 
      61          33 :   return f;
      62             : }
      63             : 
      64             : static grpc_endpoint_test_config configs[] = {
      65             :     {"tcp/tcp_socketpair", create_fixture_endpoint_pair, clean_up},
      66             : };
      67             : 
      68           1 : static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, int success) {
      69           1 :   grpc_pollset_destroy(p);
      70           1 : }
      71             : 
      72           1 : int main(int argc, char **argv) {
      73             :   grpc_closure destroyed;
      74           1 :   grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
      75           1 :   grpc_test_init(argc, argv);
      76           1 :   grpc_init();
      77           1 :   grpc_pollset_init(&g_pollset);
      78           1 :   grpc_endpoint_tests(configs[0], &g_pollset);
      79           1 :   grpc_closure_init(&destroyed, destroy_pollset, &g_pollset);
      80           1 :   grpc_pollset_shutdown(&exec_ctx, &g_pollset, &destroyed);
      81           1 :   grpc_exec_ctx_finish(&exec_ctx);
      82           1 :   grpc_shutdown();
      83             : 
      84           1 :   return 0;
      85             : }

Generated by: LCOV version 1.10