From 4d829912f7104d6f96886c1e46c173e9e7478946 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Tue, 20 Dec 2022 21:55:44 -0600 Subject: [PATCH] Add support for errors and warnings in the unit test protocol --- ChangeLog | 9 +++++++++ doc/dejagnu.texi | 12 ++++++++++++ lib/dejagnu.exp | 2 ++ .../nested/testsuite/stat.test/unit-sub.awk | 7 ++++++- .../nested/testsuite/stat.test/unit-sub.exp | 4 ++-- testsuite/runtest.main/stats.exp | 20 ++++++++++++++++++++ 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b116af9..9d94bda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2022-12-20 Jacob Bachmeyer + * 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: diff --git a/doc/dejagnu.texi b/doc/dejagnu.texi index 1e1d44f..5b94c0e 100644 --- a/doc/dejagnu.texi +++ b/doc/dejagnu.texi @@ -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} diff --git a/lib/dejagnu.exp b/lib/dejagnu.exp index 24b3c5f..be114f9 100644 --- a/lib/dejagnu.exp +++ b/lib/dejagnu.exp @@ -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 diff --git a/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.awk b/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.awk index 3b9a841..869244c 100644 --- a/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.awk +++ b/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. # @@ -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") diff --git a/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.exp b/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.exp index f3aece8..03ef4d5 100644 --- a/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.exp +++ b/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. # @@ -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. diff --git a/testsuite/runtest.main/stats.exp b/testsuite/runtest.main/stats.exp index b2a578b..3f131d0 100644 --- a/testsuite/runtest.main/stats.exp +++ b/testsuite/runtest.main/stats.exp @@ -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 { -- 2.11.4.GIT