#!/bin/bash
set -e
set -o pipefail
echo "single_tar_url=${single_tar_url}"
echo "smoke_run_file_url=${smoke_run_file_url}"
echo "obs_smoke_path=${obs_smoke_path}"
shopt -s extglob
cd ${WORKSPACE}
log() {
local dt
dt=$(date '+%Y%m%d.%H%M%S')
echo "===================================================================="
echo "$dt : $*"
echo "===================================================================="
}
log "init test case, please wait ..."
rm -rf /root/ascend/log
log "start run test case, please wait ..."
DOWNLOAD_FILE=$(basename "${single_tar_url}")
echo "Starting to download file: ${DOWNLOAD_FILE}"
wget -nv --no-clobber "${single_tar_url}"
if [ ! -f "${DOWNLOAD_FILE}" ]; then
echo "File ${DOWNLOAD_FILE} does not exist, no need to execute smoke test task"
exit 0
fi
FILE_SIZE=$(stat -c%s "${DOWNLOAD_FILE}" 2>/dev/null || echo 0)
if [ "${FILE_SIZE}" -eq 0 ]; then
echo "No compiled operators, no need to execute smoke test task"
rm -f "${DOWNLOAD_FILE}"
exit 0
fi
echo "File download completed, size ${FILE_SIZE}, starting decompression."
tar -ztf "${DOWNLOAD_FILE}"
tar -zxf "${DOWNLOAD_FILE}"
export ASCEND_GLOBAL_LOG_LEVEL=2
export ASCEND_SLOG_PRINT_TO_STDOUT=0
rm -rf /home/jenkins/opensource/json
source /usr/local/Ascend/cann/set_env.sh
bash ${WORKSPACE}/scripts/ci/check_example.sh ${WORKSPACE}/pr_filelist.txt 2>&1 | tee -a ./run_test.log
arm_package=$(basename "${smoke_run_file_url}")
wget -nv ${smoke_run_file_url}
chmod +x ${arm_package}
echo 'y' | bash ${arm_package} --quiet
source /usr/local/Ascend/cann/set_env.sh
bash build.sh -f ${WORKSPACE}/pr_filelist.txt --experimental --run_example 2>&1 | tee -a ./run_test.log
mkdir -p /root/ascend
slog_name="slog.tar.gz"
tar -zcf "${slog_name}" -C /root/ascend log
obs_key=${obs_smoke_path}/plog/${slog_name}
if python3 /home/upload.py --bucket-name "ascend-ci" --action upload --local-file "slog.tar.gz" --obs-object-key "${obs_key}"; then
echo "::set-output var=plog_url:https://ascend-ci.obs.cn-north-4.myhuaweicloud.com/${obs_key}"
fi
log "checking NPU status ..."
mkdir -p ./npu_log
npu-smi info 2>&1 | tee ./npu_log/npu_info.log
if grep "dcmi module initialize failed" "./npu_log/npu_info.log";then
date_time=$(date '+%Y%m%d.%H%M%S')
echo "$date_time : ${repo_name}_${pr_id} dcmi module initialize failed" >> "./npu_log/$(date +%Y%m%d).log"
fi
log "checking test results ..."
date_time=$(date '+%Y%m%d.%H%M%S')
if grep -w -e "example fail" -e "execute samples failed" "./run_test.log"; then
echo "$date_time : run test case failed"
exit 1
else
echo "$date_time : run test case success"
fi