Browse Source

Add UNSUPPORTED test result to DejaGnu unit test protocol

master
Jacob Bachmeyer 3 years ago
parent
commit
add1e3e32e
  1. 13
      ChangeLog
  2. 35
      dejagnu.h
  3. 2
      doc/dejagnu.texi
  4. 1
      lib/dejagnu.exp
  5. 1
      testsuite/libdejagnu/unit-c.c
  6. 20
      testsuite/libdejagnu/unit.exp

13
ChangeLog

@ -1,5 +1,18 @@
2022-11-28 Jacob Bachmeyer <jcb@gnu.org> 2022-11-28 Jacob Bachmeyer <jcb@gnu.org>
* dejagnu.h: Add UNSUPPORTED test result.
(unsupport): New counter variable for UNSUPPORTED results.
(unsupported): New function in C API.
(TestState::unsupported): New function in C++ API.
(outstate_list): Add UNSUPPORTED entry.
(teststate::laststate): Likewise.
(totals): Mention number of unsupported tests.
(TestState::totals): Likewise for C++ API.
* lib/dejagnu.exp (host_execute): Add UNSUPPORTED test result.
* doc/dejagnu.texi (DejaGnu unit test protocol): Document same.
* testsuite/libdejagnu/unit-c.c: Add test for UNSUPPORTED.
* testsuite/libdejagnu/unit.exp: Likewise.
* testsuite/libdejagnu/unit.exp: Add test for NOTE message. * testsuite/libdejagnu/unit.exp: Add test for NOTE message.
2022-11-26 Jacob Bachmeyer <jcb@gnu.org> 2022-11-26 Jacob Bachmeyer <jcb@gnu.org>

35
dejagnu.h

