From 830f253234c94636c197617466c4b2910a39e574 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Thu, 24 Sep 2009 23:27:37 -0700 Subject: tet: Print status of tests Report the status of the test cases and the composite exit code of the test programs to stdout. The tet_getstatusname function is added to convert exit codes to a string. --- src/tet3/dtet2lib/rescode.c | 33 +++++++++++++++++++++++++++++++++ src/tet3/tcm/dtcm.c | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/src/tet3/dtet2lib/rescode.c b/src/tet3/dtet2lib/rescode.c index 0715639b..7930c960 100644 --- a/src/tet3/dtet2lib/rescode.c +++ b/src/tet3/dtet2lib/rescode.c @@ -99,6 +99,23 @@ struct restab *tet_restab; int tet_nrestab; static int lrestab; +/* structure of an entry in the status code table */ +struct statustab { + char *st_name; /* status name */ + int st_code; /* status code */ +}; + +/* default status code table */ +static struct statustab tet_statustab[] = { + "PASS", TET_EXIT_SUCCESS, + "FAIL", TET_EXIT_FAILURE, + "SKIP", TET_EXIT_SKIP, +}; + +#define Ntet_statustab (sizeof(tet_statustab) / sizeof(tet_statustab[0])) + +static char invalid_status[] = "INVALID STATUS"; + /* static function declarations */ static void badresline PROTOLIST((char *, int, char *)); static struct restab *getrtbycode PROTOLIST((int)); @@ -501,6 +518,22 @@ register int lastresult, thisresult; } } +/* +** tet_getstatusname() - look up status code in the status table; +** return name if found, otherwise a default string +*/ + +char *tet_getstatusname(status) +int status; +{ + register struct statustab *stp; + + for (stp = tet_statustab; stp < tet_statustab + Ntet_statustab; stp++) + if (stp->st_code == status) + return stp->st_name; + return invalid_status; +} + /* ** tet_resulttostatus() - convert result code to exit status ** diff --git a/src/tet3/tcm/dtcm.c b/src/tet3/tcm/dtcm.c index 490396ca..d78376b0 100644 --- a/src/tet3/tcm/dtcm.c +++ b/src/tet3/tcm/dtcm.c @@ -373,10 +373,14 @@ char **argv; if (rc < 0) tet_docleanup(EXIT_FAILURE); ret = call_tps(icnum, &tpcount); + printf("%s (%d/%d): %s\n", tet_pname, + icnum, icp->ic_end, + tet_get_code(ret, NULL)); status = tet_addstatus(status, tet_resulttostatus(ret)); tet_icend(icnum, tpcount); } + printf("%s: %s\n", tet_pname, tet_getstatusname(status)); /* unexpected signals are fatal during cleanup */ setsigs(sigabandon); -- cgit v1.2.3