• 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"
18
19source $CURRPATH/env.sh
20
21if [ $# -eq 1 ]  &&  ([ "$1" == "stage1" ] || [ "$1" == "stage2" ] || [ "$1" == "stage3" ] || [ "$1" == "stage4" ]); then
22    if [ $1 == "stage1" ]; then
23        echo "run python dataset ut"
24        pytest -v $CURRPATH/dataset
25
26        RET=$?
27        if [ ${RET} -ne 0 ]; then
28            exit ${RET}
29        fi
30
31        echo "run python debugger gpu ut"
32        pytest -v $CURRPATH/debugger/gpu_tests
33
34        RET=$?
35        if [ ${RET} -ne 0 ]; then
36            exit ${RET}
37        fi
38
39    elif [ $1 == "stage2" ]; then
40        echo "run python parallel"
41        pytest -s $CURRPATH/parallel/*.py
42
43        RET=$?
44        if [ ${RET} -ne 0 ]; then
45            exit ${RET}
46        fi
47
48    elif [ $1 == "stage3" ]; then
49        echo "run python ops, pynative_mode, pipeline, train ut"
50        pytest -v $CURRPATH/ops $CURRPATH/pynative_mode
51
52        RET=$?
53        if [ ${RET} -ne 0 ]; then
54            exit ${RET}
55        fi
56
57        pytest -v $CURRPATH/pipeline $CURRPATH/train
58        RET=$?
59        if [ ${RET} -ne 0 ]; then
60            exit ${RET}
61        fi
62
63    elif [ $1 == "stage4" ]; then
64        echo "run ut"
65        pytest -v $CURRPATH/nn
66
67        RET=$?
68        if [ ${RET} -ne 0 ]; then
69            exit ${RET}
70        fi
71
72        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
73
74        RET=$?
75        if [ ${RET} -ne 0 ]; then
76            exit ${RET}
77        fi
78    fi
79else
80    echo "run all python ut"
81    pytest $CURRPATH/dataset
82    RET=$?
83    if [ ${RET} -ne 0 ]; then
84        exit ${RET}
85    fi
86
87    pytest $CURRPATH/debugger/gpu_tests
88    RET=$?
89    if [ ${RET} -ne 0 ]; then
90        exit ${RET}
91    fi
92
93    pytest -v $CURRPATH/parallel/*.py
94    RET=$?
95    if [ ${RET} -ne 0 ]; then
96        exit ${RET}
97    fi
98
99    pytest -v $CURRPATH/ops $CURRPATH/pynative_mode
100    RET=$?
101    if [ ${RET} -ne 0 ]; then
102        exit ${RET}
103    fi
104
105    pytest -v $CURRPATH/pipeline $CURRPATH/train
106    RET=$?
107    if [ ${RET} -ne 0 ]; then
108        exit ${RET}
109    fi
110
111    pytest -v $CURRPATH/nn
112    RET=$?
113    if [ ${RET} -ne 0 ]; then
114        exit ${RET}
115    fi
116
117    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
118    RET=$?
119    if [ ${RET} -ne 0 ]; then
120        exit ${RET}
121    fi
122
123    pytest -s $CURRPATH/rewrite/*.py
124    RET=$?
125    if [ ${RET} -ne 0 ]; then
126        exit ${RET}
127    fi
128fi
129
130RET=$?
131exit ${RET}
132