xref: /aosp_15_r20/external/grpc-grpc/test/cpp/interop/interop_test_with_metadata_log.sh (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1#!/bin/bash
2# Copyright 2021 The gRPC Authors
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16set -ex
17
18LOGFILE="$(mktemp)"
19
20# Location of the interop test binary is different depending
21# on whether we are running externally/internally, so we try both.
22INTEROP_TEST_BINARY="test/cpp/interop/interop_test"
23test -x "${INTEROP_TEST_BINARY}" || INTEROP_TEST_BINARY="third_party/grpc/${INTEROP_TEST_BINARY}"
24
25# Test that the --log_metadata_and_status flag generates the expected logs in the right format
26# by running the "custom_metadata" interop test case and inspect the logs afterwards.
27"${INTEROP_TEST_BINARY}" --extra_client_flags="--test_case=custom_metadata,--log_metadata_and_status" 2>&1 | tee "${LOGFILE}"
28
29# grep will return an error if any of the patterns below are not found in the log
30grep -q "GRPC_INITIAL_METADATA x-grpc-test-echo-initial: test_initial_metadata_value" "${LOGFILE}"
31grep -q "GRPC_TRAILING_METADATA x-grpc-test-echo-trailing-bin: CgsKCwoL" "${LOGFILE}"
32grep -q "GRPC_ERROR_MESSAGE " "${LOGFILE}"
33grep -q "GRPC_STATUS 0" "${LOGFILE}"
34
35echo "Passed."
36