Depending on the version of GNU binutils in use, the linkhuge or linkhuge_rw tests may be known to fail and in some cases hang. Allow the test suite to complete and produce clean output again by skipping tests that are known to be bad and suppressing redundant warning messages.
This patch handles the following cases: 1) If an xBDT linker script is used on a system that requires the use of the SPECIAL() linker script command for placement of the .plt and .got sections, the resulting binary will behave erratically (function calls will call the wrong functions) due to misplacement of the plt and got. The solution is to not run linkhuge tests if the use of SPECIAL is discovered in the system linker scripts. 2) GNU binutils < 2.17 does not support -zcommon-page-size and -zmax-page-size. These older versions will silently ignore the unrecognized options and produce binaries that are not suitably aligned for linkhuge_rw to be remapped into huge pages. The solution is to use linkhuge_rw in a test mode to check its alignment. If that test fails, suppress the redundant warning messages for the rest of linkhuge_rw tests. Signed-off-by: Adam Litke <[EMAIL PROTECTED]> --- tests/run_tests.sh | 112 +++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 79 insertions(+), 33 deletions(-) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index a1630c6..812ae88 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -31,6 +31,29 @@ HPAGE_SIZE=$(grep 'Hugepagesize:' /proc/meminfo | awk '{print $2}') [ -z "$HPAGE_SIZE" ] && HPAGE_SIZE=0 HPAGE_SIZE=$(( $HPAGE_SIZE * 1024 )) +# Up-front checks for the remapping test cases: +function check_linkhuge_tests() { + # In some circumstances, our linker scripts are known to be broken and + # they will produce binaries with undefined runtime behavior. In those + # cases don't bother running the xNNN.linkhuge tests + ld --verbose | grep -q SPECIAL + if [ $? -eq 0 ]; then + LINKHUGE_SKIP=1 + fi + + # Older GNU linkers (< 2.17) don't support -zcommon-page-size and + # -zmax-page-size which are required for linkhuge_rw to function correctly. + # When the support is missing, libhugetlbfs is very verbose to aid in + # problem diagnosis. To keep the test suite output clean in this case, + # only allow the verbose messages to be printed once. + bits=($WORDSIZES) + # Just run the test once for the first word size + run_test_bits ${bits[0]} linkhuge_rw --test-alignment + if [ $? -ne 0 ]; then + LINKHUGERW_QUIET=1 + fi +} + run_test_bits () { BITS=$1 shift @@ -51,6 +74,25 @@ skip_test () { echo "$@: SKIPPED" } +maybe_run_linkhuge_test () { + if [ $LINKHUGE_SKIP -ne 1 ]; then + run_test "$@" + else + skip_test "$@" + fi +} + +run_linkhuge_rw_test () { + if [ $LINKHUGERW_QUIET -ne 1 ]; then + run_test "$@" + else + verbose=$HUGETLB_VERBOSE + export HUGETLB_VERBOSE=1 + run_test "$@" + export HUGETLB_VERBOSE=$verbose + fi +} + preload_test () { run_test LD_PRELOAD=libhugetlbfs.so "$@" } @@ -64,28 +106,28 @@ elflink_test () { run_test "$@" "$baseprog" # Test we don't blow up if not linked for hugepage preload_test "$@" "$baseprog" - run_test "$@" "xB.$baseprog" - run_test "$@" "xBDT.$baseprog" + maybe_run_linkhuge_test "$@" "xB.$baseprog" + maybe_run_linkhuge_test "$@" "xBDT.$baseprog" # Test we don't blow up if HUGETLB_MINIMAL_COPY is diabled - run_test HUGETLB_MINIMAL_COPY=no "$@" "xB.$baseprog" - run_test HUGETLB_MINIMAL_COPY=no "$@" "xBDT.$baseprog" + maybe_run_linkhuge_test HUGETLB_MINIMAL_COPY=no "$@" "xB.$baseprog" + maybe_run_linkhuge_test HUGETLB_MINIMAL_COPY=no "$@" "xBDT.$baseprog" # Test that HUGETLB_ELFMAP=no inhibits remapping as intended - run_test HUGETLB_ELFMAP=no "$@" "xB.$baseprog" - run_test HUGETLB_ELFMAP=no "$@" "xBDT.$baseprog" + maybe_run_linkhuge_test HUGETLB_ELFMAP=no "$@" "xB.$baseprog" + maybe_run_linkhuge_test HUGETLB_ELFMAP=no "$@" "xBDT.$baseprog" } elflink_rw_test() { # Basic tests: None, Read-only, Write-only, Read-Write, exlicit disable - run_test linkhuge_rw - run_test HUGETLB_ELFMAP=R linkhuge_rw - run_test HUGETLB_ELFMAP=W linkhuge_rw - run_test HUGETLB_ELFMAP=RW linkhuge_rw - run_test HUGETLB_ELFMAP=no linkhuge_rw + run_linkhuge_rw_test linkhuge_rw + run_linkhuge_rw_test HUGETLB_ELFMAP=R linkhuge_rw + run_linkhuge_rw_test HUGETLB_ELFMAP=W linkhuge_rw + run_linkhuge_rw_test HUGETLB_ELFMAP=RW linkhuge_rw + run_linkhuge_rw_test HUGETLB_ELFMAP=no linkhuge_rw # Test we don't blow up if HUGETLB_MINIMAL_COPY is disabled - run_test HUGETLB_MINIMAL_COPY=no HUGETLB_ELFMAP=R linkhuge_rw - run_test HUGETLB_MINIMAL_COPY=no HUGETLB_ELFMAP=W linkhuge_rw - run_test HUGETLB_MINIMAL_COPY=no HUGETLB_ELFMAP=RW linkhuge_rw + run_linkhuge_rw_test HUGETLB_MINIMAL_COPY=no HUGETLB_ELFMAP=R linkhuge_rw + run_linkhuge_rw_test HUGETLB_MINIMAL_COPY=no HUGETLB_ELFMAP=W linkhuge_rw + run_linkhuge_rw_test HUGETLB_MINIMAL_COPY=no HUGETLB_ELFMAP=RW linkhuge_rw } elfshare_test () { @@ -98,12 +140,12 @@ elfshare_test () { # sharefiles before and after in the first set of runs, but leave # them there in the second: clear_hpages - run_test HUGETLB_SHARE=1 "$@" "xB.$baseprog" + maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xB.$baseprog" clear_hpages - run_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog" + maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog" clear_hpages - run_test HUGETLB_SHARE=1 "$@" "xB.$baseprog" - run_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog" + maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xB.$baseprog" + maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog" clear_hpages } @@ -116,24 +158,24 @@ elflink_and_share_test () { # Run each elflink test pair independently - clean up the sharefiles # before and after each pair clear_hpages - run_test HUGETLB_SHARE=1 "$@" "xB.$baseprog" - run_test HUGETLB_SHARE=1 "$@" "xB.$baseprog" + maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xB.$baseprog" + maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xB.$baseprog" clear_hpages - run_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog" - run_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog" + maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog" + maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog" clear_hpages } elflink_rw_and_share_test () { clear_hpages - run_test HUGETLB_ELFMAP=R HUGETLB_SHARE=1 linkhuge_rw - run_test HUGETLB_ELFMAP=R HUGETLB_SHARE=1 linkhuge_rw + run_linkhuge_rw_test HUGETLB_ELFMAP=R HUGETLB_SHARE=1 linkhuge_rw + run_linkhuge_rw_test HUGETLB_ELFMAP=R HUGETLB_SHARE=1 linkhuge_rw clear_hpages - run_test HUGETLB_ELFMAP=W HUGETLB_SHARE=1 linkhuge_rw - run_test HUGETLB_ELFMAP=W HUGETLB_SHARE=1 linkhuge_rw + run_linkhuge_rw_test HUGETLB_ELFMAP=W HUGETLB_SHARE=1 linkhuge_rw + run_linkhuge_rw_test HUGETLB_ELFMAP=W HUGETLB_SHARE=1 linkhuge_rw clear_hpages - run_test HUGETLB_ELFMAP=RW HUGETLB_SHARE=1 linkhuge_rw - run_test HUGETLB_ELFMAP=RW HUGETLB_SHARE=1 linkhuge_rw + run_linkhuge_rw_test HUGETLB_ELFMAP=RW HUGETLB_SHARE=1 linkhuge_rw + run_linkhuge_rw_test HUGETLB_ELFMAP=RW HUGETLB_SHARE=1 linkhuge_rw clear_hpages } @@ -218,15 +260,19 @@ functional_tests () { preload_test HUGETLB_MORECORE=yes HUGETLB_MORECORE_SHRINK=yes heapshrink run_test LD_PRELOAD="libhugetlbfs.so libheapshrink.so" HUGETLB_MORECORE=yes HUGETLB_MORECORE_SHRINK=yes heapshrink run_test HUGETLB_VERBOSE=1 HUGETLB_MORECORE=yes heap-overflow # warnings expected + +# Run the remapping tests' up-front checks +check_linkhuge_tests +# Original elflink tests elflink_test HUGETLB_VERBOSE=0 linkhuge_nofd # Lib error msgs expected elflink_test linkhuge - - # Test RW-style remapping mechanism - elflink_rw_test - -# Sharing tests +# Original elflink sharing tests elfshare_test linkshare elflink_and_share_test linkhuge + +# elflink_rw tests + elflink_rw_test +# elflink_rw sharing tests elflink_rw_and_share_test # Accounting bug tests ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel