Browse Source

Add support for errors and warnings in the unit test protocol

master
Jacob Bachmeyer 3 years ago
parent
commit
4d829912f7
  1. 9
      ChangeLog
  2. 12
      doc/dejagnu.texi
  3. 2
      lib/dejagnu.exp
  4. 7
      testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.awk
  5. 4
      testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.exp
  6. 20
      testsuite/runtest.main/stats.exp

9
ChangeLog

@ -1,5 +1,14 @@
2022-12-20 Jacob Bachmeyer <jcb@gnu.org> 2022-12-20 Jacob Bachmeyer <jcb@gnu.org>
* 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 * testsuite/runtest.main/stats.exp: Add tests for UNRESOLVED
results after warnings and errors. results after warnings and errors.
* testsuite/runtest.main/nested/testsuite/stat.test/stats-sub.exp: * testsuite/runtest.main/nested/testsuite/stat.test/stats-sub.exp:

12
doc/dejagnu.texi

@ -2524,6 +2524,18 @@ information.
This will cause @i{text} to be printed at verbose levels 2 and higher. 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{@ @ @ @ @ @ @ @ PASSED: }@i{name}
@print{}@t{@ @ @ @ @ @ @ @ FAILED: }@i{name} @print{}@t{@ @ @ @ @ @ @ @ FAILED: }@i{name}

2
lib/dejagnu.exp

@ -141,6 +141,8 @@ proc host_execute {args} {
UNTESTED { untested $output } UNTESTED { untested $output }
UNRESOLVED { unresolved $output } UNRESOLVED { unresolved $output }
UNSUPPORTED { unsupported $output } UNSUPPORTED { unsupported $output }
WARNING { warning $output }
ERROR { perror $output }
END { END {
expect -re {.+} { exp_continue } expect -re {.+} { exp_continue }
verbose "All done" 2 verbose "All done" 2

7
testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.awk

@ -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. # This file is part of DejaGnu.
# #
@ -22,6 +22,11 @@ BEGIN {
} }
END { 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") if (UNIT_RESULT == "pass")
print "\tPASSED: sample unit test" print "\tPASSED: sample unit test"
else if (UNIT_RESULT == "fail") else if (UNIT_RESULT == "fail")

4
testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.exp

@ -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. # This file is part of DejaGnu.
# #
@ -22,7 +22,7 @@ load_lib dejagnu.exp
if { [info exists STATS_TEST] } { if { [info exists STATS_TEST] } {
host_execute [which awk] -f [testsuite file -source -test unit-sub.awk] \ 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 # 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. # line, but will run unit-sub.awk without problems if that is done.

20
testsuite/runtest.main/stats.exp

@ -62,6 +62,26 @@ set tests {
{ unit 0 0 untested "untested testcases\[ \t\]+1\n" } { unit 0 0 untested "untested testcases\[ \t\]+1\n" }
{ unit 0 0 unresolved "unresolved testcases\[ \t\]+1\n" } { unit 0 0 unresolved "unresolved testcases\[ \t\]+1\n" }
{ unit 0 0 unsupported "unsupported tests\[ \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 { foreach t $tests {

Loading…
Cancel
Save