30#define _RWSTD_TEST_SRC
58# include <sys/resource.h>
60# ifndef RLIM_SAVED_CUR
61# define RLIM_SAVED_CUR RLIM_INFINITY
64# ifndef RLIM_SAVED_MAX
65# define RLIM_SAVED_MAX RLIM_INFINITY
77# define _RWSTD_NO_ISATTY
81#define _RWSTD_TEST_SRC
86#define RW_TEST_STRSTR(x) #x
87#define RW_TEST_STR(x) RW_TEST_STRSTR(x)
89#ifndef RW_TEST_COMPILER
90# if defined (__DECCXX__)
91# define RW_TEST_COMPILER "Compaq C++, __DECCXX__ = " \
92 RW_TEST_STR (__DECCXX__)
93# elif defined (__INTEL_COMPILER)
94# if defined (__EDG_VERSION__)
95# define RW_TEST_ICC_EDG_VER \
96 ", __EDG_VERSION__ = " RW_TEST_STR (__EDG_VERSION__)
98# define RW_TEST_ICC_EDG_VER ""
100# if defined (_MSC_VER)
101# define RW_TEST_COMPILER "Intel C++, __INTEL_COMPILER = " \
102 RW_TEST_STR (__INTEL_COMPILER) ", _MSC_VER = " \
103 RW_TEST_STR (_MSC_VER) \
105# elif defined (__INTEL_COMPILER_BUILD_DATE)
106# define RW_TEST_COMPILER "Intel C++, __INTEL_COMPILER = " \
107 RW_TEST_STR (__INTEL_COMPILER) \
108 ", __INTEL_COMPILER_BUILD_DATE = " \
109 RW_TEST_STR (__INTEL_COMPILER_BUILD_DATE) \
112# define RW_TEST_COMPILER "Intel C++, __INTEL_COMPILER = " \
113 RW_TEST_STR (__INTEL_COMPILER) \
116# elif defined (__GNUC__)
117# if defined (__VERSION__)
118# define RW_TEST_GCC_VER ", __VERSION__ = \"" __VERSION__ "\""
120# define RW_TEST_GCC_VER ""
122# if defined (__GNUC_PATCHLEVEL__)
123# define RW_TEST_COMPILER "gcc " \
124 RW_TEST_STR (__GNUC__) "." \
125 RW_TEST_STR (__GNUC_MINOR__) "." \
126 RW_TEST_STR (__GNUC_PATCHLEVEL__) \
129# define RW_TEST_COMPILER "gcc " \
130 RW_TEST_STR (__GNUC__) "." RW_TEST_STR (__GNUC_MINOR__)
133# elif defined (_COMPILER_VERSION) && defined (__sgi)
134# define RW_TEST_COMPILER "SGI MIPSpro, _COMPILER_VERSION = " \
135 RW_TEST_STR (_COMPILER_VERSION)
136# elif defined (__INTEL_COMPILER)
137# if defined (_MSC_VER)
138# define RW_TEST_COMPILER "Intel C++, __INTEL_COMPILER = " \
139 RW_TEST_STR (__INTEL_COMPILER) ", _MSC_VER = " \
140 RW_TEST_STR (_MSC_VER)
142# define RW_TEST_COMPILER "Intel C++, __INTEL_COMPILER = " \
143 RW_TEST_STR (__INTEL_COMPILER)
145# elif defined (__HP_aCC)
146# if defined (__EDG_VERSION__)
147# define RW_TEST_ACC_EDG_VER \
148 ", __EDG_VERSION__ = " RW_TEST_STR (__EDG_VERSION__)
150# define RW_TEST_ACC_EDG_VER ""
152# define RW_TEST_COMPILER "HP aCC, __HP_aCC = " \
153 RW_TEST_STR (__HP_aCC) \
155# elif defined (__IBMCPP__)
156# define RW_TEST_COMPILER "IBM VisualAge C++, __IBMCPP__ = " \
157 RW_TEST_STR (__IBMCPP__)
158# elif defined (_MSC_VER)
159# define RW_TEST_COMPILER "MSVC, _MSC_VER = " \
160 RW_TEST_STR (_MSC_VER)
161# elif defined (__SUNPRO_CC)
162# define RW_TEST_COMPILER "SunPro, __SUNPRO_CC = " \
163 RW_TEST_STR (__SUNPRO_CC)
164# elif defined (__EDG__)
168# define RW_TEST_COMPILER "EDG eccp, __EDG_VERSION__ = " \
169 RW_TEST_STR (__EDG_VERSION__)
171# define RW_TEST_COMPILER "unknown"
175#ifndef RW_TEST_LIBSTD
177# define RW_TEST_LIBSTD "Rogue Wave C++ Standard Library, " \
178 "_RWSTD_VER = " RW_TEST_STR (_RWSTD_VER)
179# elif defined (__GLIBCXX__)
180# define RW_TEST_LIBSTD "GNU C++ Standard Library, " \
182 RW_TEST_STR (__GLIBCXX__)
183# elif defined (_STLPORT_VERSION)
186# define RW_TEST_LIBSTD "STLport, " \
187 "_STLPORT_VERSION = " \
188 RW_TEST_STR (_STLPORT_VERSION)
189# elif defined (__SGI_STL)
190# define RW_TEST_LIBSTD "SGI STL, " \
192 RW_TEST_STR (__SGI_STL)
193# elif defined (_YVALS)
196# define RW_TEST_LIBSTD "Dinkum C++ Standard Library"
200#ifndef RW_TEST_HARDWARE
201# if defined (__alpha__) || defined (__alpha)
202# define RW_TEST_ARCH "alpha"
203# elif defined (__x86_64__) || defined (__x86_64)
204# if defined (__LP64__) || defined (_LP64)
205# define RW_TEST_ARCH "x86_64/LP64"
207# define RW_TEST_ARCH "x86_64/ILP32"
209# elif defined (__amd64__) || defined (__amd64)
210# if defined (__LP64__) || defined (_LP64)
211# define RW_TEST_ARCH "amd64/LP64"
213# define RW_TEST_ARCH "amd64/ILP32"
215# elif defined (_PA_RISC2_0)
216# define RW_TEST_ARCH "pa-risc 2.0"
217# elif defined (_PA_RISC1_0)
218# define RW_TEST_ARCH "pa-risc 1.0"
219# elif defined (__hppa)
220# define RW_TEST_ARCH "pa-risc"
221# elif defined (__pentiumpro__) || defined (__pentiumpro)
222# define RW_TEST_ARCH "pentiumpro"
223# elif defined (__pentium__) || defined (__pentium)
224# define RW_TEST_ARCH "pentium"
225# elif defined (__i486__) || defined (__i486)
226# define RW_TEST_ARCH "i486"
227# elif defined (__i386__) || defined (__i386)
228# define RW_TEST_ARCH "i386"
229# elif defined (__i586__) || defined (__i586)
230# define RW_TEST_ARCH "i586"
231# elif defined (__ia64)
232# define RW_TEST_ARCH "ia64"
233# elif defined (__mips)
234# define RW_TEST_ARCH "mips"
235# elif defined (__sparcv9)
236# define RW_TEST_ARCH "sparc-v9"
237# elif defined (__sparcv8)
238# define RW_TEST_ARCH "sparc-v8"
239# elif defined (__sparc)
240# define RW_TEST_ARCH "sparc"
241# elif defined (_POWER)
242# if defined (_ARCH_PWR5)
243# define RW_TEST_ARCH "power-5"
244# elif defined (_ARCH_PWR4)
245# define RW_TEST_ARCH "power-4"
246# elif defined (_ARCH_PWR3)
247# define RW_TEST_ARCH "power-3"
248# elif defined (_ARCH_604)
249# define RW_TEST_ARCH "powerpc-604"
250# elif defined (_ARCH_603)
251# define RW_TEST_ARCH "powerpc-603"
252# elif defined (_ARCH_602)
253# define RW_TEST_ARCH "powerpc-602"
254# elif defined (_ARCH_601)
255# define RW_TEST_ARCH "powerpc-601"
256# elif defined (_ARCH_403)
257# define RW_TEST_ARCH "powerpc-403"
258# elif defined (_ARCH_PPC64)
259# define RW_TEST_ARCH "powerpc/LP64"
261# define RW_TEST_ARCH "powerpc"
263# elif defined (_WIN64)
264# define RW_TEST_ARCH "ia64"
265# elif defined (_WIN32)
266# define RW_TEST_ARCH "i86"
268# define RW_TEST_ARCH "unknown"
273# define RW_TEST_OS "aix-5.4 (or better)"
274# elif defined (_AIX53)
275# define RW_TEST_OS "aix-5.3"
276# elif defined (_AIX52)
277# define RW_TEST_OS "aix-5.2"
278# elif defined (_AIX51)
279# define RW_TEST_OS "aix-5.1"
280# elif defined (_AIX50)
281# define RW_TEST_OS "aix-5.0"
282# elif defined (_AIX43)
283# define RW_TEST_OS "aix-4.3"
284# elif defined (_AIX41)
285# define RW_TEST_OS "aix-4.1"
286# elif defined (_AIX32)
287# define RW_TEST_OS "aix-3.2"
289# define RW_TEST_OS "aix"
290# elif defined (__hpux)
291# define RW_TEST_OS "hp-ux"
292# elif defined (__osf__)
293# define RW_TEST_OS "tru64-unix"
294# elif defined (__sgi) && defined (__mips)
295# define RW_TEST_OS "irix"
296# elif defined (__linux__) || defined (__linux)
297# if defined (__ELF__)
298# define LINUX_TYPE "linux-elf"
300# define LINUX_TYPE "linux"
303# define RW_TEST_OS LINUX_TYPE " (" \
304 _RWSTD_LINUX_RELEASE ") with glibc " \
305 RW_TEST_STR (__GLIBC__) "." \
306 RW_TEST_STR (__GLIBC_MINOR__)
308# elif defined (__SunOS_5_11)
309# define RW_TEST_OS "sunos-5.11"
310# elif defined (__SunOS_5_10)
311# define RW_TEST_OS "sunos-5.10"
312# elif defined (__SunOS_5_9)
313# define RW_TEST_OS "sunos-5.9"
314# elif defined (__SunOS_5_8)
315# define RW_TEST_OS "sunos-5.8"
316# elif defined (__SunOS_5_7)
317# define RW_TEST_OS "sunos-5.7"
318# elif defined (__SunOS_5_6)
319# define RW_TEST_OS "sunos-5.6"
320# elif defined (__sun__)
321# define RW_TEST_OS "sunos"
322# elif defined (_WIN64)
323# define RW_TEST_OS "win64"
324# elif defined (_WIN32)
325# define RW_TEST_OS "win32"
327# define RW_TEST_OS "unknown"
330# define RW_TEST_HARDWARE RW_TEST_ARCH " running " RW_TEST_OS
332# define RW_TEST_HARDWARE "unknown"
347static rw_file *_rw_ftestout;
349static jmp_buf test_env;
352static int _rw_driver_init = 0;
355static int _rw_driver_done = 0;
369static char diag_pattern [80];
373static int _rw_opt_csv = 0;
375static char clause_id [80];
379#define CHECK_INIT(init, func) _rw_check_init (init, __LINE__, func)
382_rw_check_init (
int expect_init,
int line,
const char *
func)
386 if (!_rw_driver_init) {
388 "%s:%d: %s: error: test driver not initialized yet\n",
394 else if (_rw_driver_init) {
397 "%s:%d: %s: error: test driver already initialized\n",
403 if (_rw_driver_done) {
406 "%s:%d: %s: warning: test finished, cannot call\n",
414_rw_opt_brief (
int argc,
char *argv[])
416 static int opt_brief;
423 if (1 == argc && argv && 0 == argv [0]) {
426 static const char helpstr[] = {
427 "Enables brief mode.\n"
444_rw_opt_quiet (
int argc,
char *argv[])
446 static int opt_quiet;
453 if (1 == argc && argv && 0 == argv [0]) {
456 static const char helpstr[] = {
457 "Enables quiet mode.\n"
458 "In quiet mode only diagnostics with severity 7 and above are "
477_rw_opt_verbose (
int argc,
char *argv[])
479 static int opt_verbose;
486 if (1 == argc && argv && 0 == argv [0]) {
489 static const char helpstr[] = {
490 "Enables verbose mode.\n"
507_rw_setopt_csv (
int argc,
char *argv[])
509 if (1 == argc && argv && 0 == argv [0]) {
510 static const char helpstr[] = {
511 "Enables CSV (comma separated values) mode.\n"
526_rw_opt_compat (
int argc,
char *argv[])
528 static int opt_compat;
535 if (1 == argc && argv && 0 == argv [0]) {
538 static const char helpstr[] = {
539 "Enables RWTest-format compatibility mode.\n"
556_rw_opt_no_stdout (
int argc,
char *argv[])
558 static int opt_no_stdout;
562 return opt_no_stdout;
565 if (1 == argc && argv && 0 == argv [0]) {
568 static const char helpstr[] = {
569 "Prevents the program from using stdandard output for diagnostic\n"
570 "messages. Instead, the driver will create a log file with a name\n"
571 "obtained from the from the basename of the program source file,\n"
572 "usually obtained by passing the value of the __FILE__ macro to\n"
573 "the driver, with the .out extension. If successful, the driver\n"
574 "will write all diagnostic messages issued by the program to this\n"
575 "file. Otherwise, the driver exits with an error.\n"
592_rw_setopt_output_file (
int argc,
char *argv[])
594 if (1 == argc && argv && 0 == argv [0]) {
595 static const char helpstr[] = {
596 "Specifies the name of the output file to be used by the program\n"
597 "for diagnostic messages. Unless this option is specified, the\n"
598 "program will issue all diagnostic messages to the standard output."
599 "\nDriver diagnostics are always directed to stderr.\n"
607 const char *file_name = 0;
609 if (
'-' == argv [0][0] && (
'O' == argv [0][1] ||
'o' == argv [0][1])
611 file_name = argv [0] + 2;
613 else if (1 < argc &&
'-' != argv [1][0]) {
614 file_name = argv [1];
618 if (file_name[0] !=
'-' || file_name[1] !=
'\0') {
619 FILE*
const f = fopen (file_name,
"w");
622 if (_rw_ftestout && _rw_ftestout !=
rw_stdout)
623 fclose ((FILE*)(
void*)_rw_ftestout);
625 _rw_ftestout = (rw_file*)(
void*)
f;
629 _rw_ftestout = (rw_file*)(
void*)
stdout;
633 return !(_rw_ftestout != 0);
646#ifndef _RWSTD_NO_ISATTY
650 static const int tty = _rw_ftestout ?
651 isatty (
fileno ((FILE*)(
void*)_rw_ftestout)) : 0;
656 static const int tty = 0;
666_rw_setopt_ulimit (
int argc,
char **argv)
668 if (1 == argc && argv && 0 == argv [0]) {
669 static const char helpstr[] = {
670 "Sets limits on one or more system resources.\n"
671 "The syntax of <arg> is as follows:\n"
672 "<arg> ::= <limit-list>\n"
673 "<limit-list> ::= <limit> [, <limit-list> ]\n"
674 "<limit> ::= <resource> : <number>\n"
675 "<resource> ::= core | cpu | data | fsize | nofile | stack | as\n"
676 " ::= CORE | CPU | DATA | FSIZE | NOFILE | STACK | AS\n"
677 " ::= Core | Cpu | Data | Fsize | Nofile | Stack | As\n"
678 "Names in all lowercase letters set the soft limit, those in all\n"
679 "uppercase set the hard limit, names in mixed case will cause \n"
680 "both limits to attempt to be set.\n"
690#if defined (RLIMIT_CORE) || defined (RLIMIT_CPU) || defined (RLIMIT_DATA)
692 static const struct {
700 {
"core",
"CORE",
"Core", RLIMIT_CORE },
703 {
"cpu",
"CPU",
"Cpu", RLIMIT_CPU },
706 {
"data",
"DATA",
"Data", RLIMIT_DATA },
709 {
"fsize",
"FSIZE",
"Fsize", RLIMIT_FSIZE },
712 {
"nofile",
"NOFILE",
"Nofile", RLIMIT_NOFILE },
715 {
"stack",
"STACK",
"Stack", RLIMIT_STACK },
718 {
"as",
"AS",
"As", RLIMIT_AS },
723 const char*
arg = strchr (argv [0],
'=');
729 const size_t arglen = strlen (
arg);
731 for (
size_t i = 0; limits [
i].name; ++
i) {
732 const size_t limit_len = strlen (limits [
i].
name);
734 if ( limit_len < arglen
735 && ( 0 == memcmp (limits [
i].
name,
arg, limit_len)
736 || 0 == memcmp (limits [
i].caps,
arg, limit_len)
737 || 0 == memcmp (limits [
i].mixd,
arg, limit_len))
738 &&
':' ==
arg [limit_len]) {
742 const bool hard = isupper (
arg [0]);
743 const bool soft = islower (
arg [1]);
745 arg += limit_len + 1;
748 const long lim = strtol (
arg, &end, 10);
752 if (
'\0' != *
arg &&
',' != *
arg)
756 memset (&rlim, 0,
sizeof rlim);
761 const int result = setrlimit (limits [
i].resource, &rlim);
765 "setrlimit(RLIMIT_%s, { .rlim_cur=%ld, "
766 ".rlim_max=%ld }) error: %m\n",
767 limits [
i].caps, rlim.rlim_cur, rlim.rlim_max);
774 if (
'\0' != *
arg &&
',' != *
arg) {
776 "%s: parse error at \"%s\"\n", argv [0],
arg);
784 "option: %s\n", argv [0]);
796_rw_setopt_compat_error (
int argc,
char **argv,
char opt)
798 if (1 == argc && argv && 0 == argv [0]) {
799 static const char helpstr[] = {
800 "Compatibility-mode option\n"
809 "in compatibility mode\n", opt);
814_rw_setopt_compat_warn (
int argc,
char **argv,
char opt)
816 if (1 == argc && argv && 0 == argv [0]) {
817 return _rw_setopt_compat_error (argc, argv, opt);
821 "warning: -%c: ignoring unimplemented compatibility "
822 "mode option\n", opt);
828_rw_setopt_compat_append (
int argc,
char **argv)
830 if (_rw_opt_compat (0, 0))
831 return _rw_setopt_compat_warn (argc, argv,
'A');
833 return _rw_setopt_compat_error (argc, argv,
'A');
838_rw_setopt_compat_compiler (
int argc,
char **argv)
840 if (_rw_opt_compat (0, 0))
841 return _rw_setopt_compat_warn (argc, argv,
'C');
843 return _rw_setopt_compat_error (argc, argv,
'C');
848_rw_setopt_compat_dir (
int argc,
char **argv)
850 if (_rw_opt_compat (0, 0))
851 return _rw_setopt_compat_warn (argc, argv,
'D');
853 return _rw_setopt_compat_error (argc, argv,
'D');
858_rw_setopt_compat_debug_file (
int argc,
char **argv)
860 if (_rw_opt_compat (0, 0))
861 return _rw_setopt_compat_warn (argc, argv,
'G');
863 return _rw_setopt_compat_error (argc, argv,
'G');
868_rw_setopt_compat_alarm (
int argc,
char **argv)
870 if (_rw_opt_compat (0, 0))
871 return _rw_setopt_compat_warn (argc, argv,
'L');
873 return _rw_setopt_compat_error (argc, argv,
'L');
878_rw_setopt_compat_machine (
int argc,
char **argv)
880 if (_rw_opt_compat (0, 0))
881 return _rw_setopt_compat_warn (argc, argv,
'M');
883 return _rw_setopt_compat_error (argc, argv,
'M');
888_rw_setopt_compat_output_file (
int argc,
char **argv)
890 if (_rw_opt_compat (0, 0))
891 return _rw_setopt_output_file (argc, argv);
893 return _rw_setopt_compat_error (argc, argv,
'O');
908 _rw_setopt_compat_append,
909 _rw_setopt_compat_compiler,
910 _rw_setopt_compat_dir,
911 _rw_setopt_compat_debug_file,
912 _rw_setopt_compat_alarm,
913 _rw_setopt_compat_machine,
914 _rw_setopt_compat_output_file,
919 "%s:%d: rw_setopts() failed\n", __FILE__, __LINE__);
930# if defined (_MSC_VER) && _MSC_VER >= 1400
933_rw_invalid_parameter (
const wchar_t* ,
945_rw_opt_no_popups (
int argc,
char *argv[])
947 static int opt_no_popups;
951 return opt_no_popups;
954 if (1 == argc && argv && 0 == argv [0]) {
957 static const char helpstr[] = {
958 "Prevents the program from using message box popup window's for\n"
970 SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
974 _set_invalid_parameter_handler (_rw_invalid_parameter);
977 _CrtSetReportMode (_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
978 _CrtSetReportFile (_CRT_WARN, _CRTDBG_FILE_STDERR);
979 _CrtSetReportMode (_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
980 _CrtSetReportFile (_CRT_ERROR, _CRTDBG_FILE_STDERR);
981 _CrtSetReportMode (_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
982 _CrtSetReportFile (_CRT_ASSERT, _CRTDBG_FILE_STDERR);
991#if defined (_MSC_VER) && defined (_DEBUG)
994_rw_opt_debug_heap (
int argc,
char *argv[])
996 static int opt_debug_heap;
1000 return opt_debug_heap;
1003 if (1 == argc && argv && 0 == argv [0]) {
1006 static const char helpstr[] = {
1007 "Enables the heap consistency checking on every memory allocation\n"
1008 "and deallocation request.\n"
1019 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF
1020 | _CRTDBG_CHECK_ALWAYS_DF
1021 | _CRTDBG_LEAK_CHECK_DF);
1032_rw_setopts_windows ()
1041 "%s:%d: rw_setopts() failed\n", __FILE__, __LINE__);
1046# if defined (_MSC_VER) && defined (_DEBUG)
1055 "%s:%d: rw_setopts() failed\n", __FILE__, __LINE__);
1071 const char *file_name,
1073 const char *comment,
1074 int (*
fun)(
int,
char**),
1086 _rw_driver_init = 1;
1090 "%s:%d: rw_setopts() failed\n", __FILE__, __LINE__);
1113 _rw_setopt_output_file,
1121 "%s:%d: rw_setopts() failed\n", __FILE__, __LINE__);
1126 _rw_setopts_compat ();
1133 _rw_setopts_windows ();
1143 if (_rw_opt_no_stdout (0, 0) && file_name) {
1147 strcpy (fname, slash ? slash + 1 : file_name);
1149 char*
const dot = strchr (fname,
'.');
1151 strcpy (dot,
".out");
1153 strcat (fname,
".out");
1155 _rw_ftestout = (rw_file*)(
void*)fopen (fname,
"w");
1162 strcpy (clause_id, clause);
1164 static const char thick_line[] = {
1165 "############################################################"
1168 static const char begin_fmt[] = {
1171 "# ENVIRONMENT: %s\n"
1173 "# COMPILED: %s, %s\n"
1179 const char*
const fname =
1185 fname ? fname + 1 : file_name,
1187 comment ? comment :
"",
1190 status =
setjmp (test_env);
1194 status =
fun (argc, argv);
1200 _rw_driver_done = 1;
1202 static const char tblrow[] =
1203 "+-----------------------+----------+----------+----------+";
1207 "# | DIAGNOSTIC | ACTIVE | TOTAL | INACTIVE |\n"
1222 const long inactive = ndiags [
i][0] - ndiags [
i][1];
1223 const long total = long (ndiags [
i][0]);
1225 const long pct = total ? long ((inactive * 100.0) / total) : 0;
1227 const char* pfx =
"";
1228 const char* sfx =
"";
1230 static int use_color = _rw_use_color ();
1238 "# | (S%d) %-*s |%s %8d %s| %8d | %7ld%% |\n",
1241 pfx, ndiags [
i][1], sfx, ndiags [
i][0], pct);
1246 rw_fprintf (_rw_ftestout,
"# no diagnostics\n");
1250 if (_rw_opt_compat (0, 0)) {
1258 "## Warnings = %d\n"
1259 "## Assertions = %d\n"
1260 "## FailedAssertions = %d\n",
1267 if (_rw_ftestout && _rw_ftestout !=
rw_stdout) {
1268 fclose ((
FILE*)(
void*)_rw_ftestout);
1281 const char *comment,
1309_rw_escape (
char *
buf,
size_t bufsize,
char esc)
1318 while ((quote = strchr (quote,
'"'))) {
1329 size_t newbufsize = strlen (
buf) + nquotes + 1;
1338 newbuf = (
char*)malloc (newbufsize);
1345 char *next = newbuf;
1351 for (
char *
q =
buf; ; ++
q) {
1354 q = strchr (
q,
'"');
1358 const size_t nchars =
q ? size_t (
q - quote) : strlen (quote);
1360 memcpy (next, quote,
nchars);
1389_rw_vissue_diag (
diag_t diag,
int severity,
const char *file,
int line,
1390 const char *fmt, va_list va)
1397 static char fmterr[] =
"*** formatting error ***";
1402 if (
nchars < 0 || 0 == usrbuf)
1407 for (
const char *nl = usrbuf; (nl = strchr (nl,
'\n')); ++nl)
1410 static const int use_color = _rw_use_color ();
1412 const char*
const diagstr[] = {
1420 const char*
const traced_diag =
1441 char*
const newbuf = _rw_escape (usrbuf, 0,
'"');
1442 if (newbuf != usrbuf) {
1456 diagstr [0], diagstr [1],
1457 0 != traced_diag, traced_diag, diagstr [2],
1459 0 != file ? file :
"",
1465 nlines += 2 + (
'\0' != *clause_id) + (0 != file) + (0 <
line);
1476 "%{?}# CLAUSE: %s\n%{;}"
1477 "%{?}# FILE: %s\n%{;}"
1478 "%{?}# LINE: %d\n%{;}",
1481 0 != traced_diag, traced_diag,
1484 0 != diagstr [3], diagstr [3],
1487 '\0' != *clause_id, clause_id,
1499 "%{?}(%d lines): %{;}"
1506 diagstr [0], diagstr [1],
1507 0 != traced_diag, traced_diag, diagstr [2],
1509 '\0' != *clause_id, clause_id,
1520 if (mybuf != fmterr)
1523 if (usrbuf != fmterr)
1530_rw_vdiag (
diag_t diag,
int severity,
const char *file,
int line,
1531 const char *fmt, va_list va)
1551 severity = diag * severity;
1564 severity = diag * severity;
1580 const int sevbit = (1 << severity);
1584 _rw_vissue_diag (diag, severity, file,
line, fmt, va);
1589 longjmp (test_env, severity);
1647rw_warn (
int success,
const char *file,
int line,
const char *fmt, ...)
1664rw_note (
int success,
const char *file,
int line,
const char *fmt, ...)
1681rw_info (
int success,
const char *file,
int line,
const char *fmt, ...)
1698rw_enable (
int (*
fun) (
int,
const char*,
int,
const char*, ...),
bool enable)
1715 RW_ASSERT (!
"Invalid function in rw_enable");
void testfun(std::ios_base::event ev, std::ios_base &iosobj, int index)
#define va_start(va, name)
#define _RWSTD_UNUSED(arg)
#define _RWSTD_CONST_CAST(T, x)
_TEST_EXPORT int rw_assert(int success, const char *file, int line, const char *fmt,...)
_TEST_EXPORT int rw_error(int success, const char *file, int line, const char *fmt,...)
_TEST_EXPORT int rw_vsetopts(const char *opts, va_list va)
_RWSTD_DLLIMPORT int() fileno(FILE *) _LIBC_THROWS()
_TEST_EXPORT int rw_warn(int success, const char *file, int line, const char *fmt,...)
_TEST_EXPORT bool rw_enable(int(*fun)(int, const char *, int, const char *,...), bool enable)
_TEST_EXPORT int rw_fatal(int success, const char *file, int line, const char *fmt,...)
#define CHECK_INIT(init, func)
_TEST_EXPORT int rw_test(int argc, char **argv, const char *fname, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optstr,...)
_TEST_EXPORT int rw_note(int success, const char *file, int line, const char *fmt,...)
_TEST_EXPORT int rw_vtest(int argc, char **argv, const char *file_name, const char *clause, const char *comment, int(*fun)(int, char **), const char *optstr, va_list va)
_TEST_EXPORT int rw_info(int success, const char *file, int line, const char *fmt,...)
_TEST_EXPORT int rw_vasnprintf(char **, size_t *, const char *, va_list)
int _rw_setopt_diags(int argc, char *argv[])
int _rw_expected(int line)
int _rw_setopt_trace_mask(int argc, char *argv[])
int _rw_setopt_trace(int argc, char *argv[])
_TEST_EXPORT int rw_setopts(const char *optspec,...)
_TEST_EXPORT int rw_runopts(int argc, char *argv[])
_TEST_EXPORT rw_file *const rw_stderr
_TEST_EXPORT char * rw_sprintfa(const char *fmt,...)
_TEST_EXPORT int rw_fprintf(rw_file *, const char *,...)
_TEST_EXPORT rw_file *const rw_stdout