Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Craig Tiller | 0605995 | 2015-02-18 08:34:56 -0800 | [diff] [blame] | 3 | * Copyright 2015, Google Inc. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 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 | |
Nicolas "Pixel" Noble | 1ff52d5 | 2015-03-01 05:24:36 +0100 | [diff] [blame] | 34 | #ifndef GRPC_TEST_CORE_END2END_CQ_VERIFIER_H |
| 35 | #define GRPC_TEST_CORE_END2END_CQ_VERIFIER_H |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 36 | |
David Garcia Quintas | fa2cc03 | 2016-05-17 13:47:40 -0700 | [diff] [blame] | 37 | #include <stdbool.h> |
| 38 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 39 | #include <grpc/grpc.h> |
Craig Tiller | 8ad8a41 | 2015-02-25 08:36:40 -0800 | [diff] [blame] | 40 | #include "test/core/util/test_config.h" |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 41 | |
| 42 | /* A cq_verifier can verify that expected events arrive in a timely fashion |
| 43 | on a single completion queue */ |
| 44 | |
| 45 | typedef struct cq_verifier cq_verifier; |
| 46 | |
| 47 | /* construct/destroy a cq_verifier */ |
| 48 | cq_verifier *cq_verifier_create(grpc_completion_queue *cq); |
| 49 | void cq_verifier_destroy(cq_verifier *v); |
| 50 | |
| 51 | /* ensure all expected events (and only those events) are present on the |
| 52 | bound completion queue */ |
| 53 | void cq_verify(cq_verifier *v); |
| 54 | |
| 55 | /* ensure that the completion queue is empty */ |
| 56 | void cq_verify_empty(cq_verifier *v); |
| 57 | |
David Garcia Quintas | 3fb8f73 | 2016-06-15 22:53:08 -0700 | [diff] [blame] | 58 | /* ensure that the completion queue is empty, waiting up to \a timeout secs. */ |
| 59 | void cq_verify_empty_timeout(cq_verifier *v, int timeout_sec); |
| 60 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 61 | /* Various expectation matchers |
| 62 | Any functions taking ... expect a NULL terminated list of key/value pairs |
| 63 | (each pair using two parameter slots) of metadata that MUST be present in |
| 64 | the event. */ |
Mark D. Roth | 661408c | 2016-08-26 13:45:01 -0700 | [diff] [blame] | 65 | void cq_expect_completion(cq_verifier *v, const char *file, int line, void *tag, |
| 66 | bool success); |
| 67 | #define CQ_EXPECT_COMPLETION(v, tag, success) \ |
| 68 | cq_expect_completion(v, __FILE__, __LINE__, tag, success) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 69 | |
Craig Tiller | d41a4a7 | 2016-10-26 16:16:06 -0700 | [diff] [blame] | 70 | int byte_buffer_eq_slice(grpc_byte_buffer *bb, grpc_slice b); |
Craig Tiller | 6a60cba | 2015-02-04 13:00:17 -0800 | [diff] [blame] | 71 | int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string); |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 72 | int contains_metadata(grpc_metadata_array *array, const char *key, |
| 73 | const char *value); |
Craig Tiller | 7c70b6c | 2017-01-23 07:48:42 -0800 | [diff] [blame] | 74 | int contains_metadata_slices(grpc_metadata_array *array, grpc_slice key, |
| 75 | grpc_slice value); |
Craig Tiller | 6a60cba | 2015-02-04 13:00:17 -0800 | [diff] [blame] | 76 | |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 77 | #endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_H */ |