Skip to content

Commit

Permalink
Add support for errors and warnings in the unit test protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Bachmeyer committed Dec 21, 2022
1 parent 61273e9 commit 4d82991
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 3 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
2022-12-20 Jacob Bachmeyer <[email protected]>

* doc/dejagnu.texi (DejaGnu unit test protocol): Add ERROR and
WARNING tokens to DejaGnu unit testing protocol.
* lib/dejagnu.exp (host_execute): Implement same.
* testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.exp,
testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.awk:
Add support for testing ERROR and WARNING tokens.
* testsuite/runtest.main/stats.exp: Add tests for UNRESOLVED
results after warnings and errors in unit test programs.

* testsuite/runtest.main/stats.exp: Add tests for UNRESOLVED
results after warnings and errors.
* testsuite/runtest.main/nested/testsuite/stat.test/stats-sub.exp:
Expand Down
12 changes: 12 additions & 0 deletions doc/dejagnu.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,18 @@ information.

This will cause @i{text} to be printed at verbose levels 2 and higher.

@print{}@t{@ @ @ @ @ @ @ @ ERROR: }@i{text}

This reports a major nonfatal error detected in the unit test program.
The framework will change the next test result to UNRESOLVED as a
result of the error.

@print{}@t{@ @ @ @ @ @ @ @ WARNING: }@i{text}

This reports a minor nonfatal error detected in the unit test program.
If more than @code{warning_threshold} minor errors occur between test
results, the framework will change the next test result to UNRESOLVED.

@print{}@t{@ @ @ @ @ @ @ @ PASSED: }@i{name}

@print{}@t{@ @ @ @ @ @ @ @ FAILED: }@i{name}
Expand Down
2 changes: 2 additions & 0 deletions lib/dejagnu.exp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ proc host_execute {args} {
UNTESTED { untested $output }
UNRESOLVED { unresolved $output }
UNSUPPORTED { unsupported $output }
WARNING { warning $output }
ERROR { perror $output }
END {
expect -re {.+} { exp_continue }
verbose "All done" 2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2020 Free Software Foundation, Inc.
# Copyright (C) 2020, 2022 Free Software Foundation, Inc.
#
# This file is part of DejaGnu.
#
Expand All @@ -22,6 +22,11 @@ BEGIN {
}

END {
for (i = 0; i < ECNT; i++)
print "\tERROR: sample error "i
for (i = 0; i < WCNT; i++)
print "\tWARNING: sample warning "i

if (UNIT_RESULT == "pass")
print "\tPASSED: sample unit test"
else if (UNIT_RESULT == "fail")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2020 Free Software Foundation, Inc.
# Copyright (C) 2020, 2022 Free Software Foundation, Inc.
#
# This file is part of DejaGnu.
#
Expand All @@ -22,7 +22,7 @@ load_lib dejagnu.exp

if { [info exists STATS_TEST] } {
host_execute [which awk] -f [testsuite file -source -test unit-sub.awk] \
UNIT_RESULT=$STATS_TEST /dev/null
ECNT=$ERROR_COUNT WCNT=$WARNING_COUNT UNIT_RESULT=$STATS_TEST /dev/null
}
# Solaris 10 /usr/bin/awk needs /dev/null actually passed on the command
# line, but will run unit-sub.awk without problems if that is done.
20 changes: 20 additions & 0 deletions testsuite/runtest.main/stats.exp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ set tests {
{ unit 0 0 untested "untested testcases\[ \t\]+1\n" }
{ unit 0 0 unresolved "unresolved testcases\[ \t\]+1\n" }
{ unit 0 0 unsupported "unsupported tests\[ \t\]+1\n" }

{ unit 1 0 pass "unresolved testcases\[ \t\]+1\n" }
{ unit 1 0 fail "unresolved testcases\[ \t\]+1\n" }
{ unit 1 0 xpass "unresolved testcases\[ \t\]+1\n" }
{ unit 1 0 xfail "unresolved testcases\[ \t\]+1\n" }
{ unit 1 0 kpass "unresolved testcases\[ \t\]+1\n" }
{ unit 1 0 kfail "unresolved testcases\[ \t\]+1\n" }
{ unit 1 0 untested "unresolved testcases\[ \t\]+1\n" }
{ unit 1 0 unresolved "unresolved testcases\[ \t\]+1\n" }
{ unit 1 0 unsupported "unresolved testcases\[ \t\]+1\n" }

{ unit 0 4 pass "unresolved testcases\[ \t\]+1\n" }
{ unit 0 4 fail "unresolved testcases\[ \t\]+1\n" }
{ unit 0 4 xpass "unresolved testcases\[ \t\]+1\n" }
{ unit 0 4 xfail "unresolved testcases\[ \t\]+1\n" }
{ unit 0 4 kpass "unresolved testcases\[ \t\]+1\n" }
{ unit 0 4 kfail "unresolved testcases\[ \t\]+1\n" }
{ unit 0 4 untested "unresolved testcases\[ \t\]+1\n" }
{ unit 0 4 unresolved "unresolved testcases\[ \t\]+1\n" }
{ unit 0 4 unsupported "unresolved testcases\[ \t\]+1\n" }
}

foreach t $tests {
Expand Down

0 comments on commit 4d82991

Please sign in to comment.