blob: 035aa270e4a297a57d719451ba352e054d674565 [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
Craig Tiller06059952015-02-18 08:34:56 -08003 * Copyright 2015, Google Inc.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 * 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" Noble1ff52d52015-03-01 05:24:36 +010034#ifndef GRPC_TEST_CORE_END2END_CQ_VERIFIER_H
35#define GRPC_TEST_CORE_END2END_CQ_VERIFIER_H
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080036
David Garcia Quintasfa2cc032016-05-17 13:47:40 -070037#include <stdbool.h>
38
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080039#include <grpc/grpc.h>
Craig Tiller8ad8a412015-02-25 08:36:40 -080040#include "test/core/util/test_config.h"
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080041
42/* A cq_verifier can verify that expected events arrive in a timely fashion
43 on a single completion queue */
44
45typedef struct cq_verifier cq_verifier;
46
47/* construct/destroy a cq_verifier */
48cq_verifier *cq_verifier_create(grpc_completion_queue *cq);
49void cq_verifier_destroy(cq_verifier *v);
50
51/* ensure all expected events (and only those events) are present on the
52 bound completion queue */
53void cq_verify(cq_verifier *v);
54
55/* ensure that the completion queue is empty */
56void cq_verify_empty(cq_verifier *v);
57
David Garcia Quintas3fb8f732016-06-15 22:53:08 -070058/* ensure that the completion queue is empty, waiting up to \a timeout secs. */
59void cq_verify_empty_timeout(cq_verifier *v, int timeout_sec);
60
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080061/* 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. Roth661408c2016-08-26 13:45:01 -070065void 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 Nobleb7ebd3b2014-11-26 16:33:03 -080069
Craig Tillerd41a4a72016-10-26 16:16:06 -070070int byte_buffer_eq_slice(grpc_byte_buffer *bb, grpc_slice b);
Craig Tiller6a60cba2015-02-04 13:00:17 -080071int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string);
Craig Tillerd6c98df2015-08-18 09:33:44 -070072int contains_metadata(grpc_metadata_array *array, const char *key,
73 const char *value);
Craig Tiller7c70b6c2017-01-23 07:48:42 -080074int contains_metadata_slices(grpc_metadata_array *array, grpc_slice key,
75 grpc_slice value);
Craig Tiller6a60cba2015-02-04 13:00:17 -080076
Craig Tillerd6c98df2015-08-18 09:33:44 -070077#endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_H */