diff --git a/run-make-check.sh b/run-make-check.sh index 4ff0783194e37..e609816782d31 100755 --- a/run-make-check.sh +++ b/run-make-check.sh @@ -61,11 +61,6 @@ function main() { echo "make check: successful run on $(git rev-parse HEAD)" return 0 else - find . -name '*.trs' | xargs grep -l FAIL | while read file ; do - log=$(dirname $file)/$(basename $file .trs).log - echo FAIL: $log - cat $log - done return 1 fi } diff --git a/src/Makefile-env.am b/src/Makefile-env.am index 93d5a9a0b55d4..e5fda78d5ff78 100644 --- a/src/Makefile-env.am +++ b/src/Makefile-env.am @@ -35,6 +35,9 @@ check_PROGRAMS = # tests scripts will be appended to this check_SCRIPTS = +# display the output of failed check_SCRIPTS after a failed make check +export VERBOSE = true + # python unit tests need to know where the scripts are located export PYTHONPATH=$(top_srcdir)/src/pybind diff --git a/src/crush/CrushTester.cc b/src/crush/CrushTester.cc index 04c5be1de1617..9aada7b1eb938 100644 --- a/src/crush/CrushTester.cc +++ b/src/crush/CrushTester.cc @@ -435,7 +435,7 @@ int CrushTester::test_with_crushtool(const string& crushtool, // something else entirely happened // log it and consider an invalid crush map err << "error running crushmap through crushtool: " << cpp_strerror(r); - return -r; + return -EINVAL; } namespace { diff --git a/src/test/ceph-helpers.sh b/src/test/ceph-helpers.sh index d02b368f3adb0..5e02d9b4a1a1c 100755 --- a/src/test/ceph-helpers.sh +++ b/src/test/ceph-helpers.sh @@ -972,6 +972,57 @@ function test_repair() { ####################################################################### +## +# Run the *command* and expect it to fail (i.e. return a non zero status). +# The output (stderr and stdout) is stored in a temporary file in *dir* +# and is expected to contain the string *expected*. +# +# Return 0 if the command failed and the string was found. Otherwise +# return 1 and cat the full output of the command on stderr for debug. +# +# @param dir temporary directory to store the output +# @param expected string to look for in the output +# @param command ... the command and its arguments +# @return 0 on success, 1 on error +# + +function expect_failure() { + local dir=$1 + shift + local expected="$1" + shift + local success + + if "$@" > $dir/out 2>&1 ; then + success=true + else + success=false + fi + + if $success || ! grep --quiet "$expected" $dir/out ; then + cat $dir/out >&2 + return 1 + else + return 0 + fi +} + +function test_expect_failure() { + local dir=$1 + + setup $dir || return 1 + expect_failure $dir FAIL bash -c 'echo FAIL ; exit 1' || return 1 + # the command did not fail + ! expect_failure $dir FAIL bash -c 'echo FAIL ; exit 0' > $dir/out || return 1 + grep --quiet FAIL $dir/out || return 1 + # the command failed but the output does not contain the expected string + ! expect_failure $dir FAIL bash -c 'echo UNEXPECTED ; exit 1' > $dir/out || return 1 + ! grep --quiet FAIL $dir/out || return 1 + teardown $dir || return 1 +} + +####################################################################### + ## # Call the **run** function (which must be defined by the caller) with # the **dir** argument followed by the caller argument list. The diff --git a/src/test/mon/osd-crush.sh b/src/test/mon/osd-crush.sh index c0857c4e99f47..1c6347f48e4aa 100755 --- a/src/test/mon/osd-crush.sh +++ b/src/test/mon/osd-crush.sh @@ -15,7 +15,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library Public License for more details. # -source test/mon/mon-test-helpers.sh +source test/ceph-helpers.sh function run() { local dir=$1 @@ -30,7 +30,7 @@ function run() { setup $dir || return 1 run_mon $dir a --public-addr $CEPH_MON if ! $TEST_function $dir ; then - cat $dir/a/log + cat $dir/mon.a.log return 1 fi teardown $dir || return 1 @@ -103,8 +103,8 @@ function TEST_crush_rule_create_erasure() { ./ceph osd erasure-code-profile rm default || return 1 ! ./ceph osd erasure-code-profile ls | grep default || return 1 ./ceph osd crush rule create-erasure $ruleset || return 1 - CEPH_ARGS='' ./ceph --admin-daemon $dir/a/ceph-mon.a.asok log flush || return 1 - grep 'profile default set' $dir/a/log || return 1 + CEPH_ARGS='' ./ceph --admin-daemon $dir/ceph-mon.a.asok log flush || return 1 + grep 'profile default set' $dir/mon.a.log || return 1 ./ceph osd erasure-code-profile ls | grep default || return 1 ./ceph osd crush rule rm $ruleset || return 1 ! ./ceph osd crush rule ls | grep $ruleset || return 1 @@ -190,7 +190,6 @@ function TEST_crush_rename_bucket() { function TEST_crush_reject_empty() { local dir=$1 - run_mon $dir a || return 1 # should have at least one OSD run_osd $dir 0 || return 1