Debian Codegraph @

src/external/googletest/ci/linux-presubmit.sh

raw
1 #!/bin/bash
2 #
3 # Copyright 2020, Google Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are
8 # met:
9 #
10 # * Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following disclaimer
14 # in the documentation and/or other materials provided with the
15 # distribution.
16 # * Neither the name of Google Inc. nor the names of its
17 # contributors may be used to endorse or promote products derived from
18 # this software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 set -euox pipefail
33
34 readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20241218"
35 readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20250205"
36
37 if [[ -z ${GTEST_ROOT:-} ]]; then
38 GTEST_ROOT="$(realpath $(dirname ${0})/..)"
39 fi
40
41 if [[ -z ${STD:-} ]]; then
42 STD="c++17 c++20"
43 fi
44
45 # Test CMake + GCC
46 for cmake_off_on in OFF ON; do
47 time docker run \
48 --volume="${GTEST_ROOT}:/src:ro" \
49 --tmpfs="/build:exec" \
50 --workdir="/build" \
51 --rm \
52 --env="CC=/usr/local/bin/gcc" \
53 --env=CXXFLAGS="-Werror -Wdeprecated" \
54 ${LINUX_LATEST_CONTAINER} \
55 /bin/bash -c "
56 cmake /src \
57 -DCMAKE_CXX_STANDARD=17 \
58 -Dgtest_build_samples=ON \
59 -Dgtest_build_tests=ON \
60 -Dgmock_build_tests=ON \
61 -Dcxx_no_exception=${cmake_off_on} \
62 -Dcxx_no_rtti=${cmake_off_on} && \
63 make -j$(nproc) && \
64 ctest -j$(nproc) --output-on-failure"
65 done
66
67 # Test CMake + Clang
68 for cmake_off_on in OFF ON; do
69 time docker run \
70 --volume="${GTEST_ROOT}:/src:ro" \
71 --tmpfs="/build:exec" \
72 --workdir="/build" \
73 --rm \
74 --env="CC=/opt/llvm/clang/bin/clang" \
75 --env=CXXFLAGS="-Werror -Wdeprecated --gcc-toolchain=/usr/local" \
76 ${LINUX_LATEST_CONTAINER} \
77 /bin/bash -c "
78 cmake /src \
79 -DCMAKE_CXX_STANDARD=17 \
80 -Dgtest_build_samples=ON \
81 -Dgtest_build_tests=ON \
82 -Dgmock_build_tests=ON \
83 -Dcxx_no_exception=${cmake_off_on} \
84 -Dcxx_no_rtti=${cmake_off_on} && \
85 make -j$(nproc) && \
86 ctest -j$(nproc) --output-on-failure"
87 done
88
89 # Do one test with an older version of GCC
90 time docker run \
91 --volume="${GTEST_ROOT}:/src:ro" \
92 --workdir="/src" \
93 --rm \
94 --env="CC=/usr/local/bin/gcc" \
95 --env="BAZEL_CXXOPTS=-std=c++17" \
96 ${LINUX_GCC_FLOOR_CONTAINER} \
97 /usr/local/bin/bazel test ... \
98 --copt="-Wall" \
99 --copt="-Werror" \
100 --copt="-Wuninitialized" \
101 --copt="-Wundef" \
102 --copt="-Wno-error=pragmas" \
103 --enable_bzlmod=false \
104 --features=external_include_paths \
105 --keep_going \
106 --show_timestamps \
107 --test_output=errors
108
109 # Test GCC
110 for std in ${STD}; do
111 for absl in 0 1; do
112 time docker run \
113 --volume="${GTEST_ROOT}:/src:ro" \
114 --workdir="/src" \
115 --rm \
116 --env="CC=/usr/local/bin/gcc" \
117 --env="BAZEL_CXXOPTS=-std=${std}" \
118 ${LINUX_LATEST_CONTAINER} \
119 /usr/local/bin/bazel test ... \
120 --copt="-Wall" \
121 --copt="-Werror" \
122 --copt="-Wuninitialized" \
123 --copt="-Wundef" \
124 --define="absl=${absl}" \
125 --enable_bzlmod=true \
126 --features=external_include_paths \
127 --keep_going \
128 --show_timestamps \
129 --test_output=errors
130 done
131 done
132
133 # Test Clang
134 for std in ${STD}; do
135 for absl in 0 1; do
136 time docker run \
137 --volume="${GTEST_ROOT}:/src:ro" \
138 --workdir="/src" \
139 --rm \
140 --env="CC=/opt/llvm/clang/bin/clang" \
141 --env="BAZEL_CXXOPTS=-std=${std}" \
142 ${LINUX_LATEST_CONTAINER} \
143 /usr/local/bin/bazel test ... \
144 --copt="--gcc-toolchain=/usr/local" \
145 --copt="-Wall" \
146 --copt="-Werror" \
147 --copt="-Wuninitialized" \
148 --copt="-Wundef" \
149 --define="absl=${absl}" \
150 --enable_bzlmod=true \
151 --features=external_include_paths \
152 --keep_going \
153 --linkopt="--gcc-toolchain=/usr/local" \
154 --show_timestamps \
155 --test_output=errors
156 done
157 done