diff options
author | Rob Savoye <rob@welcomehome.org> | 2001-04-12 05:32:15 +0000 |
---|---|---|
committer | Rob Savoye <rob@welcomehome.org> | 2001-04-12 05:32:15 +0000 |
commit | ad5950c28155a9583b19cff68d3e7546d126c5f2 (patch) | |
tree | a6484f9f953cee37af6ad7daf7a196ffb63bde50 /dejagnu.h | |
parent | 67f23aa1c6cbc0d31adfed48dbbf0b140b4bcc12 (diff) |
* Clean.tcl: Add -r to rm, so it gets rid of CVS directories.
* .clean: Don't install the debian or redhat packaging directories.
* Makefle.am: Install dejagnu.h. Fix dist2 target, so we build our
own tarballs, instead of letting automake do it for us.
* examples/cala/Makefile.am: Use noist_PROGRAMS, so calc doesn't
get installed.
* doc/Makefile.am: Install the man page for runtest.
* configure.in: Make VERSION 1.4.0, not just 1.4, so distributions
get built right.
* lib/dejagnu.exp: Test driver for embedded DejaGnu API.
* dejagnu.h: Embedded DejaGnu API main header file.
* config/default.exp: Default tool init file for simple test
suites.
Diffstat (limited to 'dejagnu.h')
-rw-r--r-- | dejagnu.h | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/dejagnu.h b/dejagnu.h new file mode 100644 index 0000000..214d3ff --- /dev/null +++ b/dejagnu.h @@ -0,0 +1,215 @@ +/* + * Copyright (C) 2000, 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the include generated by configuring */ +#include <config.h> + +#ifndef __DEJAGNU_H__ +#define __DEJAGNU_H__ + +#include <stdio.h> + +static int passed; +static int failed; +static int untest; +static int unresolve; + +inline void +pass (const char *s) { + passed++; + printf ("\tPASSED: %s\n", s); +} + +inline void +fail (const char *s) { + failed++; + printf ("\tFAILED: %s\n", s); +} + +inline void +untested (const char *s) { + untest++; + printf ("\tUNTESTED: %s\n", s); +} + +inline void +unresolved (const char *s) { + unresolve++; + printf ("\tUNRESOLVED: %s\n", s); +} + +inline void +totals (void) { + printf ("\nTotals:\n"); + printf ("\t#passed:\t\t%d\n", passed); + printf ("\t#failed:\t\t%d\n", failed); + if (untest) + printf ("\t#untested:\t\t%d\n", untest); + if (unresolve) + printf ("\t#unresolved:\t\t%d\n", unresolved); +} + +#ifdef __cplusplus + +#include <iostream> +#include <iomanip> +#include <fstream> +#include <string> +#include <strstream> + +char *outstate[] = { + "FAILED: ", + "PASSED: ", + "UNTESTED: ", + "UNRESOLVED: " +}; + +#if 0 +extern ios& __iomanip_testout (ios&, int); +inline smanip<int> testout (int n) { + return smanip<int> (__iomanip_testout, n); +} +ios & __iomanip_testout (ios& i, int x) { + return i; +} + +template<class T> +class OMANIP { + private: + T i; + ostream &(*f)(ostream&, T); + public: + OMANIP(ostream& (*ff)(ostream&, T), T ii) : f(ff), i(ii) { + } + friend ostream operator<<(ostream& us, OMANIP& m) { + return m.f(os,m.i); + } +}; + +ostream& +freakout(ostream& os, int x) { + return os << "FREAKOUT" ; +// return x << "TESTOUT " << x ; +} + +OMANIP<int> testout(int i) { + return OMANIP<int>(&freakout,i); +} +#endif + +char *testout (int x) { + const int len = 128; + static char buf[len]; + static ostrstream oss(buf, len, ios::out); + oss.seekp(ios::beg); + oss << outstate[x] << ends; + return buf; +} + +enum teststate {FAILED, PASSED,UNTESTED,UNRESOLVED} laststate; + +class TestState { + private: + teststate laststate; + string lastmsg; + public: + TestState(void) { + passed = 0; + failed = 0; + untest = 0; + unresolve = 0; + } + ~TestState(void) { + totals(); + }; + + void testrun (bool b, string s) { + if (b) + pass (s); + else + fail (s); + } + + void pass (string s) { + passed++; + laststate = PASSED; + lastmsg = s; + cout << "\t" << testout(PASSED) << s << endl; + } + void pass (const char *c) { + string s = c; + pass (s); + } + + void fail (string s) { + failed++; + laststate = FAILED; + lastmsg = s; + cout << "\t" << testout(FAILED) << s << endl; + } + void fail (const char *c) { + string s = c; + fail (s); + } + + void untested (string s) { + untest++; + laststate = UNTESTED; + lastmsg = s; + cout << "\t" << testout(UNTESTED) << s << endl; + } + void untested (const char *c) { + string s = c; + untested (s); + } + + void unresolved (string s) { + unresolve++; + laststate = UNRESOLVED; + lastmsg = s; + cout << "\t" << testout(UNRESOLVED) << s << endl; + } + void unresolved (const char *c) { + string s = c; + unresolved (s); + } + void totals (void) { + cout << "\t#passed:\t\t" << passed << endl; + cout << "\t#failed:\t\t" << failed << endl; + if (untest) + cout << "\t#untested:\t\t" << untest << endl; + if (unresolve) + cout << "\t#unresolved:\t\t" << unresolve << endl; + } + + friend ostream & operator << (ostream &os, TestState& t) { + return os << "\t" << outstate[t.laststate] << t.lastmsg ; + } + + int GetState(void) { + return laststate; + } + string GetMsg(void) { + return lastmsg; + } +}; + +#endif // __cplusplus +#endif // _DEJAGNU_H_ + + |