#!/bin/bash
set -e
set -o pipefail
echo "ge_st_rt2: ${ge_st_rt2}"
echo "GIT_TARGET_BRANCH: ${GIT_TARGET_BRANCH}"
echo "ut_type: ${ut_type}"
function LOG_HEAD() {
local assert_msg=${1}
date_time=$(date +%Y%m%d-%H%M%S)
echo -e "[INFO] ${date_time} ${assert_msg}"
}
function LOG_DO() {
local cmd="$*"
date_time=$(date +%Y%m%d-%H%M%S)
echo -e "[Command] ${date_time} ${cmd}"
${cmd}
}
function DP_ASSERT_EQUAL() {
local actual_value=${1}
local expect_value=${2}
local assert_msg=${3}
local log_flag=${4:-"true"}
local log_path=${5}
if [ "${actual_value}" != "${expect_value}" ]; then
if [ -n "${log_path}" ] && [ -f "${log_path}" ]; then
cat ${log_path}
fi
echo "${assert_msg} is failed."
exit 1
else
if [ "${log_flag}" = "true" ]; then
echo "${assert_msg} is success."
fi
fi
}
REPOSITORY_NAME="ops-math"
echo $(grep -E "^VERSION_ID=" /etc/os-release | cut -d'"' -f2)
sudo update-alternatives --set gcc /usr/bin/gcc-14
gcc --version
rm -rf /home/jenkins/opensource/json
source /home/jenkins/Ascend/cann/bin/setenv.bash
main(){
LOG_HEAD "Start run c++ testcase"
if [ "${ge_st_rt2}X" == "experimentalX" ];then
if [ "${GIT_TARGET_BRANCH}" = "master" ];then
LOG_DO bash build.sh --experimental -u -f "pr_filelist.txt" --cann_3rd_lib_path="/home/jenkins/opensource" -j16
else
echo "not need build A5"
exit 0
fi
elif [ "${ge_st_rt2}X" == "kernelX" ];then
if [ "${GIT_TARGET_BRANCH}" = "master" ];then
LOG_DO sh scripts/ci/check_kernel_ut.sh "pr_filelist.txt" "${REPOSITORY_NAME}" "-j16" | tee output.txt
DP_ASSERT_EQUAL "${PIPESTATUS[0]}" "0" "exec cmd: [sh scripts/ci/check_kernel_ut.sh "pr_filelist.txt" "${REPOSITORY_NAME}" | tee output.txt]"
if grep -q "error happened" output.txt; then
DP_ASSERT_EQUAL "1" "0" "Error happened in output check log"
fi
else
LOG_DO "not need run kernel ut"
exit 0
fi
else
LOG_DO sh build.sh -u -f "pr_filelist.txt" -j16 --cann_3rd_lib_path="/home/jenkins/opensource"
DP_ASSERT_EQUAL "$?" "0" "Run UT TESTCASE"
fi
}
main_param=$@
main $main_param