• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2019-2021 Huawei Technologies Co., Ltd
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# ============================================================================
16CURRPATH=$(cd "$(dirname $0)" || exit; pwd)
17IGNORE_EXEC="--ignore=$CURRPATH/exec"
18PROJECT_PATH=$(cd ${CURRPATH}/../../.. || exit; pwd)
19
20if [ $BUILD_PATH ];then
21    echo "BUILD_PATH = $BUILD_PATH"
22else
23    BUILD_PATH=${PROJECT_PATH}/build
24    echo "BUILD_PATH = $BUILD_PATH"
25fi
26
27export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${BUILD_PATH}/third_party/gtest/lib
28export PYTHONPATH=$PYTHONPATH:${PROJECT_PATH}:${PROJECT_PATH}/tests/ut/cpp/python_input:${PROJECT_PATH}/tests/ut/python
29echo "export PYTHONPATH=$PYTHONPATH"
30export GC_COLLECT_IN_CELL=1
31
32if [ $# -eq 1 ]  &&  ([ "$1" == "stage1" ] || [ "$1" == "stage2" ] || [ "$1" == "stage3" ] || [ "$1" == "stage4" ]); then
33    if [ $1 == "stage1" ]; then
34        echo "run python dataset ut"
35        pytest -v $CURRPATH/dataset
36
37        RET=$?
38        if [ ${RET} -ne 0 ]; then
39            exit ${RET}
40        fi
41
42        echo "run python debugger gpu ut"
43        pytest -v $CURRPATH/debugger/gpu_tests
44
45        RET=$?
46        if [ ${RET} -ne 0 ]; then
47            exit ${RET}
48        fi
49
50    elif [ $1 == "stage2" ]; then
51        echo "run python parallel"
52        pytest -s $CURRPATH/parallel/*.py
53
54        RET=$?
55        if [ ${RET} -ne 0 ]; then
56            exit ${RET}
57        fi
58
59    elif [ $1 == "stage3" ]; then
60        echo "run python ops, pynative_mode, pipeline, train ut"
61        pytest -v $CURRPATH/ops $CURRPATH/pynative_mode
62
63        RET=$?
64        if [ ${RET} -ne 0 ]; then
65            exit ${RET}
66        fi
67
68        pytest -v $CURRPATH/pipeline $CURRPATH/train
69        RET=$?
70        if [ ${RET} -ne 0 ]; then
71            exit ${RET}
72        fi
73
74    elif [ $1 == "stage4" ]; then
75        echo "run ut"
76        pytest -v $CURRPATH/nn
77
78        RET=$?
79        if [ ${RET} -ne 0 ]; then
80            exit ${RET}
81        fi
82
83        pytest -v --ignore=$CURRPATH/dataset --ignore=$CURRPATH/debugger/gpu_tests --ignore=$CURRPATH/parallel --ignore=$CURRPATH/ops --ignore=$CURRPATH/pynative_mode --ignore=$CURRPATH/pipeline --ignore=$CURRPATH/train --ignore=$CURRPATH/nn $IGNORE_EXEC $CURRPATH
84
85        RET=$?
86        if [ ${RET} -ne 0 ]; then
87            exit ${RET}
88        fi
89    fi
90else
91    echo "run all python ut"
92    pytest $CURRPATH/dataset
93    RET=$?
94    if [ ${RET} -ne 0 ]; then
95        exit ${RET}
96    fi
97
98    pytest $CURRPATH/debugger/gpu_tests
99    RET=$?
100    if [ ${RET} -ne 0 ]; then
101        exit ${RET}
102    fi
103
104    pytest -v $CURRPATH/parallel/*.py
105    RET=$?
106    if [ ${RET} -ne 0 ]; then
107        exit ${RET}
108    fi
109
110    pytest -v $CURRPATH/ops $CURRPATH/pynative_mode
111    RET=$?
112    if [ ${RET} -ne 0 ]; then
113        exit ${RET}
114    fi
115
116    pytest -v $CURRPATH/pipeline $CURRPATH/train
117    RET=$?
118    if [ ${RET} -ne 0 ]; then
119        exit ${RET}
120    fi
121
122    pytest -v $CURRPATH/nn
123    RET=$?
124    if [ ${RET} -ne 0 ]; then
125        exit ${RET}
126    fi
127
128    pytest -v --ignore=$CURRPATH/dataset --ignore=$CURRPATH/debugger/gpu_tests --ignore=$CURRPATH/parallel --ignore=$CURRPATH/ops --ignore=$CURRPATH/pynative_mode --ignore=$CURRPATH/pipeline --ignore=$CURRPATH/train --ignore=$CURRPATH/nn $IGNORE_EXEC $CURRPATH
129    RET=$?
130    if [ ${RET} -ne 0 ]; then
131        exit ${RET}
132    fi
133fi
134
135RET=$?
136exit ${RET}
137