19d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson#!/bin/bash 24ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# 34ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# Copyright 2008, Google Inc. 44ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# All rights reserved. 54ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# 64ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# Redistribution and use in source and binary forms, with or without 74ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# modification, are permitted provided that the following conditions are 84ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# met: 94ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# 104ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# * Redistributions of source code must retain the above copyright 114ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# notice, this list of conditions and the following disclaimer. 124ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# * Redistributions in binary form must reproduce the above 134ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# copyright notice, this list of conditions and the following disclaimer 144ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# in the documentation and/or other materials provided with the 154ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# distribution. 164ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# * Neither the name of Google Inc. nor the names of its 174ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# contributors may be used to endorse or promote products derived from 184ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# this software without specific prior written permission. 194ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# 204ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 214ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 224ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 234ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 244ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 254ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 264ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 274ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 284ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 294ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 304ed70b139807f76eff9c401144baef6bffca481fzhanyong.wan# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 319d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson 320ee54f996f44ba697e6e13f6a4430c154b38625dpreston.a.jackson# Executes the samples and tests for the Google Test Framework. 339d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson 340ee54f996f44ba697e6e13f6a4430c154b38625dpreston.a.jackson# Help the dynamic linker find the path to the libraries. 359d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jacksonexport DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR 360ee54f996f44ba697e6e13f6a4430c154b38625dpreston.a.jacksonexport DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR 379d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson 380ee54f996f44ba697e6e13f6a4430c154b38625dpreston.a.jackson# Create some executables. 390ee54f996f44ba697e6e13f6a4430c154b38625dpreston.a.jacksontest_executables=("$BUILT_PRODUCTS_DIR/gtest_unittest-framework" 404dcf9e4b2bf0d87229194165bbb0986e5f73534apreston.a.jackson "$BUILT_PRODUCTS_DIR/gtest_unittest" 410ee54f996f44ba697e6e13f6a4430c154b38625dpreston.a.jackson "$BUILT_PRODUCTS_DIR/sample1_unittest-framework" 420ee54f996f44ba697e6e13f6a4430c154b38625dpreston.a.jackson "$BUILT_PRODUCTS_DIR/sample1_unittest-static") 439d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson 449d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson# Now execute each one in turn keeping track of how many succeeded and failed. 459d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jacksonsucceeded=0 469d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jacksonfailed=0 47e44602ec83c65102035ce5304ae8de0cb16e9e56shiqianfailed_list=() 489d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jacksonfor test in ${test_executables[*]}; do 499d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson "$test" 509d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson result=$? 519d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson if [ $result -eq 0 ]; then 529d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson succeeded=$(( $succeeded + 1 )) 539d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson else 549d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson failed=$(( failed + 1 )) 55e44602ec83c65102035ce5304ae8de0cb16e9e56shiqian failed_list="$failed_list $test" 569d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson fi 579d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jacksondone 589d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jackson 590ee54f996f44ba697e6e13f6a4430c154b38625dpreston.a.jackson# Report the successes and failures to the console. 609d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jacksonecho "Tests complete with $succeeded successes and $failed failures." 61e44602ec83c65102035ce5304ae8de0cb16e9e56shiqianif [ $failed -ne 0 ]; then 62e44602ec83c65102035ce5304ae8de0cb16e9e56shiqian echo "The following tests failed:" 63e44602ec83c65102035ce5304ae8de0cb16e9e56shiqian echo $failed_list 64e44602ec83c65102035ce5304ae8de0cb16e9e56shiqianfi 659d2c8d16f148a95f81944d2020adb987c0d55e7bpreston.jacksonexit $failed 66