libhugetlbfs is able to run a variety of regression tests against the
currently running kernel. Some of these tests may fail due to known
reasons such as the kernel being too old. It is unreasonable to expect an
ordinary user of the library to determine that a FAIL is really an "expected
fail". This patch introduces a framework where verification scripts can be
added called verifyresults-TESTNAME.sh. It gets passed the return value
of the regression script and returns 0 if the output is expected and 1
otherwise. This in combination with a message can be used to report to the
user if a FAILed test is due to expected reasons.

Signed-off-by: Mel Gorman <[EMAIL PROTECTED]>
---
 tests/run_tests.sh |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index c98179d..a08eecb 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -55,7 +55,34 @@ run_test_bits () {
 
     if [ -d obj$BITS ]; then
        echo -n "$@ ($BITS):    "
-       PATH="obj$BITS:$PATH" 
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:../obj$BITS:obj$BITS" $ENV "$@"
+       OUTPUT=`PATH="obj$BITS:$PATH" 
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:../obj$BITS:obj$BITS" $ENV "$@"`
+       RETVAL=$?
+
+       # Figure out the name of the testcase we just ran
+       echo $1 | grep = > /dev/null
+       while [ $? -eq 0 ]; do
+               shift 1
+               echo $1 | grep = > /dev/null
+       done
+
+       # Run a postprocessing script if it exists. Given the return value
+       # of the regression test, a post-processing script returns 0 if the
+       # result is expected and non-zero otherwise. If the user should be
+       # informed, it may print out a reason for the decision. For example,
+       # a post-processing script can detect that a FAIL is expected due
+       # to an old kernel and print that explanation so the user does not
+       # report the FAIL
+       if [ -e verifyresults-$1.sh ]; then
+               REASON=`./verifyresults-$1.sh $RETVAL`
+               if [ "$REASON" != "" ]; then
+                       if [ $? -eq 0 ]; then
+                               OUTPUT="EXPECTED $OUTPUT ($REASON)"
+                       else
+                               OUTPUT="UNEXPECTED $OUTPUT ($REASON)"
+                       fi
+               fi
+       fi
+       echo "$OUTPUT"
     fi
 }
 
-- 
1.5.6.3


>From 252b588264b8d14a3f01bd17ba2b4c1aca4d2ed1 Mon Sep 17 00:00:00 2001
From: Mel Gorman <[EMAIL PROTECTED]>
Date: Thu, 31 Jul 2008 18:31:39 +0100
Subject: [PATCH 2/3] Detect the expected failure of linkhuge_rw due to an old 
binutils

binutils 2.17 or later is required for the linkhuge_rw tests to pass
successfully. If the regression test fails and binutils is old, a
message to this effect will be given to the user.

Signed-off-by: Mel Gorman <[EMAIL PROTECTED]>
---
 tests/verifyresults-linkhuge_rw.sh |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
 create mode 100755 tests/verifyresults-linkhuge_rw.sh

diff --git a/tests/verifyresults-linkhuge_rw.sh 
b/tests/verifyresults-linkhuge_rw.sh
new file mode 100755
index 0000000..f55dbd6
--- /dev/null
+++ b/tests/verifyresults-linkhuge_rw.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+# linkhuge_rw is expected to fail only if binutils is older than 2.6.17
+
+# If the return value of linkhuge_rw was PASS, then it is expected
+if [ $1 -eq 0 ]; then
+       exit 0
+fi
+
+# If the result was FAIL but it is an old binutils, it's expected
+ELFMAP_SKIP=0
+BINUTILS_VERSION=`ld -v | sed -e 's/[a-zA-Z() \t]//g'`
+MAJOR=`echo $BINUTILS_VERSION | cut -d. -f1`
+MINOR=`echo $BINUTILS_VERSION | cut -d. -f2`
+
+if [ $MAJOR -lt 2 ] || [ $MAJOR -eq 2 -a $MINOR -lt 17 ]; then
+       echo Binutils is too old to support the test
+       exit 0
+fi
+
+# Otherwise this is an unexpected failure
+exit 1
-- 
1.5.6.3


>From 54a801daec7620a99be7c82376ff10b401d9c8b8 Mon Sep 17 00:00:00 2001
From: Mel Gorman <[EMAIL PROTECTED]>
Date: Thu, 31 Jul 2008 19:18:22 +0100
Subject: [PATCH 3/3] Use a linkhuge verification script to detect expected 
FAILs instead of skipping

Currently some of the linkhuge scripts are skipped in the event the
keyboard SPECIAL is found in ld --verbose. Instead of skipping the tests,
this will run them. However, if the test fails the user will be told it is
an expected failure.

Signed-off-by: Mel Gorman <[EMAIL PROTECTED]>
---
 tests/Makefile                  |   10 ++++++-
 tests/run_tests.sh              |   52 ++++++++++----------------------------
 tests/verifyresults-linkhuge.sh |   22 ++++++++++++++++
 3 files changed, 45 insertions(+), 39 deletions(-)
 create mode 100644 tests/verifyresults-linkhuge.sh

diff --git a/tests/Makefile b/tests/Makefile
index b723db7..24c438d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -65,7 +65,15 @@ ifdef CC64
 ALLTESTS += $(TESTS_64:%=obj64/%)
 endif
 
