quota is known to fail on kernels < 2.6.24. Create a wrapper script to check for an old running kernel and report the failure as expected. Place reusable shell functions into their own wrapper-utils.sh script.
Changes since V1: - Make sure to install wrapper-utils.sh along with tests Signed-off-by: Adam Litke <[EMAIL PROTECTED]> --- tests/Makefile | 4 +++ tests/quota.sh | 13 +++++++++++ tests/run_tests.sh | 2 +- tests/wrapper-utils.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100755 tests/quota.sh create mode 100644 tests/wrapper-utils.sh diff --git a/tests/Makefile b/tests/Makefile index ff4f61f..009f75f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -16,7 +16,7 @@ LDSCRIPT_TESTS = zero_filesize_segment HUGELINK_TESTS = linkhuge linkhuge_nofd linkshare HUGELINK_RW_TESTS = linkhuge_rw STRESS_TESTS = mmap-gettest mmap-cow shm-gettest shm-getraw shm-fork -WRAPPERS = +WRAPPERS = quota HELPERS = get_hugetlbfs_path compare_kvers HELPER_LIBS = libheapshrink.so BADTOOLCHAIN = bad-toolchain.sh @@ -217,6 +217,7 @@ obj32/install: $(INSTALL) -d $(DESTDIR)$(INST_TESTSDIR32)/obj32 $(INSTALL) -m 755 $(TESTS:%=obj32/%) $(DESTDIR)$(INST_TESTSDIR32)/obj32 $(INSTALL) -m 755 $(WRAPPERS32) $(DESTDIR)$(INST_TESTSDIR32)/obj32 + $(INSTALL) -m 755 wrapper-utils.sh $(DESTDIR)$(INST_TESTSDIR32)/obj32 $(INSTALL) -m 755 $(HELPERS:%=obj32/%) $(DESTDIR)$(INST_TESTSDIR32)/obj32 $(INSTALL) -m 755 $(HELPER_LIBS:%=obj32/%) $(DESTDIR)$(INST_TESTSDIR32)/obj32 $(INSTALL) -m 755 run_tests.sh $(DESTDIR)$(INST_TESTSDIR32) @@ -227,6 +228,7 @@ obj64/install: $(INSTALL) -d $(DESTDIR)$(INST_TESTSDIR64)/obj64 $(INSTALL) -m 755 $(TESTS:%=obj64/%) $(DESTDIR)$(INST_TESTSDIR64)/obj64 $(INSTALL) -m 755 $(WRAPPERS64) $(DESTDIR)$(INST_TESTSDIR64)/obj64 + $(INSTALL) -m 755 wrapper-utils.sh $(DESTDIR)$(INST_TESTSDIR64)/obj64 $(INSTALL) -m 755 $(HELPERS:%=obj64/%) $(DESTDIR)$(INST_TESTSDIR64)/obj64 $(INSTALL) -m 755 $(HELPER_LIBS:%=obj64/%) $(DESTDIR)$(INST_TESTSDIR64)/obj64 $(INSTALL) -m 755 $(TESTS_64:%=obj64/%) $(DESTDIR)$(INST_TESTSDIR64)/obj64 diff --git a/tests/quota.sh b/tests/quota.sh new file mode 100755 index 0000000..398d442 --- /dev/null +++ b/tests/quota.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +. wrapper-utils.sh + +# There are known bugs in quota accounting prior to 2.6.24 +compare_kvers `uname -r` "2.6.24" +if [ $? -eq 1 ]; then + EXP_RC=$RC_FAIL +else + EXP_RC=$RC_PASS +fi + +exec_and_check $EXP_RC quota "$@" diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 19cd9ee..9064451 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -346,7 +346,7 @@ check_linkhuge_tests run_test LD_PRELOAD=libhugetlbfs.so shmoverride_unlinked # Test hugetlbfs filesystem quota accounting - run_test quota + run_test quota.sh # Test accounting of HugePages_{Total|Free|Resv|Surp} # Alters the size of the hugepage pool so should probably be run last diff --git a/tests/wrapper-utils.sh b/tests/wrapper-utils.sh new file mode 100644 index 0000000..2f6451d --- /dev/null +++ b/tests/wrapper-utils.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# Standard return codes +RC_PASS=0 +RC_CONFIG=1 +RC_FAIL=2 +RC_XFAIL=3 +RC_XPASS=4 +RC_BUG=99 + +function unexpected_pass() +{ + echo -n "UNEXPECTED " +} + +function expected_fail() +{ + echo -n "EXPECTED " +} + +# check_rc (<expected return code>, <actual return code>) +# Returns: Adjusted return code +# +# Check the actual and expected return codes to identify +# expected failures and unexpected passes. +function check_rc() +{ + EXP_RC=$1 + ACT_RC=$2 + + if [ $ACT_RC -eq $RC_PASS -a $EXP_RC -ne $RC_PASS ]; then + unexpected_pass + return $RC_XPASS + elif [ $EXP_RC -ne $RC_PASS -a $EXP_RC -eq $ACT_RC ]; then + expected_fail + return $RC_XFAIL + else + return $ACT_RC + fi +} + +# exec_and_check (<expected return code>, <command-line ...>) +# Does not return +# Execute a test command and check for expected failures and unexpected passes. +function exec_and_check() +{ + EXP_RC=$1 + shift + + [EMAIL PROTECTED] + check_rc $EXP_RC $? + RC=$? + echo $OUTPUT + + exit $RC +} ------------------------------------------------------------------------- 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