h2_local_uds.cc 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #include <inttypes.h>
  19. #include <unistd.h>
  20. #include "absl/strings/str_format.h"
  21. #include <grpc/support/string_util.h>
  22. #include "test/core/end2end/end2end_tests.h"
  23. #include "test/core/end2end/fixtures/local_util.h"
  24. #include "test/core/util/test_config.h"
  25. static int unique = 1;
  26. static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_uds(
  27. const grpc_channel_args* /*client_args*/,
  28. const grpc_channel_args* /*server_args*/) {
  29. grpc_end2end_test_fixture f =
  30. grpc_end2end_local_chttp2_create_fixture_fullstack();
  31. gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
  32. static_cast<grpc_end2end_local_fullstack_fixture_data*>(f.fixture_data)
  33. ->localaddr = absl::StrFormat(
  34. "unix:/tmp/grpc_fullstack_test.%d.%" PRId64 ".%" PRId32 ".%d", getpid(),
  35. now.tv_sec, now.tv_nsec, unique++);
  36. return f;
  37. }
  38. static void chttp2_init_client_fullstack_uds(
  39. grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) {
  40. grpc_end2end_local_chttp2_init_client_fullstack(f, client_args, UDS);
  41. }
  42. static void chttp2_init_server_fullstack_uds(
  43. grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) {
  44. grpc_end2end_local_chttp2_init_server_fullstack(f, client_args, UDS);
  45. }
  46. /* All test configurations */
  47. static grpc_end2end_test_config configs[] = {
  48. {"chttp2/fullstack_local_uds",
  49. FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
  50. FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
  51. FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER |
  52. FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS,
  53. nullptr, chttp2_create_fixture_fullstack_uds,
  54. chttp2_init_client_fullstack_uds, chttp2_init_server_fullstack_uds,
  55. grpc_end2end_local_chttp2_tear_down_fullstack}};
  56. int main(int argc, char** argv) {
  57. size_t i;
  58. grpc::testing::TestEnvironment env(argc, argv);
  59. grpc_end2end_tests_pre_init();
  60. grpc_init();
  61. for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
  62. grpc_end2end_tests(argc, argv, configs[i]);
  63. }
  64. grpc_shutdown();
  65. return 0;
  66. }