xref: /test/xts/tools/lite/buildUtils.sh (revision 31c75014)
131c75014Sopenharmony_ci#!/bin/bash
231c75014Sopenharmony_ci# Copyright (c) 2022 Huawei Device Co., Ltd.
331c75014Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
431c75014Sopenharmony_ci# you may not use this file except in compliance with the License.
531c75014Sopenharmony_ci# You may obtain a copy of the License at
631c75014Sopenharmony_ci#
731c75014Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
831c75014Sopenharmony_ci#
931c75014Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
1031c75014Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1131c75014Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1231c75014Sopenharmony_ci# See the License for the specific language governing permissions and
1331c75014Sopenharmony_ci# limitations under the License.
1431c75014Sopenharmony_ci
1531c75014Sopenharmony_ciset -e
1631c75014Sopenharmony_cifind_dir_by_name()
1731c75014Sopenharmony_ci{
1831c75014Sopenharmony_ci  dir_name=$1
1931c75014Sopenharmony_ci  find_dir_path=$2
2031c75014Sopenharmony_ci  grep_filed=$3
2131c75014Sopenharmony_ci  pushd $find_dir_path
2231c75014Sopenharmony_ci    dir_num=$(find . -name $dir_name|grep $grep_filed|wc -l)
2331c75014Sopenharmony_ci    if [ $dir_num -eq 1 ];then
2431c75014Sopenharmony_ci      dir_path_find_by_name=$(pwd)/$(find . -name $dir_name | grep $grep_filed)
2531c75014Sopenharmony_ci    else
2631c75014Sopenharmony_ci      echo "find $dir_name in out error !"
2731c75014Sopenharmony_ci      exit 1
2831c75014Sopenharmony_ci    fi
2931c75014Sopenharmony_ci  popd
3031c75014Sopenharmony_ci}
31