X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fbash%2Ffunction%2Fper_patch.sh;h=cfd22e7826334d07c6d61535b4d16d199f9b5929;hb=f80c4dc842b77e9231e443f7ef10e4a735f18e1f;hp=abf2cac6884755d669ea36f3c1ba511641e1e2f3;hpb=3111f250640b2f0364bd62104416ada41098b280;p=csit.git diff --git a/resources/libraries/bash/function/per_patch.sh b/resources/libraries/bash/function/per_patch.sh index abf2cac688..cfd22e7826 100644 --- a/resources/libraries/bash/function/per_patch.sh +++ b/resources/libraries/bash/function/per_patch.sh @@ -1,4 +1,5 @@ -# Copyright (c) 2018 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. +# Copyright (c) 2023 PANTHEON.tech s.r.o. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -36,7 +37,8 @@ function archive_test_results () { cd "${VPP_DIR}" || die "Change directory command failed." TARGET="$(readlink -f "$1")" mkdir -p "${TARGET}" || die "Directory creation failed." - for filename in "output.xml" "log.html" "report.html"; do + file_list=("output.xml" "log.html" "report.html" "tests") + for filename in "${file_list[@]}"; do mv "${ARCHIVE_DIR}/${filename}" "${TARGET}/${filename}" || { die "Attempt to move '${filename}' failed." } @@ -44,26 +46,6 @@ function archive_test_results () { } -function archive_parse_test_results () { - - # Arguments: - # - ${1}: Directory to archive to. Required. Parent has to exist. - # Variables read: - # - TARGET - Target directory. - # Functions called: - # - die - Print to stderr and exit, defined in common.sh - # - archive_test_results - Archiving results. - # - parse_bmrr_results - See definition in this file. - - set -exuo pipefail - - archive_test_results "$1" || die - parse_bmrr_results "${TARGET}" || { - die "The function should have died on error." - } -} - - function build_vpp_ubuntu_amd64 () { # This function is using make pkg-verify to build VPP with all dependencies @@ -73,6 +55,8 @@ function build_vpp_ubuntu_amd64 () { # Arguments: # - ${1} - String identifier for echo, can be unset. # Variables read: + # - MAKE_PARALLEL_FLAGS - Make flags when building VPP. + # - MAKE_PARALLEL_JOBS - Number of cores to use when building VPP. # - VPP_DIR - Path to existing directory, parent to accessed directories. # Directories updated: # - ${VPP_DIR} - Whole subtree, many files (re)created by the build process. @@ -82,7 +66,18 @@ function build_vpp_ubuntu_amd64 () { set -exuo pipefail cd "${VPP_DIR}" || die "Change directory command failed." - make UNATTENDED=y pkg-verify || die "VPP build using make pkg-verify failed." + if [ -n "${MAKE_PARALLEL_FLAGS-}" ]; then + echo "Building VPP. Number of cores for build set with" \ + "MAKE_PARALLEL_FLAGS='${MAKE_PARALLEL_FLAGS}'." + elif [ -n "${MAKE_PARALLEL_JOBS-}" ]; then + echo "Building VPP. Number of cores for build set with" \ + "MAKE_PARALLEL_JOBS='${MAKE_PARALLEL_JOBS}'." + else + echo "Building VPP. Number of cores not set, " \ + "using build default ($(grep -c ^processor /proc/cpuinfo))." + fi + + make UNATTENDED=y pkg-verify || die "VPP build with make pkg-verify failed." echo "* VPP ${1-} BUILD SUCCESSFULLY COMPLETED" || { die "Argument not found." } @@ -100,7 +95,6 @@ function compare_test_results () { # of parent build. # Functions called: # - die - Print to stderr and exit, defined in common.sh - # - parse_bmrr_results - See definition in this file. # Exit code: # - 0 - If the comparison utility sees no regression (nor data error). # - 1 - If the comparison utility sees a regression (or data error). @@ -114,39 +108,10 @@ function compare_test_results () { } -function download_builds () { - - # This is mostly useful only for Sandbox testing, to avoid recompilation. - # - # Arguments: - # - ${1} - URL to download VPP builds from. - # Variables read: - # - VPP_DIR - Path to WORKSPACE, parent of created directories. - # Directories created: - # - archive - Ends up empty, not to be confused with ${ARCHIVE_DIR}. - # - build_current - Holding built artifacts of the patch under test (PUT). - # - built_parent - Holding built artifacts of parent of PUT. - # Functions called: - # - die - Print to stderr and exit, defined in common.sh +function initialize_csit_dirs () { set -exuo pipefail - cd "${VPP_DIR}" || die "Change directory operation failed." - dirs=("build-root" "build_parent" "build_current" "archive" "csit_current") - rm -rf ${dirs[@]} || { - die "Directory removal failed." - } - wget -N --progress=dot:giga "${1}" || die "Wget download failed." - unzip "archive.zip" || die "Archive extraction failed." - mv "archive/build_parent" ./ || die "Move operation failed." - mv "archive/build_current" ./ || die "Move operation failed." -} - - -function initialize_csit_dirs () { - - # This could be in prepare_test, but download_builds also needs this. - # # Variables read: # - VPP_DIR - Path to WORKSPACE, parent of created directories. # Directories created: @@ -167,36 +132,6 @@ function initialize_csit_dirs () { } -function parse_bmrr_results () { - - # Currently "parsing" is just two greps. - # TODO: Re-use PAL parsing code, make parsing more general and centralized. - # - # Arguments: - # - ${1} - Path to (existing) directory holding robot output.xml result. - # Files read: - # - output.xml - From argument location. - # Files updated: - # - results.txt - (Re)created, in argument location. - # Functions called: - # - die - Print to stderr and exit, defined in common.sh - - set -exuo pipefail - - rel_dir="$(readlink -e "${1}")" || die "Readlink failed." - in_file="${rel_dir}/output.xml" - out_file="${rel_dir}/results.txt" - # TODO: Do we need to check echo exit code explicitly? - echo "Parsing ${in_file} putting results into ${out_file}" - echo "TODO: Re-use parts of PAL when they support subsample test parsing." - pattern='Maximum Receive Rate trial results in packets' - pattern+=' per second: .*\]' - grep -o "${pattern}" "${in_file}" | grep -o '\[.*\]' > "${out_file}" || { - die "Some parsing grep command has failed." - } -} - - function select_build () { # Arguments: