tests: add a helper script to identify line-numbers and commands of test-cases

Use the tests/utils/testn.sh after a regression test failed to identify
what command/line number belongs to the test-number.

Jenkins will have something like this in the console output:

    Test Summary Report
    -------------------
    ./tests/bugs/quota/bug-1087198.t
      Failed test:  18

Call the script like:

    $ ./tests/utils/testn.sh ./tests/bugs/quota/bug-1087198.t 18
    56 TEST grep -e "\"Usage crossed....

BUG: 1200174
Change-Id: I661c1178d7f5bc50fd40679232c65734c2bc5477
Original-author: Pranith Kumar K <pkarampu@redhat.com>
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/9842
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
This commit is contained in:
Niels de Vos 2015-03-09 18:39:07 -04:00 committed by Vijay Bellur
parent b832e35493
commit 9d6fab6910

16
tests/utils/testn.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# Use this script to identify the command and line-number of test-cases.
#
if [ -z "${1}" -a -z "${2}" ]
then
echo "Usage: ${0} path/to/test/case.t testnumber"
exit 1
elif [ -z "${2}" ]
then
echo "ERROR: The second parameter to ${0} should be a number."
exit 2
fi
awk '{print FNR " " $0}' ${1} | egrep '^[[:digit:]]+[[:space:]]*(EXPECT|TEST|EXPECT_WITHIN|EXPECT_KEYWORD)' | sed -n ${2}p