blob: cae49271ee19081c13732173e1605d4423c03386 [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
Craig Tiller42bc87c2015-02-23 08:50:19 -080034#include <grpc/grpc.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080035
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);
Craig Tillerc4f0ebe2015-02-02 10:16:30 -080054 call = grpc_channel_create_call_old(
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080055 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 */
Craig Tillerc4f0ebe2015-02-02 10:16:30 -080062 GPR_ASSERT(GRPC_CALL_OK == grpc_call_add_metadata_old(call, &md, 0));
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080063
64 /* and invoke the call */
Craig Tillerc4f0ebe2015-02-02 10:16:30 -080065 GPR_ASSERT(GRPC_CALL_OK == grpc_call_invoke_old(call, cq, tag(2), tag(3), 0));
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080066
67 /* the call should immediately fail */
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080068 cq_expect_client_metadata_read(cqv, tag(2), NULL);
69 cq_expect_finished(cqv, tag(3), NULL);
70 cq_verify(cqv);
71
72 grpc_call_destroy(call);
73 grpc_channel_destroy(chan);
74 cq_verifier_destroy(cqv);
75 grpc_completion_queue_destroy(cq);
76
77 grpc_shutdown();
78
79 return 0;
Craig Tiller190d3602015-02-18 09:23:38 -080080}