-all:   $(ALLTESTS) $(ALLHELPERS) $(ALLHELPERLIBS)
+# Setup symbolic links to duplicate verification scripts
+symlink_verifydups: verifyresults-linkhuge.sh
+       for LINK in linkhuge_nofd linkshare; do \
+               if [ ! -e verifyresults-$$LINK.sh ]; then \
+                       ln -s verifyresults-linkhuge.sh 
verifyresults-$$LINK.sh; \
+               fi \
+       done
+       
+all:   symlink_verifydups $(ALLTESTS) $(ALLHELPERS) $(ALLHELPERLIBS)
 
 obj32/%.o: %.c
        @$(VECHO) CC32 $@
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index a08eecb..b8094b3 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -35,20 +35,6 @@ 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.  This checks if the
-    # system linker scripts use the SPECIAL keyword (for placing the got and
-    # plt).  Our linker scripts do not use SPECIAL and are thus broken when the
-    # system scripts use it.
-    ld --verbose | grep -q SPECIAL
-    if [ $? -eq 0 ]; then
-        LINKHUGE_SKIP=1
-    fi
-}
-
 run_test_bits () {
     BITS=$1
     shift
@@ -98,14 +84,6 @@ skip_test () {
     echo "$@:  SKIPPED"
 }
 
-maybe_run_linkhuge_test () {
-    if [ "$LINKHUGE_SKIP" != "1" ]; then
-        run_test "$@"
-    else
-        skip_test "$@"
-    fi
-}
-
 preload_test () {
     run_test LD_PRELOAD=libhugetlbfs.so "$@"
 }
@@ -119,14 +97,14 @@ elflink_test () {
     run_test "$@" "$baseprog"
     # Test we don't blow up if not linked for hugepage
     preload_test "$@" "$baseprog"
-    maybe_run_linkhuge_test "$@" "xB.$baseprog"
-    maybe_run_linkhuge_test "$@" "xBDT.$baseprog"
+    run_test "$@" "xB.$baseprog"
+    run_test "$@" "xBDT.$baseprog"
     # Test we don't blow up if HUGETLB_MINIMAL_COPY is diabled
-    maybe_run_linkhuge_test HUGETLB_MINIMAL_COPY=no "$@" "xB.$baseprog"
-    maybe_run_linkhuge_test HUGETLB_MINIMAL_COPY=no "$@" "xBDT.$baseprog"
+    run_test HUGETLB_MINIMAL_COPY=no "$@" "xB.$baseprog"
+    run_test HUGETLB_MINIMAL_COPY=no "$@" "xBDT.$baseprog"
     # Test that HUGETLB_ELFMAP=no inhibits remapping as intended
-    maybe_run_linkhuge_test HUGETLB_ELFMAP=no "$@" "xB.$baseprog"
-    maybe_run_linkhuge_test HUGETLB_ELFMAP=no "$@" "xBDT.$baseprog"
+    run_test HUGETLB_ELFMAP=no "$@" "xB.$baseprog"
+    run_test HUGETLB_ELFMAP=no "$@" "xBDT.$baseprog"
 }
 
 elflink_rw_test() {
@@ -153,12 +131,12 @@ elfshare_test () {
     # sharefiles before and after in the first set of runs, but leave
     # them there in the second:
     clear_hpages
-    maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xB.$baseprog"
+    run_test HUGETLB_SHARE=1 "$@" "xB.$baseprog"
     clear_hpages
-    maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog"
+    run_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog"
     clear_hpages
-    maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xB.$baseprog"
-    maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog"
+    run_test HUGETLB_SHARE=1 "$@" "xB.$baseprog"
+    run_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog"
     clear_hpages
 }
 
@@ -171,11 +149,11 @@ elflink_and_share_test () {
     # Run each elflink test pair independently - clean up the sharefiles
     # before and after each pair
     clear_hpages
-    maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xB.$baseprog"
-    maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xB.$baseprog"
+    run_test HUGETLB_SHARE=1 "$@" "xB.$baseprog"
+    run_test HUGETLB_SHARE=1 "$@" "xB.$baseprog"
     clear_hpages
-    maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog"
-    maybe_run_linkhuge_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog"
+    run_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog"
+    run_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog"
     clear_hpages
 }
 
@@ -276,8 +254,6 @@ functional_tests () {
     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
diff --git a/tests/verifyresults-linkhuge.sh b/tests/verifyresults-linkhuge.sh
new file mode 100644
index 0000000..2e5ecb0
--- /dev/null
+++ b/tests/verifyresults-linkhuge.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# In some circumstances, our linker scripts are known to be broken and
+# they will produce binaries with undefined runtime behavior. This checks if
+# the system linker scripts use the SPECIAL keyword (for placing the got and
+# plt). Our linker scripts do not use SPECIAL and are thus broken when the
+# system scripts use it so tell the user any FAIL is expected.
+
+# Check that we passed as expected
+if [ $1 -eq 0 ]; then
+       exit 0
+fi
+
+# If we failed and it is due to ld, it is expected
+ld --verbose | grep -q SPECIAL > /dev/null
+if [ $? -eq 0 ]; then
+       echo System linker scripts use SPECIAL which is known to be broken
+       exit 0
+fi
+
+# Otherwise, this is unexpected breakage
+exit 0
-- 
1.5.6.3


-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to