1 /* 2 * 3 * Copyright 2015 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #ifndef GRPC_TEST_CORE_END2END_CQ_VERIFIER_H 20 #define GRPC_TEST_CORE_END2END_CQ_VERIFIER_H 21 22 #include <stdbool.h> 23 24 #include <grpc/grpc.h> 25 #include "test/core/util/test_config.h" 26 27 /* A cq_verifier can verify that expected events arrive in a timely fashion 28 on a single completion queue */ 29 30 typedef struct cq_verifier cq_verifier; 31 32 /* construct/destroy a cq_verifier */ 33 cq_verifier* cq_verifier_create(grpc_completion_queue* cq); 34 void cq_verifier_destroy(cq_verifier* v); 35 36 /* ensure all expected events (and only those events) are present on the 37 bound completion queue */ 38 void cq_verify(cq_verifier* v); 39 40 /* ensure that the completion queue is empty */ 41 void cq_verify_empty(cq_verifier* v); 42 43 /* ensure that the completion queue is empty, waiting up to \a timeout secs. */ 44 void cq_verify_empty_timeout(cq_verifier* v, int timeout_sec); 45 46 /* Various expectation matchers 47 Any functions taking ... expect a NULL terminated list of key/value pairs 48 (each pair using two parameter slots) of metadata that MUST be present in 49 the event. */ 50 void cq_expect_completion(cq_verifier* v, const char* file, int line, void* tag, 51 bool success); 52 void cq_expect_completion_any_status(cq_verifier* v, const char* file, int line, 53 void* tag); 54 #define CQ_EXPECT_COMPLETION(v, tag, success) \ 55 cq_expect_completion(v, __FILE__, __LINE__, tag, success) 56 #define CQ_EXPECT_COMPLETION_ANY_STATUS(v, tag) \ 57 cq_expect_completion_any_status(v, __FILE__, __LINE__, tag) 58 59 int byte_buffer_eq_slice(grpc_byte_buffer* bb, grpc_slice b); 60 int byte_buffer_eq_string(grpc_byte_buffer* byte_buffer, const char* string); 61 int contains_metadata(grpc_metadata_array* array, const char* key, 62 const char* value); 63 int contains_metadata_slices(grpc_metadata_array* array, grpc_slice key, 64 grpc_slice value); 65 66 #endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_H */ 67