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