From 50f41b8c31f50c81ba5bd18ebfa96937583010e0 Mon Sep 17 00:00:00 2001 From: Milosz Linkiewicz Date: Sat, 8 Feb 2025 04:04:52 +0100 Subject: [PATCH] [FIX] Build patched MediaSDK with MTL enabled [FIX] Build patched MediaSDK with MTL enabled: - correct build script in ecosystem subpath - add scripts/common.sh for common functionalities is bash - remove proxy settings specific to one vendor - minor other fixes/adjustments Signed-off-by: Milosz Linkiewicz --- .gitignore | 1 + app/sample/redundant_sample_test.sh | 28 +- app/sample/sample_test.sh | 98 ++-- ecosystem/msdk/build_msdk_mtl.sh | 31 +- gpu_direct/gpu.c | 2 +- gpu_direct/gpu.h | 2 +- script/common.sh | 515 ++++++++++++++++++ tests/meson_options.txt | 2 +- .../Kahawai_Linux_install_script_0825.sh | 11 +- .../setup/kahawai_windows_installer_v0.6.ps1 | 42 +- 10 files changed, 638 insertions(+), 94 deletions(-) create mode 100755 script/common.sh diff --git a/.gitignore b/.gitignore index 00e06991a..3ab7d2a21 100644 --- a/.gitignore +++ b/.gitignore @@ -86,6 +86,7 @@ mtl_system_status_* doc/_build # Gpu direct files +ecosystem/msdk/_install gpu_direct/tests/fff.h gpu_direct/subprojects/* !gpu_direct/subprojects/gtest.wrap diff --git a/app/sample/redundant_sample_test.sh b/app/sample/redundant_sample_test.sh index ab18011ed..4e0a03023 100755 --- a/app/sample/redundant_sample_test.sh +++ b/app/sample/redundant_sample_test.sh @@ -5,24 +5,30 @@ set -e -TEST_TIME_SEC=15 +SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" +REPOSITORY_DIR="$(readlink -f "${SCRIPT_DIR}/../..")" -TEST_BIN_PATH=../../build/app +# shellcheck source="script/common.sh" +. "${REPOSITORY_DIR}/script/common.sh" + +print_logo_anim +TEST_TIME_SEC="${TEST_TIME_SEC:-15}" +TEST_BIN_PATH="${REPOSITORY_DIR}/build/app" LOG_LEVEL=notice name=RxSt20RedundantSample -${TEST_BIN_PATH}/TxSt20PipelineSample >/dev/null --log_level ${LOG_LEVEL} --p_port 0000:af:01.2 --r_port 0000:af:01.3 --p_sip 192.168.77.2 --r_sip 192.168.77.3 --p_tx_ip 239.168.77.20 --r_tx_ip 239.168.77.21 2>&1 & +"${TEST_BIN_PATH}/TxSt20PipelineSample" >/dev/null --log_level "${LOG_LEVEL}" --p_port 0000:af:01.2 --r_port 0000:af:01.3 --p_sip 192.168.77.2 --r_sip 192.168.77.3 --p_tx_ip 239.168.77.20 --r_tx_ip 239.168.77.21 2>&1 & pid_tx=$! -${TEST_BIN_PATH}/RxSt20RedundantSample --log_level ${LOG_LEVEL} --p_port 0000:af:01.0 --r_port 0000:af:01.1 --p_sip 192.168.77.11 --r_sip 192.168.77.12 --p_rx_ip 239.168.77.20 --r_rx_ip 239.168.77.21 & +"${TEST_BIN_PATH}/RxSt20RedundantSample" --log_level "${LOG_LEVEL}" --p_port 0000:af:01.0 --r_port 0000:af:01.1 --p_sip 192.168.77.11 --r_sip 192.168.77.12 --p_rx_ip 239.168.77.20 --r_rx_ip 239.168.77.21 & pid_rx=$! -echo "${name}: pid_tx ${pid_tx}, pid_rx ${pid_rx}, wait ${TEST_TIME_SEC}s" -sleep ${TEST_TIME_SEC} -kill -SIGINT ${pid_tx} -kill -SIGINT ${pid_rx} +log_info "${name}: pid_tx ${pid_tx}, pid_rx ${pid_rx}, wait ${TEST_TIME_SEC}s" +sleep "${TEST_TIME_SEC}" +kill -SIGINT "${pid_tx}" +kill -SIGINT "${pid_rx}" -echo "${name}: wait all thread ending" +log_info "${name}: wait all thread ending" wait -echo "${name}: ****** Done ******" -echo "" +log_success "${name}: ****** Done ******" +log_info "" diff --git a/app/sample/sample_test.sh b/app/sample/sample_test.sh index eb78fcafc..c9df5a08d 100755 --- a/app/sample/sample_test.sh +++ b/app/sample/sample_test.sh @@ -1,22 +1,24 @@ #!/bin/bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2022 Intel Corporation +# Copyright 2022-2025 Intel Corporation -set -e +SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" +REPOSITORY_DIR="$(readlink -f "${SCRIPT_DIR}/../..")" -ST_PORT_TX=0000:af:01.1 -ST_PORT_RX=0000:af:01.0 -ST_SIP_TX=192.168.87.80 -ST_SIP_RX=192.168.87.81 -ST_TX_IP=239.168.87.20 -ST_RX_IP=239.168.87.20 -TEST_TIME_SEC=15 +# shellcheck source="script/common.sh" +. "${REPOSITORY_DIR}/script/common.sh" -TEST_BIN_PATH=../../build/app -LOG_LEVEL=notice +ST_PORT_TX="${ST_PORT_TX:-'0000:af:01.1'}" +ST_PORT_RX="${ST_PORT_RX:-'0000:af:01.0'}" +ST_SIP_TX="${ST_SIP_TX:-'192.168.87.80'}" +ST_SIP_RX="${ST_SIP_RX:-'192.168.87.81'}" +ST_TX_IP="${ST_TX_IP:-'239.168.87.20'}" +ST_RX_IP="${ST_RX_IP:-'239.168.87.20'}" +TEST_TIME_SEC="${TEST_TIME_SEC:-15}" -export KAHAWAI_CFG_PATH=../../kahawai.json +TEST_BIN_PATH="${TEST_BIN_PATH:-"${REPOSITORY_DIR}/build/app"}" +LOG_LEVEL="${LOG_LEVEL:-notice}" test_tx_and_rx() { local name=$1 @@ -30,53 +32,59 @@ test_tx_and_rx() { if [ -n "$5" ]; then height=$5 fi - echo "${name}: start ${tx_prog}, width:${width} height:${height}" + log_info "${name}: start ${tx_prog}, width:${width} height:${height}" "${TEST_BIN_PATH}"/"${tx_prog}" --log_level "${LOG_LEVEL}" --p_port "${ST_PORT_TX}" --p_sip "${ST_SIP_TX}" --p_tx_ip "${ST_TX_IP}" --width "${width}" --height "${height}" & #${TEST_BIN_PATH}/${tx_prog} > /dev/null --log_level ${LOG_LEVEL} --p_port ${ST_PORT_TX} --p_sip ${ST_SIP_TX} --p_tx_ip ${ST_TX_IP} --width ${width} --height ${height} 2>&1 & pid_tx=$! - echo "${name}: start ${rx_prog}" + log_info "${name}: start ${rx_prog}" "${TEST_BIN_PATH}"/"${rx_prog}" --log_level "${LOG_LEVEL}" --p_port "${ST_PORT_RX}" --p_sip "${ST_SIP_RX}" --p_rx_ip "${ST_RX_IP}" --width "${width}" --height "${height}" & pid_rx=$! - echo "${name}: pid_tx ${pid_tx}, pid_rx ${pid_rx}, wait ${TEST_TIME_SEC}s" - sleep ${TEST_TIME_SEC} + log_info "${name}: pid_tx ${pid_tx}, pid_rx ${pid_rx}, wait ${TEST_TIME_SEC}s" + sleep "${TEST_TIME_SEC}" - echo "${name}: wait all thread ending" + log_info "${name}: wait all thread ending" kill -SIGINT ${pid_tx} kill -SIGINT ${pid_rx} wait ${pid_tx} - echo "${name}: ${tx_prog} exit" + log_info "${name}: ${tx_prog} exit" wait ${pid_rx} - echo "${name}: ${rx_prog} exit" - echo "${name}: ****** Done ******" - echo "" + log_info "${name}: ${rx_prog} exit" + log_success "${name}: ****** Done ******" + log_info "" } -# test video -test_tx_and_rx st20 TxVideoSample RxVideoSample -# test st20p -test_tx_and_rx st20p TxSt20PipelineSample RxSt20PipelineSample -# test st22p -test_tx_and_rx st22p TxSt22PipelineSample RxSt22PipelineSample +# Allow sourcing of the script. +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + set -e -o pipefail + export KAHAWAI_CFG_PATH="${REPOSITORY_DIR}/kahawai.json" -# test rtp video -test_tx_and_rx st20_rtp TxRtpVideoSample RxRtpVideoSample -# test slice video -test_tx_and_rx st20_slice TxSliceVideoSample RxSliceVideoSample -# test st22 -test_tx_and_rx st22 TxSt22VideoSample RxSt22VideoSample + print_logo_anim + # test video + test_tx_and_rx st20 TxVideoSample RxVideoSample + # test st20p + test_tx_and_rx st20p TxSt20PipelineSample RxSt20PipelineSample + # test st22p + test_tx_and_rx st22p TxSt22PipelineSample RxSt22PipelineSample -# test RxSt20TxSt20Fwd -test_tx_and_rx RxSt20TxSt20Fwd TxSt20PipelineSample RxSt20TxSt20Fwd -# test RxSt20pTxSt20pFwd -test_tx_and_rx RxSt20pTxSt20pFwd TxSt20PipelineSample RxSt20pTxSt20pFwd -# test RxSt20pTxSt22pFwd -test_tx_and_rx RxSt20pTxSt22pFwd TxSt20PipelineSample RxSt20pTxSt22pFwd + # test rtp video + test_tx_and_rx st20_rtp TxRtpVideoSample RxRtpVideoSample + # test slice video + test_tx_and_rx st20_slice TxSliceVideoSample RxSliceVideoSample + # test st22 + test_tx_and_rx st22 TxSt22VideoSample RxSt22VideoSample -# test TxVideoSplitSample -test_tx_and_rx TxVideoSplitSample TxVideoSplitSample RxSt20PipelineSample -# test RxSt20TxSt20SplitFwd, not enable now -test_tx_and_rx RxSt20TxSt20SplitFwd TxSt20PipelineSample RxSt20TxSt20SplitFwd 3840 2160 + # test RxSt20TxSt20Fwd + test_tx_and_rx RxSt20TxSt20Fwd TxSt20PipelineSample RxSt20TxSt20Fwd + # test RxSt20pTxSt20pFwd + test_tx_and_rx RxSt20pTxSt20pFwd TxSt20PipelineSample RxSt20pTxSt20pFwd + # test RxSt20pTxSt22pFwd + test_tx_and_rx RxSt20pTxSt22pFwd TxSt20PipelineSample RxSt20pTxSt22pFwd -echo "****** All test OK ******" + # test TxVideoSplitSample + test_tx_and_rx TxVideoSplitSample TxVideoSplitSample RxSt20PipelineSample + # test RxSt20TxSt20SplitFwd, not enable now + test_tx_and_rx RxSt20TxSt20SplitFwd TxSt20PipelineSample RxSt20TxSt20SplitFwd 3840 2160 -unset KAHAWAI_CFG_PATH + log_success "****** All test OK ******" + unset KAHAWAI_CFG_PATH +fi diff --git a/ecosystem/msdk/build_msdk_mtl.sh b/ecosystem/msdk/build_msdk_mtl.sh index 467459553..533aabf3d 100755 --- a/ecosystem/msdk/build_msdk_mtl.sh +++ b/ecosystem/msdk/build_msdk_mtl.sh @@ -1,17 +1,26 @@ #!/bin/bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2022 Intel Corporation +# Copyright 2022-2025 Intel Corporation -# check out msdk code -git clone https://github.com/Intel-Media-SDK/MediaSDK.git -cd MediaSDK || exit -git checkout intel-mediasdk-22.6.4 -git switch -c v22.6.4 +SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" +set -e -o pipefail -# apply the patches -git am ../*.patch +mkdir -p "${SCRIPT_DIR}/MediaSDK" +curl -Lf "https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-23.2.2.tar.gz" -o "${SCRIPT_DIR}/intel-mediasdk-22.6.4.tar.gz" +tar -zx --strip-components=1 -C "${SCRIPT_DIR}/MediaSDK" -f "${SCRIPT_DIR}/intel-mediasdk-22.6.4.tar.gz" +rm -f "${SCRIPT_DIR}/intel-mediasdk-22.6.4.tar.gz" +patch -d "${SCRIPT_DIR}/MediaSDK" -p1 -i <(cat "${SCRIPT_DIR}/"*.patch) -# build now -cmake -S . -B build -G Ninja -DENABLE_IMTL=ON -cmake --build build +cmake \ + -S "${SCRIPT_DIR}/MediaSDK" \ + -B "${SCRIPT_DIR}/build" \ + -G Ninja \ + -DENABLE_IMTL=ON \ + -DCMAKE_INSTALL_PREFIX="${SCRIPT_DIR}/_install" +ninja -C "${SCRIPT_DIR}/build" +ninja -C "${SCRIPT_DIR}/build" install + +echo "Use sample applications, found under path:" +echo "LD_LIBRARY_PATH=\"${LD_LIBRARY_PATH}:${SCRIPT_DIR}/_install/lib\"" +echo "APPLICATION_PATH=\"${SCRIPT_DIR}/_install/share/mfx/samples/sample_encode\"" diff --git a/gpu_direct/gpu.c b/gpu_direct/gpu.c index 47bf66020..e4cca53c8 100644 --- a/gpu_direct/gpu.c +++ b/gpu_direct/gpu.c @@ -2,7 +2,7 @@ * SPDX-FileCopyrightText: Copyright (c) 2024 Intel Corporation */ -#include "gpu.h" +#include "./gpu.h" // Macros for error checking #define ZE_CHECK_ERROR(fn_call) \ diff --git a/gpu_direct/gpu.h b/gpu_direct/gpu.h index 16c2e7d75..7d41190fc 100644 --- a/gpu_direct/gpu.h +++ b/gpu_direct/gpu.h @@ -45,4 +45,4 @@ int gpu_memset(GpuContext* ctx, void* dst, char byte, size_t sz); void gpu_free_buf(GpuContext* ctx, void* buf); int free_gpu_context(GpuContext* ctx); -#endif /* GPU */ \ No newline at end of file +#endif /* GPU */ diff --git a/script/common.sh b/script/common.sh new file mode 100755 index 000000000..9ed96c8ef --- /dev/null +++ b/script/common.sh @@ -0,0 +1,515 @@ +#!/bin/bash + +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2024 Intel Corporation + +REPO_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")/..")" +BUILD_DIR="${BUILD_DIR:-${REPO_DIR}/_build}" +DRIVERS_DIR="${DRIVERS_DIR:-/opt/intel/drivers}" + +export MTL_DIR="${BUILD_DIR}/mtl" +export DPDK_DIR="${BUILD_DIR}/dpdk" +export XDP_DIR="${BUILD_DIR}/xdp" +export BPF_DIR="${XDP_DIR}/lib/libbpf" +export GRPC_DIR="${BUILD_DIR}/grpc" +export JPEGXS_DIR="${BUILD_DIR}/jpegxs" +export LIBFABRIC_DIR="${BUILD_DIR}/libfabric" +export LIBFDT_DIR="${BUILD_DIR}/libfdt" +export JSONC_DIR="${BUILD_DIR}/json-c" +export NASM_DIR="${BUILD_DIR}/nasm" + +ICE_VER="${ICE_VER:-1.14.9}" +IAVF_VER="${IAVF_VER:-4.13.3}" +IRDMA_VER="${IRDMA_VER:-1.16.10}" +export ICE_DIR="${DRIVERS_DIR}/ice/${ICE_VER}" +export IAVF_DIR="${DRIVERS_DIR}/iavf/${IAVF_VER}" +export IRDMA_DIR="${DRIVERS_DIR}/irdma/${IRDMA_VER}" + +PM="${PM:-apt-get}" +KERNEL_VERSION="${KERNEL_VERSION:-$(uname -r)}" +TZ="${TZ:-Europe/Warsaw}" +NPROC="${NPROC:-$(nproc)}" + +if ! grep "/root/.local/bin" <<< "${PATH}" > /dev/null 2>&1; then + PATH="/root/.local/bin:/root/bin:/root/usr/bin:${PATH}" + PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/local/lib/x86_64-linux-gnu/pkgconfig:${PKG_CONFIG_PATH}" +fi + +BOLD="${BOLD:-\e[1;}" +REGULAR="${REGULAR:-\e[0;}" +RED="${RED:-31m}" +GREEN="${GREEN:-32m}" +YELLOW="${YELLOW:-33m}" +BLUE="${BLUE:-34m}" +EndCl='\e[m' + +function log_message() { + local type="${1}" + shift + local HEADER="${type}: " + local FOOTER="" + # case $(echo $type | tr '[:upper:]' '[:lower:]') in + if [ -z "${DISABLE_COLOR_PRINT}" ]; then + FOOTER='\e[0m' + case "${type}" in + ERROR) HEADER="${REGULAR}${RED}${type}: ${BOLD}${RED}" ;; + WARN|WARNING) HEADER="${REGULAR}${BLUE}${type}: ${BOLD}${YELLOW}" ;; + SUCC|SUCCESS) HEADER="${REGULAR}${BLUE}${type}: ${BOLD}${GREEN}" ;; + INFO|*) HEADER="${REGULAR}${BLUE}${type}: ${BOLD}${BLUE}" ;; + esac + fi + echo -e "${HEADER}$*${FOOTER}" >&2 +} + +function log_info() { log_message "INFO" "$*"; } +function log_success() { log_message "SUCCESS" "$*"; } +function log_warning() { log_message "WARNING" "$*"; } +function log_error() { log_message "ERROR" "$*"; } + +function get_user_input_confirm() { + local confirm + local confirm_string + local confirm_default="${1:-0}" + confirm_string=( "(N)o" "(Y)es" ) + + echo -en "${REGULAR}${BLUE}CHOOSE:${BOLD}${BLUE} (Y)es/(N)o [default: ${confirm_string[$confirm_default]}]: ${EndCl}" >&2 + read -r confirm + if [[ -z "$confirm" ]]; then + confirm="$confirm_default" + else + { [[ $confirm == [yY] ]] || [[ $confirm == [yY][eE][sS] ]]; } && confirm="1" || confirm="0" + fi + echo "${confirm}" +} + +function get_user_input_def_yes() { + get_user_input_confirm 1 +} + +function get_user_input_def_no() { + get_user_input_confirm 0 +} + +function get_filename() { + local path="$1" + echo "${path##*/}" +} + +function get_dirname() { + local path="$1" + echo "${path%/*}/" +} + +function get_extension() { + local filename + filename="$(get_filename "${1}")" + echo "${filename#*.}" +} + +function check_extension() { + local filename="$1" + local extension="$2" + if [ "${filename}" == "${filename%"${extension}"}" ]; then + echo "0" + else + echo "1" + fi +} + +function get_basename() { + local filename + filename="$(get_filename "${1}")" + echo "${filename%%.*}" +} + +# Extracts namespace and repository part from valid GitHub URL passed as argument. +# input: valid GitHub repository URL +# output: two element string array, space separated +function get_github_elements() { + local path_part + local path_elements + path_part="${1#*://github.com/}" + mapfile -t -d'/' path_elements <<< "${path_part}" + if [[ "${#path_elements[@]}" -lt "2" ]]; then + log_error "Invalid link passed to get_github_elements method." + return 1 + fi + echo "${path_elements[0]} ${path_elements[1]}" +} + +function get_github_namespace() { + cut -d' ' -f1 <<< "$(get_github_elements "$1")" +} + +function get_github_repo() { + cut -d' ' -f2 <<< "$(get_github_elements "$1")" +} + +# Adds sufix to base of filename from full path. +# input[1]: string sufix to be added +# input[2]: path string to be modified +# output: [path]/[file_base][id].[extension] +function get_filepath_add_sufix() { + local dir_path + local file_base + local file_ext + local file_sufix="${1}" + local file_path="${2}" + dir_path="$(get_dirname "${file_path}")" + file_base="$(get_basename "${file_path}")" + file_ext="$(get_extension "${file_path}")" + echo "${dir_path}${file_base}${file_sufix}.${file_ext}" +} + +function command_exists { + command -v "$@" > /dev/null 2>&1 +} + +function as_root() +{ + CMD_TO_EVALUATE="$*" + CURRENT_USER_ID="$(id -u)" + EFECTIVE_USER_ID="${EUID:-$CURRENT_USER_ID}" + AS_ROOT="/bin/bash -c" + + if [ "${EFECTIVE_USER_ID}" -ne 0 ]; then + if command_exists sudo; then + AS_ROOT="sudo -E /bin/bash -c" + elif command_exists su; then + AS_ROOT="su -c" + else + log_error "This command must be run as root [EUID=0] ${CMD_TO_EVALUATE[*]}." + log_error "- current [EUID=${EFECTIVE_USER_ID}]." + log_error "- 'sudo' nor 'su' commands were found in PATH." + log_error "Re-run the script as sudo or install sudo pkg." + exit 1 + fi + fi + $AS_ROOT "${CMD_TO_EVALUATE[*]}" +} + +function github_api_call() { + url=$1 + shift + GITHUB_API_URL=https://api.github.com + INPUT_OWNER=$(echo "${url#"${GITHUB_API_URL}/repos/"}" | cut -f1 -d'/') + INPUT_REPO=$(echo "${url#"${GITHUB_API_URL}/repos/"}" | cut -f2 -d'/') + API_SUBPATH="${url#"${GITHUB_API_URL}/repos/${INPUT_OWNER}/${INPUT_REPO}/"}" + if [ -z "${INPUT_GITHUB_TOKEN}" ]; then + echo >&2 "Set the INPUT_GITHUB_TOKEN env variable first." + return + fi + + echo >&2 "GITHUB_API_URL=$GITHUB_API_URL" + echo >&2 "INPUT_OWNER=$INPUT_OWNER" + echo >&2 "INPUT_REPO=$INPUT_REPO" + echo >&2 "API_SUBPATH=$API_SUBPATH" + echo >&2 "curl --fail-with-body -sSL \"${GITHUB_API_URL}/repos/${INPUT_OWNER}/${INPUT_REPO}/${API_SUBPATH}\" -H \"Authorization: Bearer ${INPUT_GITHUB_TOKEN}\" -H 'Accept: application/vnd.github.v3+json' -H 'Content-Type: application/json' $*" + + if API_RESPONSE=$(curl --fail-with-body -sSL \ + "${GITHUB_API_URL}/repos/${INPUT_OWNER}/${INPUT_REPO}/${API_SUBPATH}" \ + -H "Authorization: Bearer ${INPUT_GITHUB_TOKEN}" \ + -H 'Accept: application/vnd.github.v3+json' \ + -H 'Content-Type: application/json' \ + "$@") + then + echo "${API_RESPONSE}" + else + echo >&2 "GitHub API call failed." + echo >&2 "${API_RESPONSE}" + return + fi +} + +function print_logo() +{ + if [[ -z "$blue_code" ]] + then + local blue_code=( 26 27 20 19 20 20 21 04 27 26 32 12 33 06 39 38 44 45 ) + fi + local IFS + local logo_string + local colorized_logo_string + IFS=$'\n\t' + logo_string="$(cat <<- EOF + .-----------------------------------------------------------. + | * . .. . * | + | . . . . . . | + | . . *:. . . | + | . . . .. . . | + | . . . . ... . . | + | . . . . . . . . . | + | . . . ... .. . . | + | . . . *. . . | + | :. . . | + | . . . . | + | . . . . ^ | + | . .. :. . | . . | + |. ... . | | + | :. . . *. We are here. . | + | . . *. | + .©-Intel-Corporation--------------------ascii-author-unknown. + = = + = 88 88 = + = "" ,d 88 = + = 88 88 88 = + = 88 8b,dPPYba, MM88MMM ,adPPYba, 88 = + = 88 88P' '"8a 88 a8P_____88 88 = + = 88 88 88 88 8PP""""""" 88 = + = 88 88 88 88, "8b, ,aa 88 = + = 88 88 88 "Y888 '"Ybbd8"' 88 = + = = + ============================================================= + EOF + )" + + colorized_logo_string="" + for (( i=0; i<${#logo_string}; i++ )) + do + colorized_logo_string+="\e[38;05;${blue_code[$(( (i-(i/64)*64)/4 ))]}m" + colorized_logo_string+="${logo_string:$i:1}" + done; + colorized_logo_string+='\e[m\n' + + echo -e "$colorized_logo_string" >&2 +} + +function print_logo_sequence() +{ + set +x + local wait_between_frames="${1:-0}" + local wait_cmd="" + if [ ! "${wait_between_frames}" = "0" ]; then + wait_cmd="sleep ${wait_between_frames}" + fi + + blue_code_fixed=( 26 27 20 19 20 20 21 04 27 26 32 12 33 06 39 38 44 45 ) + size=${#blue_code_fixed[@]} + for (( move=0; move' + "${_last_command}" + ) + else + _output_array+=("last_command: ${_last_command}") + fi + + _output_array+=('---') + log_error "${_output_array[*]}" +} + +# Calling this function executes ERR and SIGINT signals trapping. Triggered trap calls catch_error_print_debug and exit 1 +function trap_error_print_debug() { + log_info "Setting trap for errors handling" + trap 'catch_error_print_debug "LINENO" "BASH_LINENO" "${BASH_COMMAND}" "${?}"; exit 1' SIGINT ERR + log_info "Trap set successfuly." +} + +# GITHUB_CREDENTIALS="username:password" +# URL construction: https://${GITHUB_CREDENTIALS}@github.com/${name}/archive/${version}.tar.gz +# $1 - name +# $2 - version +# $3 - dest_dir +function git_download_strip_unpack() +{ + # Version can be commit sha or tag, examples: + # version=d2515b90cc0ef651f6d0a6661d5a644490bfc3f3 + # version=refs/tags/v${JPEG_XS_VER} + name="${1}" + version="${2}" + dest_dir="${3}" + filename="$(get_filename "${version}")" + [ -n "${GITHUB_CREDENTIALS}" ] && creds="${GITHUB_CREDENTIALS}@" || creds="" + + mkdir -p "${dest_dir}" + curl -Lf "https://${creds}github.com/${name}/archive/${version}.tar.gz" -o "${dest_dir}/${filename}.tar.gz" + tar -zx --strip-components=1 -C "${dest_dir}" -f "${dest_dir}/${filename}.tar.gz" + rm -f "${dest_dir}/${filename}.tar.gz" +} + +# Downloads and strip unpack a file from URL ($1) to a target directory ($2) +# $1 - URL to download +# $2 - destination directory to strip unpack the tar.gz +function wget_download_strip_unpack() +{ + local filename + local source_url="${1}" + local dest_dir="${2}" + filename="$(get_filename "${source_url}")" + [ -n "${GITHUB_CREDENTIALS}" ] && creds="${GITHUB_CREDENTIALS}@" || creds="" + + mkdir -p "${dest_dir}" + curl -Lf "${source_url}" -o "${dest_dir}/${filename}.tar.gz" + tar -zx --strip-components=1 -C "${dest_dir}" -f "${dest_dir}/${filename}.tar.gz" + rm -f "${dest_dir}/${filename}.tar.gz" +} + +# Example usage: +# PM="$(setup_package_manager)" && \ +# $PM install python3 +function setup_package_manager() +{ + TIBER_USE_PM="${PM:-$1}" + if [[ -x "$(command -v "$TIBER_USE_PM")" ]]; then + export PM="${TIBER_USE_PM}" + elif [[ -x "$(command -v yum)" ]]; then + export PM='yum' + elif [[ -x "$(command -v dnf)" ]]; then + export PM='dnf' + elif [[ -x "$(command -v apt-get)" ]]; then + export PM='apt-get' + elif [[ -x "$(command -v apt)" ]]; then + export PM='apt' + else + log_error "No known pkg manager found. Try to re-run with variable, example:" + log_error "export PM=\"apt\"" + return 1 + fi + log_info "Setting pkg manager to ${PM}." + echo "${PM}" + return 0 +} + +# Setup build dir and ffmpeg version/directory. +# FFMPEG_VER taken from environment or forced by 1st parameter +# Exports FFMPEG_DIR and FFMPEG_VER +function lib_setup_ffmpeg_dir_and_version() +{ + FFMPEG_VER="${1:-$FFMPEG_VER}" + FFMPEG_7_0_DIR="${FFMPEG_7_0_DIR:-ffmpeg-7-0}" + FFMPEG_6_1_DIR="${FFMPEG_6_1_DIR:-ffmpeg-6-1}" + + if [[ "${FFMPEG_VER}" == "7.0" ]]; then + FFMPEG_SUB_DIR="${FFMPEG_7_0_DIR}" + elif [[ "${FFMPEG_VER}" == "6.1" ]]; then + FFMPEG_SUB_DIR="${FFMPEG_6_1_DIR}" + else + log_error "Unsupported version of FFmpeg == '${FFMPEG_VER}'." + log_error "Try again, choose one of '7.0', '6.1'." + exit 2 + fi + export FFMPEG_VER + export FFMPEG_SUB_DIR +} + +function exec_command() +{ + # One of: yes|no|accept-new + SSH_STRICT_HOST_KEY_CHECKING="accept-new" + SSH_CMD="ssh -oStrictHostKeyChecking=${SSH_STRICT_HOST_KEY_CHECKING} -t -o" + + local values_returned="" + local user_at_address="" + [[ "$#" -eq "2" ]] && user_at_address="${2}" + [[ "$#" -eq "3" ]] && user_at_address="${3}@${2}" + + if [ "$#" -eq "1" ]; then + values_returned="$(eval "${1}")" + elif [[ "$#" -eq "2" ]] || [[ "$#" -eq "3" ]]; then + values_returned="$($SSH_CMD "RemoteCommand=eval \"${1}\"" "${user_at_address}" 2>/dev/null)" + else + log_error "Wrong arguments for exec_command(). Valid number is one of [1 2 3], got $#" + return 1 + fi + + if [ -z "$values_returned" ]; then + log_error "Unable to collect results or results are empty." + return 1 + else + echo "${values_returned}" + return 0 + fi +} + +function get_hostname() { + exec_command 'hostname' "$@" +} + +function get_intel_nic_device() { + exec_command "lspci | grep 'Intel Corporation.*\(810\|X722\)'" "$@" +} + +function get_default_route_nic() { + exec_command "ip -json r show default | jq '.[0].dev' -r" "$@" +} + +function get_cpu_arch() { + local arch="" + + if ! arch="$(exec_command 'cat /sys/devices/cpu/caps/pmu_name' "$@")"; then echo "Got: $arch" && return 1; fi + + case $arch in + icelake) + log_info "Xeon IceLake CPU (icx)" 1>&2 + echo "icx" + ;; + sapphire_rapids) + log_info "Xeon Sapphire Rapids CPU (spr)" 1>&2 + echo "spr" + ;; + skylake) + log_info "Xeon SkyLake" + echo "skl" + ;; + *) + log_error "Unsupported architecture: ${arch}. Please edit the script or setup the architecture manually." + return 1 + ;; + esac + return 0 +} diff --git a/tests/meson_options.txt b/tests/meson_options.txt index 8a0926aaa..c5cc03c62 100644 --- a/tests/meson_options.txt +++ b/tests/meson_options.txt @@ -1,4 +1,4 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2022 Intel Corporation -option('enable_asan', type: 'boolean', value: false, description: 'enable/disable address sanitizer, debug usage only') \ No newline at end of file +option('enable_asan', type: 'boolean', value: false, description: 'enable/disable address sanitizer, debug usage only') diff --git a/tests/validation/setup/Kahawai_Linux_install_script_0825.sh b/tests/validation/setup/Kahawai_Linux_install_script_0825.sh index 68624b4e8..c6a9e9cdf 100755 --- a/tests/validation/setup/Kahawai_Linux_install_script_0825.sh +++ b/tests/validation/setup/Kahawai_Linux_install_script_0825.sh @@ -1,5 +1,10 @@ #!/bin/bash +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2022-2025 Intel Corporation + +set -e -o pipefail + default_path=/home/media/ws work_path=${default_path}/workspace json_config_path="${work_path}/sample_config" @@ -10,10 +15,6 @@ expect_ice_version='1.9.11' expect_ddp_version='1.3.30.0' expect_dpdk_version='22.07' -export http_proxy=http://proxy-prc.intel.com:913 -export https_proxy=http://proxy-prc.intel.com:913 -export no_proxy="127.0.0.1,localhost,intel.com" - if [ -d ${work_path} ]; then rm -rf ${work_path} fi @@ -251,4 +252,4 @@ precondition check_ice_version build_install_dpdk bind_nic_pf -echo "Set up enviroment successfully" +echo "Set up environment successfully" diff --git a/tests/validation/setup/kahawai_windows_installer_v0.6.ps1 b/tests/validation/setup/kahawai_windows_installer_v0.6.ps1 index 108581aab..91924081c 100644 --- a/tests/validation/setup/kahawai_windows_installer_v0.6.ps1 +++ b/tests/validation/setup/kahawai_windows_installer_v0.6.ps1 @@ -1,4 +1,9 @@  +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2022-2025 Intel Corporation + +# This script is for development purposes only, use on your own risk + $defaultPath = (Get-Location) $workPath = "C:\ws\workspace" $dpdkPath = "$workPath\dpdk" @@ -9,28 +14,33 @@ $dpdkVersion = "22.07" $libdpdkPc = 'Libs.private:' $libdpdkLibsPc = 'Libs:-L${libdir} -lrte_latencystats -lrte_gso -lrte_bus_pci -lrte_gro -lrte_cfgfile -lrte_bitratestats -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_net_ice -lrte_net_iavf -lrte_common_iavf -lrte_mbuf -lrte_mempool -lrte_stack -lrte_mempool_stack -lrte_mempool_ring -lrte_rcu -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs -lrte_dmadev -lrte_dma_ioat' -#Check the test enviroment +# For proxy connections uncomment and fill below environment variables: +# $Env:http_proxy='http://my-fancy-proxy.intel.com:123' +# $Env:https_proxy='http://my-fancy-proxy.intel.com:123' +# $Env:no_proxy='127.0.0.1,localhost,intel.com' + +# Check the test enviroment function checkEnviroment { $checkDPDKPath = (Test-Path 'C:\dpdk') if($checkDPDKPath -eq "True") { - echo "-----------------remove C:\dpdk-----------------" + echo "-----------------remove C:\dpdk-----------------" Remove-Item 'C:\dpdk' -Recurse -Force } else { - echo "-----------------no C:\dpdk-----------------" + echo "-----------------no C:\dpdk-----------------" } $checkLibDPDKPath = (Test-Path 'C:\libst_dpdk') if($checkLibDPDKPath -eq "True") { - echo "-----------------remove C:\libst_dpdk-----------------" + echo "-----------------remove C:\libst_dpdk-----------------" Remove-Item 'C:\libst_dpdk' -Recurse -Force } else { - echo "-----------------no C:\libst_dpdk-----------------" + echo "-----------------no C:\libst_dpdk-----------------" } $checkWorkpath = (Test-Path $workPath) @@ -38,11 +48,11 @@ function checkEnviroment { echo "-----------------remove workspace-----------------" Remove-Item "$workPath\*" -Recurse -Force - } + } else { echo "-----------------mkdir workspace-----------------" - New-Item -Path $workPath -ItemType Directory + New-Item -Path $workPath -ItemType Directory } $checkKahwaiPackage = (Test-Path $kahawaiPackage) @@ -54,17 +64,13 @@ function checkEnviroment { echo "-----------------No kahawai source package, please check it-----------------" exit - } - + } } function downloadDPDK { cd $workPath - $Env:http_proxy='http://proxy-prc.intel.com:913' - $Env:https_proxy='http://proxy-prc.intel.com:913' - $Env:no_proxy="127.0.0.1,localhost,intel.com" echo "-----------------The DPDK package is downloading...-----------------" git clone https://github.com/DPDK/dpdk.git cd dpdk @@ -81,7 +87,6 @@ function downloadDPDK { echo "-----------------The version($DPDKVersion) of DPDK is not v$dpdkVersion-----------------" } - } @@ -89,7 +94,7 @@ function unzipKahawai { cd $workPath $CheckKahawaiPackage = (Test-Path $kahawaiPackage) - + if($CheckKahawaiPackage -eq "True") { echo "-----------------Kahawai package is unzipping....-----------------" @@ -138,7 +143,7 @@ function patchDPDK git am "$kahawaiPath\patches\dpdk\$dpdkVersion\$real_file" #echo "done" } - + $windowsPathType = file("$kahawaiPath\patches\dpdk\$dpdkVersion\windows").split(":")[1] if($windowsPathType -like "*symbolic link*") { @@ -150,7 +155,7 @@ function patchDPDK echo "The windows path is a normal path" $windowsRealPath = "windows" } - + $windowsPatchList = Get-ChildItem -Path "$kahawaiPath\patches\dpdk\$dpdkVersion\$windowsRealPath\*.patch" -Name foreach($file2 in $windowsPatchList) { @@ -181,7 +186,6 @@ function buildDPDK Remove-Item "C:\dpdk\lib\*.dll.a" (Get-Content "C:\dpdk\lib\pkgconfig\libdpdk.pc") | ForEach-Object {$_ -replace("Libs\..*","$libdpdkPc")} | Out-File -Encoding ASCII "C:\dpdk\lib\pkgconfig\libdpdk.pc" (Get-Content "C:\dpdk\lib\pkgconfig\libdpdk-libs.pc") | ForEach-Object {$_ -replace("^Libs:.*","$libdpdkLibsPc")} | Out-File -Encoding ASCII "C:\dpdk\lib\pkgconfig\libdpdk-libs.pc" - } function buildKahawai @@ -210,6 +214,6 @@ patchDPDK buildDPDK buildKahawai -echo "copy library to execting path" +echo "Copy library to execting path" cp C:\kahawai\lib_need_to_copy\* $kahawaiPath\tests\build -cp C:\kahawai\lib_need_to_copy\* $kahawaiPath\app\build \ No newline at end of file +cp C:\kahawai\lib_need_to_copy\* $kahawaiPath\app\build