• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_END2END_TESTS_H
20 #define GRPC_TEST_CORE_END2END_END2END_TESTS_H
21 
22 #include <grpc/grpc.h>
23 
24 typedef struct grpc_end2end_test_fixture grpc_end2end_test_fixture;
25 typedef struct grpc_end2end_test_config grpc_end2end_test_config;
26 
27 /* Test feature flags. */
28 #define FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION 1
29 #define FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION 2
30 #define FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS 4
31 #define FEATURE_MASK_SUPPORTS_REQUEST_PROXYING 8
32 #define FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL 16
33 #define FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER 32
34 #define FEATURE_MASK_DOES_NOT_SUPPORT_RESOURCE_QUOTA_SERVER 64
35 #define FEATURE_MASK_DOES_NOT_SUPPORT_NETWORK_STATUS_CHANGE 128
36 #define FEATURE_MASK_SUPPORTS_WORKAROUNDS 256
37 #define FEATURE_MASK_DOES_NOT_SUPPORT_SEND_CALL_CREDENTIALS 512
38 #define FEATURE_MASK_DOES_NOT_SUPPORT_CLIENT_HANDSHAKE_COMPLETE_FIRST 1024
39 
40 #define FAIL_AUTH_CHECK_SERVER_ARG_NAME "fail_auth_check"
41 
42 struct grpc_end2end_test_fixture {
43   grpc_completion_queue* cq;
44   grpc_completion_queue* shutdown_cq;
45   grpc_server* server;
46   grpc_channel* client;
47   void* fixture_data;
48 };
49 
50 struct grpc_end2end_test_config {
51   /* A descriptive name for this test fixture. */
52   const char* name;
53 
54   /* Which features are supported by this fixture. See feature flags above. */
55   uint32_t feature_mask;
56 
57   /* If the call host is setup by the fixture (for example, via the
58    * GRPC_SSL_TARGET_NAME_OVERRIDE_ARG channel arg), which value should the test
59    * expect to find in call_details.host */
60   const char* overridden_call_host;
61 
62   grpc_end2end_test_fixture (*create_fixture)(grpc_channel_args* client_args,
63                                               grpc_channel_args* server_args);
64   void (*init_client)(grpc_end2end_test_fixture* f,
65                       grpc_channel_args* client_args);
66   void (*init_server)(grpc_end2end_test_fixture* f,
67                       grpc_channel_args* server_args);
68   void (*tear_down_data)(grpc_end2end_test_fixture* f);
69 };
70 
71 void grpc_end2end_tests_pre_init(void);
72 void grpc_end2end_tests(int argc, char** argv, grpc_end2end_test_config config);
73 
74 const char* get_host_override_string(const char* str,
75                                      grpc_end2end_test_config config);
76 /* Returns a pointer to a statically allocated slice: future invocations
77    overwrite past invocations, not threadsafe, etc... */
78 const grpc_slice* get_host_override_slice(const char* str,
79                                           grpc_end2end_test_config config);
80 
81 void validate_host_override_string(const char* pattern, grpc_slice str,
82                                    grpc_end2end_test_config config);
83 
84 #endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */
85