xref: /aosp_15_r20/external/grpc-grpc/tools/bazelify_tests/grpc_run_distribtest_test.sh (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1#!/bin/bash
2# Copyright 2023 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 -e
17
18ARCHIVE_WITH_SUBMODULES="$1"
19BUILD_SCRIPT="$2"
20shift 2
21
22# Extract grpc repo archive
23tar -xopf ${ARCHIVE_WITH_SUBMODULES}
24cd grpc
25
26# Extract all input archives with artifacts into input_artifacts directory
27# TODO(jtattermusch): Deduplicate the snippet below (it appears in multiple files).
28mkdir -p input_artifacts
29pushd input_artifacts >/dev/null
30# all remaining args are .tar.gz archives with input artifacts
31for input_artifact_archive in "$@"
32do
33  # extract the .tar.gz with artifacts into a directory named after a basename
34  # of the archive itself (and strip the "artifact/" prefix)
35  # Note that input artifacts from different dependencies can have files
36  # with the same name, so disambiguating through the name of the archive
37  # is important.
38  archive_extract_dir="$(basename ${input_artifact_archive} .tar.gz)"
39  mkdir -p "${archive_extract_dir}"
40  pushd "${archive_extract_dir}" >/dev/null
41  tar --strip-components=1 -xopf ../../../${input_artifact_archive}
42  popd >/dev/null
43done
44popd >/dev/null
45
46ls -lR input_artifacts
47
48# Run build script passed as arg.
49"${BUILD_SCRIPT}"
50