#!/bin/bash
set +e
shopt -s extglob
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
declare -a ops
ops=("is_finite")
export ASCEND_GLOBAL_LOG_LEVEL=2
export ASCEND_SLOG_PRINT_TO_STDOUT=0
log "start run test case, please wait ..."
for op in "${ops[@]}"; do
echo "Processing: $op"
mode="eager"
[ "$op" = "crop_and_resize" ] && mode="graph"
source /usr/local/Ascend/cann/set_env.sh
cd ${WORKSPACE}
arm_package="cann-asc-devkit_linux-aarch64.run"
(cd ./scripts && bash devkit_dir_check.sh 2>&1 | tee -a ./run_test.log)
wget -nv -O "${arm_package}" \
"https://ascend-ci.obs.cn-north-4.myhuaweicloud.com/${obs_path}/${arm_package}" 2>/dev/null
if [ ! -f "${arm_package}" ] || [ ! -s "${arm_package}" ]; then
echo "No custom package found, This PR no need execute smoke."
rm -f "${arm_package}"
exit 0
fi
chmod +x ${arm_package}
yes "y" | bash "${arm_package}" --full --install-path=/usr/local/Ascend --quiet
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 10; update-alternatives --config gcc <<< '1'
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 10; update-alternatives --config g++ <<< '1'
source /usr/local/Ascend/cann/set_env.sh
python3 -m pip install -r .devcontainer/requirements.txt
(cd ./scripts && bash run_presmoke.sh 2>&1 | tee -a ./run_test.log)
if [ -d "presmoke_reports" ];then
mv presmoke_reports /root/ascend/log
fi
cd ./scripts
done
mkdir -p /root/ascend
slog_name="slog.tar.gz"
tar -zcf slog.tar.gz -C /root/ascend log
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
python3 /home/aa/check_npu.py $repo_name $pr_id `cat /home/aa/hostname`
exit 1
fi
log "checking test results ..."
date_time=`date +%Y%m%d`"."`date +%H%M%S`
if grep -w -e "execute samples success" "./run_test.log"; then
echo "$date_time : run test case success"
else
echo "$date_time : run test case failed"
exit 1
fi