Skip to content

Commit

Permalink
Add UNSUPPORTED test result to DejaGnu unit test protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Bachmeyer committed Nov 29, 2022
1 parent 92bf23d commit add1e3e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 11 deletions.
13 changes: 13 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
2022-11-28 Jacob Bachmeyer <[email protected]>

* 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.

2022-11-26 Jacob Bachmeyer <[email protected]>
Expand Down
35 changes: 33 additions & 2 deletions dejagnu.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static int passed;
static int failed;
static int untest;
static int unresolve;
static int unsupport;
static int xfailed;
static int xpassed;

Expand Down Expand Up @@ -137,6 +138,19 @@ unresolved (const char* fmt, ...)
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
note (const char* fmt, ...)
{
Expand All @@ -163,6 +177,8 @@ totals (void)
printf ("\t#untested:\t\t%d\n", untest);
if (unresolve)
printf ("\t#unresolved:\t\t%d\n", unresolve);
if (unsupport)
printf ("\t#unsupported:\t\t%d\n", unsupport);
printf ("\tEND: done\n");
}

Expand All @@ -174,12 +190,16 @@ totals (void)
#include <string>

const char *outstate_list[] = {
"FAILED: ", "PASSED: ", "UNTESTED: ", "UNRESOLVED: ", "XFAILED: ", "XPASSED: "
"FAILED: ", "PASSED: ",
"UNTESTED: ", "UNRESOLVED: ", "UNSUPPORTED: ",
"XFAILED: ", "XPASSED: "
};

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 {
private:
Expand All @@ -194,6 +214,7 @@ class TestState {
xpassed = 0;
xfailed = 0;
unresolve = 0;
unsupport = 0;
}

~TestState (void) { totals(); }
Expand Down Expand Up @@ -254,6 +275,14 @@ class TestState {
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)
{
std::cout << "\t#passed:\t\t" << passed << std::endl;
Expand All @@ -266,6 +295,8 @@ class TestState {
std::cout << "\t#untested:\t\t" << untest << std::endl;
if (unresolve)
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;
}

Expand Down
2 changes: 2 additions & 0 deletions doc/dejagnu.texi
Original file line number Diff line number Diff line change
Expand Up @@ -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{@ @ @ @ @ @ @ @ UNSUPPORTED: }@i{name}

These indicate simple test results.

@print{}@t{@ @ @ @ @ @ @ @ END: }@i{text}
Expand Down
1 change: 1 addition & 0 deletions lib/dejagnu.exp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ proc host_execute {args} {
XFAILED { xfail $output }
UNTESTED { untested $output }
UNRESOLVED { unresolved $output }
UNSUPPORTED { unsupported $output }
END {
expect -re {.+} { exp_continue }
verbose "All done" 2
Expand Down
1 change: 1 addition & 0 deletions testsuite/libdejagnu/unit-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ main(int argc, char ** argv)
else if (!strcmp("xfail", argv[i])) xfail("test");
else if (!strcmp("untested", argv[i])) untested("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 {
fprintf(stderr, "%s: unknown test `%s'\n", argv[0], argv[i]);
Expand Down
20 changes: 11 additions & 9 deletions testsuite/libdejagnu/unit.exp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ proc test_libdejagnu_unit { language tests } {
"expected failures" xfail
untested untested
unresolved unresolved
unsupported unsupported
}

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

test_libdejagnu_unit c {
note pass fail xpass xfail untested unresolved
note pass fail xpass xfail untested unresolved unsupported
}

0 comments on commit add1e3e

Please sign in to comment.