已合并
add pre-smoking #1421
duanpengliang创建于 4月7日
add pre-smoking #1421
已合并
共 3 个文件变更+99-0
| @@ -24,6 +24,7 @@ | |||
| 24 | <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/--> | 24 | <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/--> |
| 25 | <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/--> | 25 | <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/--> |
| 26 | <filteritem type="filepath" name="docs/.*.png" desc="filter docs png"/> | 26 | <filteritem type="filepath" name="docs/.*.png" desc="filter docs png"/> |
| 27 | + <filteritem type="filename" name="pre-smoking-testcase" desc="filter pre-smoking-testcase"/> | ||
| 27 | 28 | ||
| 28 | </filefilter> | 29 | </filefilter> |
| 29 | <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies"> | 30 | <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies"> |
| @@ -0,0 +1,96 @@ | |||
| 1 | +#!/bin/bash | ||
| 2 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 3 | +# Copyright (c) 2025 Huawei Technologies Co., Ltd. | ||
| 4 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 5 | +# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | +# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 7 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 8 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 9 | +# See LICENSE in the root of the software repository for the full text of the License. | ||
| 10 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 11 | + | ||
| 12 | +export SLOG_PRINT_TO_STDOUT=1 | ||
| 13 | +export ASCEND_SLOG_PRINT_TO_STDOUT=1 | ||
| 14 | +export ASCEND_GLOBAL_LOG_LEVEL=1 | ||
| 15 | + | ||
| 16 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| 17 | +PARAM_FILE="${SCRIPT_DIR}/../pre-smoking-testcase" | ||
| 18 | + | ||
| 19 | +run_once() { | ||
| 20 | + local rts_bin="$1" | ||
| 21 | + shift | ||
| 22 | + local args=("$@") | ||
| 23 | + | ||
| 24 | + echo "execute: ${rts_bin} ${args[*]}" | ||
| 25 | + LD_LIBRARY_PATH="${SCRIPT_DIR}:${SCRIPT_DIR}/lib:${LD_LIBRARY_PATH:-}" \ | ||
| 26 | + "${rts_bin}" "${args[@]}" | ||
| 27 | + local rc=$? | ||
| 28 | + | ||
| 29 | + if [[ ${rc} -ne 0 ]]; then | ||
| 30 | + echo "Failed: args [${args[*]}], exit code ${rc}" >&2 | ||
| 31 | + fi | ||
| 32 | + | ||
| 33 | + return ${rc} | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +main() { | ||
| 37 | + local fail_count=0 | ||
| 38 | + local total_count=0 | ||
| 39 | + local param_file="${PARAM_FILE}" | ||
| 40 | + local rts_bin="" | ||
| 41 | + | ||
| 42 | + if [[ $# -lt 1 ]]; then | ||
| 43 | + echo "Usage: $0 <rtstest_host_path>" >&2 | ||
| 44 | + exit 1 | ||
| 45 | + fi | ||
| 46 | + | ||
| 47 | + rts_bin="$1" | ||
| 48 | + shift | ||
| 49 | + | ||
| 50 | + if [[ ! -x "${rts_bin}" ]]; then | ||
| 51 | + echo "Executable not found or not executable: ${rts_bin}" >&2 | ||
| 52 | + exit 1 | ||
| 53 | + fi | ||
| 54 | + | ||
| 55 | + if [[ $# -ge 2 && "$1" == "--param-file" ]]; then | ||
| 56 | + param_file="$2" | ||
| 57 | + shift 2 | ||
| 58 | + fi | ||
| 59 | + | ||
| 60 | + if [[ $# -gt 0 ]]; then | ||
| 61 | + total_count=1 | ||
| 62 | + run_once "${rts_bin}" "$@" | ||
| 63 | + fail_count=$(( $? != 0 ? 1 : 0 )) | ||
| 64 | + else | ||
| 65 | + if [[ ! -f "${param_file}" ]]; then | ||
| 66 | + echo "Parameter file not found: ${param_file}" >&2 | ||
| 67 | + exit 1 | ||
| 68 | + fi | ||
| 69 | + | ||
| 70 | + while IFS= read -r line || [[ -n "${line}" ]]; do | ||
| 71 | + if [[ -z "${line//[[:space:]]/}" ]]; then | ||
| 72 | + continue | ||
| 73 | + fi | ||
| 74 | + | ||
| 75 | + if [[ "${line}" == \#* ]]; then | ||
| 76 | + continue | ||
| 77 | + fi | ||
| 78 | + | ||
| 79 | + total_count=$((total_count + 1)) | ||
| 80 | + run_once "${rts_bin}" "${line}" | ||
| 81 | + if [[ $? -ne 0 ]]; then | ||
| 82 | + fail_count=$((fail_count + 1)) | ||
| 83 | + fi | ||
| 84 | + done < "${param_file}" | ||
| 85 | + fi | ||
| 86 | + | ||
| 87 | + echo "Execution complete: total=${total_count}, failed=${fail_count}" | ||
| 88 | + if [[ ${fail_count} -ne 0 ]]; then | ||
| 89 | + exit 1 | ||
| 90 | + fi | ||
| 91 | + | ||
| 92 | + echo "Run all examples success" | ||
| 93 | + exit 0 | ||
| 94 | +} | ||
| 95 | + | ||
| 96 | +main "$@" | ||