Skip to content

Commit

Permalink
Add tagging capability to the test suite.
Browse files Browse the repository at this point in the history
Orabug: 26992620

Signed-off-by: Eugene Loh <eugene.loh@oracle>
  • Loading branch information
Eugene Loh authored and nickalcock committed Apr 5, 2018
1 parent 7a6b149 commit 7b87fa8
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 0 deletions.
61 changes: 61 additions & 0 deletions runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ Options:
of modules, then immediately exit.
--quiet: Only show unexpected output (FAILs and XPASSes).
--verbose: The opposite of --quiet (and the default).
--[no-]tag=TAG: Run only tests with[out] TAG.
Multiple such options are ANDed together.
--help: This message.
If one or more TESTs is provided, they must be the name of .d files existing
Expand Down Expand Up @@ -359,6 +361,7 @@ fi
ONLY_TESTS=
TESTS=
QUIET=
USER_TAGS=

if [[ -n $DTRACE_TEST_TIMEOUT ]]; then
TIMEOUT="$DTRACE_TEST_TIMEOUT"
Expand Down Expand Up @@ -392,6 +395,8 @@ while [[ $# -gt 0 ]]; do
--testsuites=*) TESTSUITES="$(printf -- $1 | cut -d= -f2- | tr "," " ")";;
--quiet) QUIET=t;;
--verbose) QUIET=;;
--tag=*) USER_TAGS="$USER_TAGS $(printf -- $1 | cut -d= -f2-)";;
--no-tag=*) USER_TAGS="$USER_TAGS !$(printf -- $1 | cut -d= -f2-)";;
--help|--*) usage;;
*) ONLY_TESTS=t
OVERWRITE_RESULTS=t
Expand Down Expand Up @@ -735,6 +740,23 @@ touch $LOGFILE
touch $SUMFILE
chattr +S $LOGFILE $SUMFILE 2>/dev/null

# Form run and skip files from multiple sources of user-specified tags:
# - default-tag file (test/tags.default)
# - environment variable (TEST_TAGS)
# - command-line options (--[no-]tag=)

USER_TAGS="$(cat test/tags.default 2>/dev/null) $TEST_TAGS $USER_TAGS"
rm -f $tmpdir/run.tags > /dev/null 2>&1
rm -f $tmpdir/skip.tags > /dev/null 2>&1
printf "%s\n" $USER_TAGS | grep -v '^!' | sort -u > $tmpdir/run.tags
printf "%s\n" $USER_TAGS | grep '^!' | sed 's/^!//' | sort -u > $tmpdir/skip.tags
# Free ourselves of the hassles of empty (but existing) files.
for name in $tmpdir/run.tags $tmpdir/skip.tags; do
if [[ `cat $name | wc -w` -eq 0 ]]; then
rm $name
fi
done

# Loop over each test in turn, or the specified subset if test names were passed
# on the command line.

Expand Down Expand Up @@ -820,6 +842,8 @@ for dt in $dtrace; do
#
# @@skip: If true, the test is skipped.
#
# @@tags: Tag test case with specified tags, separated by spaces.
#
# @@xfail: A single line containing a reason for this test's expected
# failure. (If the test passes unexpectedly, this message is
# not printed.) See '.x'.
Expand Down Expand Up @@ -944,6 +968,43 @@ for dt in $dtrace; do
sum "$_test: SKIP: $(extract_options skip $_test)\n"
continue
fi

# Check if the user specified any tags.

if [[ -n "$USER_TAGS" ]]; then

# Extract tags from test.
rm -f $tmpdir/test.tags >/dev/null 2>&1
test_tags="$(extract_options tags $_test)"
if [[ -n "$test_tags" ]]; then
printf "%s\n" $test_tags | sort -u > $tmpdir/test.tags
elif [[ -e $tmpdir/run.tags ]]; then
# User requested tags, but test has none. So skip test.
tagdiff=$(cat $tmpdir/run.tags | xargs)
sum "$_test: SKIP: test lacks requested tags: $tagdiff\n"
continue
fi

# If user specified run tags, check for them.
if [[ -e $tmpdir/run.tags ]]; then
if [[ -n "$(comm -23 $tmpdir/run.tags $tmpdir/test.tags)" ]]; then
# Some user-specified run tags are not in test. Skip test.
tagdiff=$(comm -23 $tmpdir/run.tags $tmpdir/test.tags | xargs)
sum "$_test: SKIP: test lacks requested tags: $tagdiff\n"
continue
fi
fi

# If user specified skip tags, check for them.
if [[ -e $tmpdir/skip.tags && -n $test_tags ]]; then
if [[ -n "$(comm -12 $tmpdir/skip.tags $tmpdir/test.tags)" ]]; then
# Some user-specified skip tags are in test. Skip test.
tagdiff=$(comm -12 $tmpdir/skip.tags $tmpdir/test.tags | xargs)
sum "$_test: SKIP: test has excluded tags: $tagdiff\n"
continue
fi
fi
fi

# Per-test timeout.

Expand Down
1 change: 1 addition & 0 deletions test/internals/libproc/tst.lmid-consistency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# @@timeout: 50
# @@skip: fails intermittently without libproc-mt
# @@tags: unstable

unset LD_AUDIT
export MANY_LMIDS=t
Expand Down
1 change: 1 addition & 0 deletions test/unittest/builtinvar/tst.errno2.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

/* @@skip: known erratic */
/* @@tags: unstable */

#pragma D option quiet
#pragma D option destructive
Expand Down
1 change: 1 addition & 0 deletions test/unittest/ip/tst.ipv6remoteicmp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# which is the reason we are testing.
# 2. An unrelated ICMPv6 between these hosts was traced by accident.
#
# @@tags: unstable

# @@skip: spurious failures due to results postprocessor malfunctions

Expand Down
1 change: 1 addition & 0 deletions test/unittest/misc/tst.dynopt.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
/* @@tags: unstable */

/* @@skip: known erratic */

Expand Down
2 changes: 2 additions & 0 deletions test/unittest/proc/tst.system-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# under /var, which checks the trickiest code path in Psystem_daemon().)
#
# @@skip: for release, too many garbage stack frames for reliable results
# @@tags: unstable

orig_DEBUG="$DTRACE_DEBUG"

script()
Expand Down
1 change: 1 addition & 0 deletions test/unittest/ustack/tst.bigstack.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

/* @@trigger: ustack-tst-bigstack */
/* @@tags: unstable */

/* @@skip: fails intermittently, not testing anything useful? */

Expand Down
2 changes: 2 additions & 0 deletions test/unittest/ustack/tst.mtspin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# http://oss.oracle.com/licenses/upl.
# @@skip: unreliable, see bug 22269741

# @@tags: unstable

if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
Expand Down
2 changes: 2 additions & 0 deletions test/unittest/ustack/tst.spin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# http://oss.oracle.com/licenses/upl.
# @@skip: unreliable, see bug 22269741

# @@tags: unstable

if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
Expand Down

0 comments on commit 7b87fa8

Please sign in to comment.