@ -39,6 +39,7 @@ static int passed;
static int failed; static int failed;
static int untest; static int untest;
static int unresolve; static int unresolve;
static int unsupport;
static int xfailed; static int xfailed;
static int xpassed; static int xpassed;
@ -137,6 +138,19 @@ unresolved (const char* fmt, ...)
wait (); wait ();
} }
static inline void
unsupported (const char* fmt, ...)
{
va_list ap;
unsupport++;
va_start (ap, fmt);
vsnprintf (buffer, sizeof (buffer), fmt, ap);
va_end (ap);
printf ("\tUNSUPPORTED: %s\n", buffer);
wait ();
}
static inline void static inline void
note (const char* fmt, ...) note (const char* fmt, ...)
{ {
@ -163,6 +177,8 @@ totals (void)
printf ("\t#untested:\t\t%d\n", untest); printf ("\t#untested:\t\t%d\n", untest);
if (unresolve) if (unresolve)
printf ("\t#unresolved:\t\t%d\n", unresolve); printf ("\t#unresolved:\t\t%d\n", unresolve);
if (unsupport)
printf ("\t#unsupported:\t\t%d\n", unsupport);
printf ("\tEND: done\n"); printf ("\tEND: done\n");
} }
@ -174,12 +190,16 @@ totals (void)
#include <string> #include <string>
const char *outstate_list[] = { const char *outstate_list[] = {
"FAILED: ", "PASSED: ", "UNTESTED: ", "UNRESOLVED: ", "XFAILED: ", "XPASSED: " "FAILED: ", "PASSED: ",
"UNTESTED: ", "UNRESOLVED: ", "UNSUPPORTED: ",
"XFAILED: ", "XPASSED: "
}; };
const char ** outstate = outstate_list; const char ** outstate = outstate_list;
enum teststate { FAILED, PASSED, UNTESTED, UNRESOLVED, XFAILED, XPASSED} laststate; enum teststate { FAILED, PASSED,
UNTESTED, UNRESOLVED, UNSUPPORTED,
XFAILED, XPASSED } laststate;
class TestState { class TestState {
private: private:
@ -194,6 +214,7 @@ class TestState {
xpassed = 0; xpassed = 0;
xfailed = 0; xfailed = 0;
unresolve = 0; unresolve = 0;
unsupport = 0;
} }
~TestState (void) { totals(); } ~TestState (void) { totals(); }
@ -254,6 +275,14 @@ class TestState {
std::cout << "\t" << outstate[UNRESOLVED] << s << std::endl; std::cout << "\t" << outstate[UNRESOLVED] << s << std::endl;
} }
void unsupported (std::string s)
{
unsupport++;
laststate = UNSUPPORTED;
lastmsg = s;
std::cout << "\t" << outstate[UNSUPPORTED] << s << std::endl;
}
void totals (void) void totals (void)
{ {
std::cout << "\t#passed:\t\t" << passed << std::endl; std::cout << "\t#passed:\t\t" << passed << std::endl;
@ -266,6 +295,8 @@ class TestState {
std::cout << "\t#untested:\t\t" << untest << std::endl; std::cout << "\t#untested:\t\t" << untest << std::endl;
if (unresolve) if (unresolve)
std::cout << "\t#unresolved:\t\t" << unresolve << std::endl; std::cout << "\t#unresolved:\t\t" << unresolve << std::endl;
if (unsupport)
std::cout << "\t#unsupported:\t\t" << unsupport << std::endl;
std::cout << "\tEND: done" << std::endl; std::cout << "\tEND: done" << std::endl;
} }

2
doc/dejagnu.texi

@ -2536,6 +2536,8 @@ This will cause @i{text} to be printed at verbose levels 2 and higher.
@print{}@t{@ @ @ @ @ @ @ @ UNRESOLVED: }@i{name} @print{}@t{@ @ @ @ @ @ @ @ UNRESOLVED: }@i{name}
@print{}@t{@ @ @ @ @ @ @ @ UNSUPPORTED: }@i{name}
These indicate simple test results. These indicate simple test results.
@print{}@t{@ @ @ @ @ @ @ @ END: }@i{text} @print{}@t{@ @ @ @ @ @ @ @ END: }@i{text}

1
lib/dejagnu.exp

@ -140,6 +140,7 @@ proc host_execute {args} {
XFAILED { xfail $output } XFAILED { xfail $output }
UNTESTED { untested $output } UNTESTED { untested $output }
UNRESOLVED { unresolved $output } UNRESOLVED { unresolved $output }
UNSUPPORTED { unsupported $output }
END { END {
expect -re {.+} { exp_continue } expect -re {.+} { exp_continue }
verbose "All done" 2 verbose "All done" 2

1
testsuite/libdejagnu/unit-c.c

@ -45,6 +45,7 @@ main(int argc, char ** argv)
else if (!strcmp("xfail", argv[i])) xfail("test"); else if (!strcmp("xfail", argv[i])) xfail("test");
else if (!strcmp("untested", argv[i])) untested("test"); else if (!strcmp("untested", argv[i])) untested("test");
else if (!strcmp("unresolved", argv[i])) unresolved("test"); else if (!strcmp("unresolved", argv[i])) unresolved("test");
else if (!strcmp("unsupported", argv[i])) unsupported("test");
else if (!strcmp("note", argv[i])) note("test"); else if (!strcmp("note", argv[i])) note("test");
else { else {
fprintf(stderr, "%s: unknown test `%s'\n", argv[0], argv[i]); fprintf(stderr, "%s: unknown test `%s'\n", argv[0], argv[i]);

20
testsuite/libdejagnu/unit.exp

@ -31,13 +31,14 @@ proc test_libdejagnu_unit { language tests } {
"expected failures" xfail "expected failures" xfail
untested untested untested untested
unresolved unresolved unresolved unresolved
unsupported unsupported
} }
foreach test $tests { foreach test $tests {
array set expected_totals { array set expected_totals {
pass 0 fail 0 pass 0 fail 0
xpass 0 xfail 0 xpass 0 xfail 0
untested 0 unresolved 0 untested 0 unresolved 0 unsupported 0
} }
set test_idx 0 set test_idx 0
set result pass set result pass
@ -73,13 +74,14 @@ proc test_libdejagnu_unit { language tests } {
-re {(?:\A|\n)\t([][[:upper:]]+):([^\n]+)\n} { -re {(?:\A|\n)\t([][[:upper:]]+):([^\n]+)\n} {
# above pattern copied from lib/dejagnu.exp:host_execute # above pattern copied from lib/dejagnu.exp:host_execute
switch -- [lindex $test $test_idx] { switch -- [lindex $test $test_idx] {
note { set expected NOTE } note { set expected NOTE }
pass { set expected PASSED } pass { set expected PASSED }
fail { set expected FAILED } fail { set expected FAILED }
xpass { set expected XPASSED } xpass { set expected XPASSED }
xfail { set expected XFAILED } xfail { set expected XFAILED }
untested { set expected UNTESTED } untested { set expected UNTESTED }
unresolved { set expected UNRESOLVED } unresolved { set expected UNRESOLVED }
unsupported { set expected UNSUPPORTED }
} }
if { [info exists expected_totals([lindex $test $test_idx])]} { if { [info exists expected_totals([lindex $test $test_idx])]} {
incr expected_totals([lindex $test $test_idx]) incr expected_totals([lindex $test $test_idx])
@ -124,5 +126,5 @@ proc test_libdejagnu_unit { language tests } {
} }
test_libdejagnu_unit c { test_libdejagnu_unit c {
note pass fail xpass xfail untested unresolved note pass fail xpass xfail untested unresolved unsupported
} }

Loading…
Cancel
Save