h2_local_ipv4.cc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. *
  3. * Copyright 2018 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. #include <unistd.h>
  19. #include <grpc/support/string_util.h>
  20. #include "src/core/lib/gprpp/host_port.h"
  21. #include "test/core/end2end/end2end_tests.h"
  22. #include "test/core/end2end/fixtures/local_util.h"
  23. #include "test/core/util/port.h"
  24. #include "test/core/util/test_config.h"
  25. static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_ipv4(
  26. const grpc_channel_args* /*client_args*/,
  27. const grpc_channel_args* /*server_args*/) {
  28. grpc_end2end_test_fixture f =
  29. grpc_end2end_local_chttp2_create_fixture_fullstack();
  30. int port = grpc_pick_unused_port_or_die();
  31. static_cast<grpc_end2end_local_fullstack_fixture_data*>(f.fixture_data)
  32. ->localaddr = grpc_core::JoinHostPort("127.0.0.1", port);
  33. return f;
  34. }
  35. static void chttp2_init_client_fullstack_ipv4(
  36. grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) {
  37. grpc_end2end_local_chttp2_init_client_fullstack(f, client_args, LOCAL_TCP);
  38. }
  39. static void chttp2_init_server_fullstack_ipv4(
  40. grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) {
  41. grpc_end2end_local_chttp2_init_server_fullstack(f, client_args, LOCAL_TCP);
  42. }
  43. /* All test configurations */
  44. static grpc_end2end_test_config configs[] = {
  45. {"chttp2/fullstack_local_ipv4",
  46. FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
  47. FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
  48. FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER |
  49. FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS,
  50. nullptr, chttp2_create_fixture_fullstack_ipv4,
  51. chttp2_init_client_fullstack_ipv4, chttp2_init_server_fullstack_ipv4,
  52. grpc_end2end_local_chttp2_tear_down_fullstack}};
  53. int main(int argc, char** argv) {
  54. size_t i;
  55. grpc::testing::TestEnvironment env(argc, argv);
  56. grpc_end2end_tests_pre_init();
  57. grpc_init();
  58. for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
  59. grpc_end2end_tests(argc, argv, configs[i]);
  60. }
  61. grpc_shutdown();
  62. return 0;
  63. }