blob: 11d5e4a4951df5d112e7cb4a9c16c68b2d64a5cd [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
3 * Copyright 2014, 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/surface/lame_client.h"
35
36#include "test/core/end2end/cq_verifier.h"
37#include "test/core/util/test_config.h"
38#include <grpc/support/log.h>
39
40static void *tag(gpr_intptr x) { return (void *)x; }
41
42int main(int argc, char **argv) {
43 grpc_channel *chan;
44 grpc_call *call;
45 grpc_metadata md = {"a", "b", 1};
46 grpc_completion_queue *cq;
47 cq_verifier *cqv;
48
49 grpc_test_init(argc, argv);
50 grpc_init();
51
52 chan = grpc_lame_client_channel_create();
53 GPR_ASSERT(chan);
54 call = grpc_channel_create_call(
55 chan, "/Foo", "anywhere",
56 gpr_time_add(gpr_now(), gpr_time_from_seconds(100)));
57 GPR_ASSERT(call);
58 cq = grpc_completion_queue_create();
59 cqv = cq_verifier_create(cq);
60
61 /* we should be able to add metadata */
62 GPR_ASSERT(GRPC_CALL_OK == grpc_call_add_metadata(call, &md, 0));
63
64 /* and invoke the call */
65 GPR_ASSERT(GRPC_CALL_OK ==
Craig Tiller80fa15c2015-01-13 16:10:49 -080066 grpc_call_invoke(call, cq, tag(2), tag(3), 0));
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080067
68 /* the call should immediately fail */
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080069 cq_expect_client_metadata_read(cqv, tag(2), NULL);
70 cq_expect_finished(cqv, tag(3), NULL);
71 cq_verify(cqv);
72
73 grpc_call_destroy(call);
74 grpc_channel_destroy(chan);
75 cq_verifier_destroy(cqv);
76 grpc_completion_queue_destroy(cq);
77
78 grpc_shutdown();
79
80 return 0;
81}