Test-definitions/tree/master/auto-test/libhugetlbfs,
Test-definitions/tree/master/auto-test/libhugetlbfs
#! /Bin/sh # shellcheck disable = SC1091... /.. /lib/sh-test-lib # assign the initial value OUTPUT = "$ (pwd) to the variable) /output "RESULT_FILE =" $ {OUTPUT}/result.txt "RESULT_LOG =" $ {OUTPUT}/result_log.txt "TMP_LOG =" $ {OUTPUT}/tmp_log.txt "TEST_PASS_LOG =" $ {OUTPUT} /test_pass_log.txt "TEST_FAIL_LOG =" $ {OUTPUT}/test_fail_log.txt "TEST_SKIP_LOG =" $ {OUTPUT}/test_skip_log.txt "CWD =" "WORD_SIZE =" 64 "VERSION =" 2.20 "# define function Description how to use usage () {echo "Usage: $0 [-B <4 | 64>] [-s
] [-V
] "1> & 2 exit 1} # parse location parameter while getopts" B: s: v: "o; do case" $ o "in B) WORD_SIZE = "$ {OPTARG}"; s) SKIP_INSTALL = "$ {OPTARG}"; v) VERSION = "$ {OPTARG}"; *) usage ;; esacdone # defines the function, which is basically replaced by sed and inserted into the file parse_output () {# Avoid results summary lines start with "*" sed-I-e's //-/G' "$ {TMP_LOG}" # shellcheck disable = SC2063 grep-v "*" "$ {TMP_LOG}" | tee-a "$ {RESULT_LOG}" # Parse each type of results egrep "PASS" "$ {RESULT_LOG}" | tee-" $ {TEST_PASS_LOG} "sed-I-e's/(inconclusive) // G' "$ {TEST_PASS_LOG}" sed-I-e's/(// G' "$ {TEST_PASS_LOG}" sed-I-e's /): // G' "$ {TEST_PASS_LOG}" sed-I-e's/: // G' "$ {TEST_PASS_LOG}" awk '{for (I = 1; I <NF-1; I ++) = "" printf = "" $ I = """-"; = "" print = "=" "$ nf} '=" $ {test_pass_log} "=" "2 =" "> & 1 | tee-a" $ {RESULT_FILE} "sed-I-e's/PASS/pass/G'" $ {RESULT_FILE} "egrep" FAIL "" $ {RESULT_LOG} "| cut-d: -f 1-2 2> & 1 | tee-a "$ {TEST_FAIL_LOG}" sed-I-e's/(inconclusive) // G' "$ {TEST_FAIL_LOG}" sed-I-e's/(// G' "$ {TEST_FAIL_LOG}" sed-I-e's /) // G' "$ {TEST_FAIL_LOG}" sed-I-e's/: // G' "$ {TEST_FAIL_LOG}" awk '{for (I = 1; I <nf; I ++) = "" printf = "" $ I = """-"; = "" print = "=" fail "} '=" $ {test_fail_log} "=" "2 =" "> & 1 | tee-" $ {RESULT_FILE} "egrep" SKIP "" $ {RESULT_LOG} "| cut-d: -f 1-2 2> & 1 | tee-a "$ {TEST_SKIP_LOG}" egrep "Bad configuration" "$ {RESULT_LOG}" | cut-d: -f 1-2 2> & 1 | tee-a "$ {TEST_SKIP_LOG}" sed-I-e's/(inconclusive) // G' "$ {TEST_SKIP_LOG}" sed-I-e's/(// G' "$ {TEST_SKIP_LOG}" sed-I-e's /) // G' "$ {TEST_SKIP_LOG}" sed-I-e's/: // G' "$ {TEST_SKIP_LOG}" awk '{for (I = 1; I <nf; I ++) = "" printf = "" $ I = """-"; = "" print = "=" skip "} '=" $ {test_skip_log} "=" "2 =" "> & 1 | tee-" $ {RESULT_FILE} "# Replace" = "with" _ "in test case names sed-I-e's/=/_/G'" $ {RESULT_FILE} "# Clean up rm-rf "$ {TMP_LOG}" "$ {RESULT_LOG}" "$ {TEST_PASS_LOG}" $ {TEST_FAIL_LOG} "$ {TEST_SKIP_LOG}"} libhugetlbfs_setup () {mount_point = "/mnt/hugetlb/" # Allocate hugepages echo 200>/proc/sys/vm/nr_hugepages # umount mount point umount "$ {mount_point}">/dev/ null 2> & 1 | true # create a directory, re-mount to the new directory mkdir-p "$ {mount_point}" mount-t hugetlbfs "$ {mount_point}"} libhugetlbfs_cleanup () {# umount mount point umount "$ {mount_point}">/dev/null 2> & 1 | true if [-n "$ {CWD}"]; then # shellcheck disable = SC2164 # enter the current directory, delete the directory cd "$ {CWD}" rm-rf libhugetlbfs-"$ {VERSION}">/dev/null 2> & 1 | true rm-rf libhugetlbfs-"$ {VERSION} ".tar.gz>/dev/null 2> & 1 | true fi} libhugetlbfs_build_test () {# shellcheck disable = SC2140 # Upstream tree # wget https://github.com/libhugetlbfs/libhugetlbfs/releases/download/ "$ {VERSION}"/libhugetlbfs-"$ {VERSION}" .tar.gz # TODO # Private tree with CentOS build fix # When patch is upstream remove private tree and enable upstream tree # download tar package, decompress the tar package and make wget again. https://github.com/nareshkamboju/libhugetlbfs/releases/download/ "$ {VERSION}"/libhugetlbfs-"$ {VERSION}" .tar.gz CWD = $ (pwd) tar-xvf libhugetlbfs-"$ {VERSION}" .tar.gz # shellcheck disable = SC2164 cd libhugetlbfs-"$ {VERSION}" make BUILDTYPE = NATIVEONLY} libhugetlbfs_run_test () {# shellcheck disable = SC2164 cd tests # Run tests # Redirect stdout (not stderr) # Run the script to start the test. /run_tests.py-B "$ {WORD_SIZE}" | tee-a "$ {TMP_LOG}" parse_output} # install different dependent packages for different releases install () {dist_name # Shellcheck disable = SC2154 case "$ {dist}" in debian | ubuntu) pkgs = "binutils gcc make python sed tar wget" install_deps "$ {pkgs}" "$ {SKIP_INSTALL}"; fedora | centos) pkgs = "binutils gcc glibc-static make python sed tar wget" install_deps "$ {pkgs}" $ {SKIP_INSTALL} "; esac} # Test run. # Check whether it is root. If it is not a root user, an error log is output! Check_root & error_msg "This script must be run as root" create_out_dir "$ {OUTPUT}" # shellcheck disable = SC2164cd "$ {OUTPUT}" info_msg "About to run libhugetlbfs test... "info_msg" Output directory: $ {OUTPUT} "# You can see two ways to query kernel config, one is/proc/config.gz if [-f/proc/config.gz] thenCONFIG_HUGETLBFS =$ (zcat/proc/config.gz | grep "CONFIG_HUGETLBFS = ") CONFIG_HUGETLB_PAGE = $ (zcat/proc/config.gz | grep "CONFIG_HUGETLB_PAGE =") # The other is/boot/config-"$ (uname-r) "elif [-f/boot/config-" $ (uname-r) "] thenKERNEL_CONFIG_FILE ="/boot/config-$ (uname-r) "CONFIG_HUGETLBFS = $ (grep" CONFIG_HUGETLBFS = "" $ {KERNEL_CONFIG_FILE} ") CONFIG_HUGETLB_PAGE = $ (grep" CONFIG_HUGETLB_PAGE = "" $ {KERNEL_CONFIG_FILE }") elseexit_on_skip "libhugetlb-pre-requirements" "Kernel config file not available" fiHUGETLBFS =$ (grep hugetlbfs/proc/filesystems | awk '{print $2 }') ["$ {CONFIG_HUGETLBFS}" = "CONFIG_HUGETLBFS = y"] & ["$ {CONFIG_HUGETLB_PAGE}" = "CONFIG_HUGETLB_PAGE = y"] & ["$ {HUGETLBFS}" = ""hugetlbfs"] Kernel "libhugetlb-pre-requirements" "Kernel config CONFIG_HUGETLBFS = y and Kernel = y not enabled" # Install packagesinstall # Setup writable mount paths # Find the PRE_BUILD_PATH = directory of run_test.py "$ (find/usr/lib */libhugetlbfs-type f-name run_tests.py) "if [-n" $ {PRE_BUILD_PATH} "] then echo" pre built libhugetlbfs found on rootfs "# shellcheck disable = SC2164 cd/usr/lib */issue # Build libhugetlbfs tests release # Run libhugetlbfs testslibhugetlbfs_run_test # Unmount libhugetlbfs mount pointlibhugetlbfs_cleanup