Skip to content

Commit

Permalink
Add CI Test (PaddlePaddle#30)
Browse files Browse the repository at this point in the history
1. Add piano_ci_test.sh, which runs the ctests that has corresponding files under `paddle/fluid/compiler` folder.
2. Add `libtinfo-dev` to Dockerfile
3. Change `piano_layout_test` and `piano_shape_test` to `layout_test` and `shape_test`
4. Add `-DWITH_COMPILER` into `paddle_build.sh`
  • Loading branch information
zhhsplendid authored Aug 17, 2021
1 parent 50275fb commit f6c3b77
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 3 deletions.
4 changes: 2 additions & 2 deletions paddle/fluid/compiler/piano/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ add_subdirectory(backends)
add_subdirectory(note)

cc_library(piano_data_description SRCS layout.cc shape.cc DEPS string_helper note_proto)
cc_test(piano_layout_test SRCS layout_test.cc DEPS piano_data_description)
cc_test(piano_shape_test SRCS shape_test.cc DEPS piano_data_description)
cc_test(layout_test SRCS layout_test.cc DEPS piano_data_description)
cc_test(shape_test SRCS shape_test.cc DEPS piano_data_description)
131 changes: 131 additions & 0 deletions paddle/fluid/compiler/scripts/piano_ci_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/usr/bin/env bash

# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -ex

if [ -z ${BRANCH} ]; then
BRANCH="paddle_compiler"
fi

function init() {
RED='\033[0;31m'
BLUE='\033[0;34m'
BOLD='\033[1m'
NONE='\033[0m'

PADDLE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}")/../../../../" && pwd )"
export PADDLE_ROOT
if [ -z "${SCRIPT_NAME}" ]; then
SCRIPT_NAME=$0
fi

ENABLE_MAKE_CLEAN=${ENABLE_MAKE_CLEAN:-ON}

# NOTE(chenweihang): For easy debugging, CI displays the C++ error stacktrace by default
export FLAGS_call_stack_level=2

# set CI_SKIP_CPP_TEST if only *.py changed
# In order to avoid using in some CI(such as daily performance), the current
# branch must not be `${BRANCH}` which is usually develop.
if [ ${CI_SKIP_CPP_TEST:-ON} == "OFF" ];then
echo "CI_SKIP_CPP_TEST=OFF"
else
if [ "$(git branch | grep "^\*" | awk '{print $2}')" != "${BRANCH}" ]; then
git diff --name-only ${BRANCH} | grep -v "\.py$" || export CI_SKIP_CPP_TEST=ON
fi
fi
}

function parallel_test() {
mkdir -p ${PADDLE_ROOT}/build
cd ${PADDLE_ROOT}/build
pip install ${PADDLE_ROOT}/build/python/dist/*whl
cp ${PADDLE_ROOT}/build/python/paddle/fluid/tests/unittests/op_test.py ${PADDLE_ROOT}/build/python
ut_total_startTime_s=`date +%s`

EXIT_CODE=0

all_ctests=$(ctest -N | awk -F ': ' '{print $2}' | sed '/^$/d' | sed '$d')
compiler_files_contains_test=$(find ${PADDLE_ROOT}/paddle/fluid/compiler -iname "*test*" -type f)

# Temporary directory to save failed Piano test
tmp_dir=`mktemp -d`
echo "Created temporary directory to store test result:" $tmp_dir

piano_test_list=''
for test_case in $all_ctests; do
is_piano_test=0
for test_file in $compiler_files_contains_test; do
if [[ $test_file =~ $test_case ]]; then
is_piano_test=1
break
fi
done

if [ $is_piano_test = 1 ]; then
tmp_file_rand=`date +%s%N`
tmp_file=$tmp_dir/$tmp_file_rand
ctest -R $test_case --output-on-failure | tee $tmp_file
piano_test_list="${piano_test_list}
${test_case}"
fi
done

failed_test_lists=''
set +e
for file in `ls $tmp_dir`; do
grep -q 'The following tests FAILED:' $tmp_dir/$file
grep_exit_code=$?
if [ $grep_exit_code -ne 0 ]; then
failed_test=''
else
EXIT_CODE=8
failed_test=`grep -A 10000 'The following tests FAILED:' $tmp_dir/$file | sed 's/The following tests FAILED://g'|sed '/^$/d'`
failed_test_lists="${failed_test_lists}
${failed_test}"
fi
done
set -e

rm -rf $tmp_dir
echo "Removed temporary directory which stores test result:" $tmp_dir

if [ $EXIT_CODE != 0 ]; then
echo "========================================="
echo "The following tests FAILED:"
echo "========================================="
echo "${failed_test_lists}"
exit 8;
fi

ut_total_endTime_s=`date +%s`
echo "========================================="
echo "The following tests SUCCESSED:"
echo "========================================="
echo "${piano_test_list}"
echo ""
echo "TestCases Total Time: $[ $ut_total_endTime_s - $ut_total_startTime_s ]s"
echo "ipipe_log_param_TestCases_Total_Time: $[ $ut_total_endTime_s - $ut_total_startTime_s ]s"
}

function main() {
init
parallel_test

echo "piano_ci_test script finished as expected"
}

main $@
2 changes: 2 additions & 0 deletions paddle/scripts/paddle_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ function cmake_base() {
-DWITH_GPU=${WITH_GPU:-OFF}
-DWITH_TENSORRT=${WITH_TENSORRT:-ON}
-DWITH_ROCM=${WITH_ROCM:-OFF}
-DWITH_COMPILER=${WITH_COMPILER:-OFF}
-DWITH_DISTRIBUTE=${distibuted_flag}
-DWITH_MKL=${WITH_MKL:-ON}
-DWITH_AVX=${WITH_AVX:-OFF}
Expand Down Expand Up @@ -242,6 +243,7 @@ EOF
-DWITH_GPU=${WITH_GPU:-OFF} \
-DWITH_TENSORRT=${WITH_TENSORRT:-ON} \
-DWITH_ROCM=${WITH_ROCM:-OFF} \
-DWITH_COMPILER=${WITH_COMPILER:-OFF} \
-DWITH_DISTRIBUTE=${distibuted_flag} \
-DWITH_MKL=${WITH_MKL:-ON} \
-DWITH_AVX=${WITH_AVX:-OFF} \
Expand Down
2 changes: 1 addition & 1 deletion tools/dockerfile/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY paddle/scripts/docker/root/ /root/
RUN apt-get update && \
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev
xz-utils tk-dev libffi-dev liblzma-dev libtinfo-dev

RUN apt-get update && \
apt-get install -y --allow-downgrades --allow-change-held-packages \
Expand Down

0 comments on commit f6c3b77

Please sign in to comment.