#!/bin/bash
set -euo pipefail
echo "start run test case, please wait ..."
cd ${WORKSPACE}
export ASCEND_GLOBAL_LOG_LEVEL=2
export ASCEND_SLOG_PRINT_TO_STDOUT=0
source /usr/local/Ascend/cann/set_env.sh
log() {
local dt
dt=$(date '+%Y%m%d.%H%M%S')
echo "===================================================================="
echo "$dt : $*"
echo "===================================================================="
}
log "init test case, please wait ..."
source /usr/local/Ascend/cann/set_env.sh
arm_package=$(basename "${arm_run_url}")
wget -nv ${arm_run_url} && chmod 777 ${arm_package}
/opt/conda/envs/python39/bin/python3 -m pip install packaging
/opt/conda/envs/python39/bin/python3 -m pip install build
/opt/conda/envs/python39/bin/python3 -m pip install 'setuptools>=68,<80'
chmod +x ${arm_package}
echo 'y' | bash ${arm_package} --full --quiet --pylocal
echo "bash ${arm_package} bash build.sh --run_example --no-autofuse"
source /opt/conda/bin/activate python39
pip3 install build
source /usr/local/Ascend/cann/set_env.sh && bash build.sh --run_example --no-autofuse 2>&1 | tee -a ./run_test.log
source /opt/conda/bin/deactivate
mkdir -p /root/ascend
slog_name="slog.tar.gz"
tar -zcf "${slog_name}" -C /root/ascend log
log "checking NPU status ..."
mkdir -p ./npu_log
npu-smi info 2>&1 | tee ./npu_log/npu_info.log
log "checking test results ..."
date_time=`date +%Y%m%d`"."`date +%H%M%S`
if grep -w -e "Run all examples success" "./run_test.log"; then
echo "$date_time : run test case success"
else
echo "$date_time : run test case failed"
exit 1
fi