Debian Codegraph @

test/core/end2end/end2end_test_utils.cc

raw
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 #include <grpc/slice.h>
20 #include <grpc/support/log.h>
21
22 #include "test/core/end2end/end2end_tests.h"
23
24 const char* get_host_override_string(const char* str,
25 grpc_end2end_test_config config) {
26 if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) {
27 return str;
28 } else {
29 return nullptr;
30 }
31 }
32
33 const grpc_slice* get_host_override_slice(const char* str,
34 grpc_end2end_test_config config) {
35 const char* r = get_host_override_string(str, config);
36 if (r != nullptr) {
37 static grpc_slice ret;
38 ret = grpc_slice_from_static_string(r);
39 return &ret;
40 }
41 return nullptr;
42 }
43
44 void validate_host_override_string(const char* pattern, grpc_slice str,
45 grpc_end2end_test_config config) {
46 if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) {
47 GPR_ASSERT(0 == grpc_slice_str_cmp(str, pattern));
48 }
49 }