Author: sebor
Date: Thu Jul 26 12:04:16 2007
New Revision: 559941
URL: http://svn.apache.org/viewvc?view=rev&rev=559941
Log:
2007-07-26 Martin Sebor <[EMAIL PROTECTED]>
* display.h (short_st_name): Removed declaration.
(print_header, print_footer): Added an argument.
* display.cpp (short_st_name): Moved to the top of file.
(verbose_st_name): New array to parallel short_st_name.
(print_argv): New.
(print_header_plain): Added an (unused) argument.
(print_header_verbose, print_target_verbose, print_status_verbose):
New handlers for verbose output.
(print_target_plain): Asserted a precondition.
(print_footer_plain): Added an argument and printed out summary
information.
(set_output_format): Defined.
* exec.cpp (open_input): Allowed data_dir to be null.
* cmdopt.cpp (eval_options): Set defaults to all 0. Handled
the -v (verbose) option.
* output.cpp (parse_output): Allowed data_dir to be null.
* util.cpp (reference_name): Allowed data_dir to be null.
* target.h (target_opts): Added a verbose member.
* runall.cpp (merge_argv): Corrected constness of argument.
(run_target): Added a new argument and incremented summary data.
(main): Removed default timeout of 10 seconds.
Called set_output_format().
Passed argument to print_header() and print_footer().
Modified:
incubator/stdcxx/trunk/util/cmdopt.cpp
incubator/stdcxx/trunk/util/display.cpp
incubator/stdcxx/trunk/util/display.h
incubator/stdcxx/trunk/util/exec.cpp
incubator/stdcxx/trunk/util/output.cpp
incubator/stdcxx/trunk/util/runall.cpp
incubator/stdcxx/trunk/util/target.h
incubator/stdcxx/trunk/util/util.cpp
Modified: incubator/stdcxx/trunk/util/cmdopt.cpp
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/cmdopt.cpp?view=diff&rev=559941&r1=559940&r2=559941
==============================================================================
--- incubator/stdcxx/trunk/util/cmdopt.cpp (original)
+++ incubator/stdcxx/trunk/util/cmdopt.cpp Thu Jul 26 12:04:16 2007
@@ -503,11 +503,15 @@
const char opt_signal[] = "--signal";
const char opt_sleep[] = "--sleep";
const char opt_ulimit[] = "--ulimit";
+ const char opt_verbose[] = "--verbose";
const char opt_warn[] = "--warn";
int i;
assert (0 != argv);
+ assert (0 != defaults);
+
+ memset (defaults, 0, sizeof (target_opts));
/* The chain of preprocesor logic below initializes the defaults->c_warn
and defaults->l_warn values.
@@ -582,6 +586,11 @@
defaults->data_dir = get_short_val (argv, &i);
if (!defaults->data_dir)
missing_value (optname);
+ break;
+
+ case 'v': /* enable verbose mode */
+ optname = opt_verbose;
+ ++defaults->verbose;
break;
case 'x': /* command line options to pass to targets */
Modified: incubator/stdcxx/trunk/util/display.cpp
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/display.cpp?view=diff&rev=559941&r1=559940&r2=559941
==============================================================================
--- incubator/stdcxx/trunk/util/display.cpp (original)
+++ incubator/stdcxx/trunk/util/display.cpp Thu Jul 26 12:04:16 2007
@@ -26,31 +26,148 @@
#include <assert.h>
#include <stdio.h> /* for fflush(), printf(), puts(), ... */
+#include <string.h> /* for strchr() */
#include "cmdopt.h" /* for target_name -should this be moved? */
#include "exec.h" /* for get_signame */
#include "display.h"
+#include "target.h" /* for target_status */
+
+
+/**
+ ProcessStatus enum lookup table for 'short' (6 character) strings.
+*/
+static const char* const
+short_st_name [ST_LAST] = {
+ "OK", /*ST_OK*/
+ "COMP", /*ST_COMPILE*/
+ "LINK", /*ST_LINK*/
+ "EXIST", /*ST_EXIST*/
+ "XPERM", /*ST_EXECUTE_FLAG*/
+ "EXEC", /*ST_EXECUTE*/
+ "NOUT", /*ST_NO_OUTPUT*/
+ "OUTPUT", /*ST_NO_REF*/
+ "BREF", /*ST_BAD_REF*/
+ "DIFF", /*ST_BAD_OUTPUT*/
+ "FORMAT", /*ST_FORMAT*/
+ "OFLOW", /*ST_OVERFLOW*/
+ "ERROR", /*ST_SYSTEM_ERROR*/
+ "KILLED", /*ST_KILLED*/
+ "NKILL" /*ST_NOT_KILLED*/
+};
+
+
+/**
+ ProcessStatus enum lookup table for descriptive strings.
+*/
+static const char* const
+verbose_st_name [ST_LAST] = {
+ "OK", /*ST_OK*/
+ "Program failed to compile.", /*ST_COMPILE*/
+ "Program failed to link.", /*ST_LINK*/
+ "Program executable not found.", /*ST_EXIST*/
+ "Program not executable.", /*ST_EXECUTE_FLAG*/
+ "Program failed to execute.", /*ST_EXECUTE*/
+ "Program generated no output.", /*ST_NO_OUTPUT*/
+ "Program reference output missing.", /*ST_NO_REF*/
+ "Bad reference.", /*ST_BAD_REF*/
+ "Program produced unexpected output.", /*ST_BAD_OUTPUT*/
+ "Program produced output in unexpected format.", /*ST_FORMAT*/
+ "Arithmetic overflow.", /*ST_OVERFLOW*/
+ "System error occurred.", /*ST_SYSTEM_ERROR*/
+ "Process killed after a timeout.", /*ST_KILLED*/
+ "Failed to kill process after a timeout." /*ST_NOT_KILLED*/
+};
+
+
+/**
+ Prints an argv array, quoting elelemnts containing spaces.
+*/
+static int
+print_argv (const char* const argv[], int newline)
+{
+ assert (0 != argv);
+
+ const char* const* parg = argv;
+
+ int nchars = 0;
+
+ for (parg = argv; *parg; ++parg) {
+
+ const char *fmt = "%s ";
+
+ if (strchr (*parg, ' '))
+ fmt = "\"%s\" ";
+
+ nchars += printf (fmt, *parg);
+ }
+
+ if (newline)
+ puts ("");
+
+ return nchars;
+}
+
/**
Generates output header, designed for text output and console viewing.
*/
-static void print_header_plain ()
+static void
+print_header_plain (const char* const argv[])
{
+ (void)&argv;
+
puts ("NAME STATUS WARN ASSERTS FAILED PERCNT"
" USER SYS REAL");
}
+
+/**
+ Generates output header in verbose mode.
+*/
+static void
+print_header_verbose (const char* const argv[])
+{
+ print_argv (argv, 1 /* append newline */);
+}
+
+
+
/**
Generates target name listing, designed for text output and console viewing.
*/
-static void print_target_plain (const struct target_opts*)
+static void
+print_target_plain (const struct target_opts *defaults)
{
const char* const target_name = get_target ();
+
+ assert (0 == defaults->verbose);
+
printf ("%-30.30s ", target_name);
+
+ /* flush to prevent killing a signal from not displaying the text */
fflush (stdout);
}
+
+/**
+ Generates target name listing, designed for text output and console viewing.
+*/
+static void
+print_target_verbose (const struct target_opts *defaults)
+{
+ assert (defaults->verbose);
+
+ printf ("%s ", "Executing \"");
+ print_argv (defaults->argv, 0 /* no newline */);
+ puts ("\"");
+
+ /* flush to prevent killing a signal from not displaying the text */
+ fflush (stdout);
+}
+
+
/**
Generates target result listing, designed for text output and console
viewing.
@@ -103,32 +220,115 @@
puts ("");
}
+
+/**
+ Generates verbose target result listing.
+*/
+static void
+print_status_verbose (const struct target_status* status)
+{
+ unsigned valid_timing;
+
+ assert (0 != status);
+ assert (ST_OK <= status->status && ST_LAST > status->status);
+
+ valid_timing = status->user && status->sys
+ && ST_NOT_KILLED != status->status;
+
+ if (status->status) /* if status is set, print it */
+ printf (" Status: %s\n", verbose_st_name [status->status]);
+ else if (status->signaled) /* if exit signal is non-zero, print it */
+ printf (" Process signalled: %s", get_signame (status->exit));
+ else {
+ printf (" Exit status: %6d%s\n"
+ " Compiler warnings: %6u\n"
+ " Linker warnings: %6u\n"
+ " Runtime warnings: %6u\n",
+ status->exit, 0 == status->exit ? " (success)" : "",
+ status->c_warn,
+ status->l_warn,
+ status->t_warn);
+
+ /* Print assetions, if any registered */
+ if ((unsigned)-1 != status->assert && status->assert) {
+ printf (" Failed assertions: %6u\n"
+ " Total assertions: %6u\n",
+ status->failed, status->assert);
+ }
+ }
+
+ /* Print timings, if available */
+ if (valid_timing) {
+ const float wall = status->wall ? *status->wall / TICKS_PER_SEC : -1;
+ const float user = status->user ? *status->user / TICKS_PER_SEC : -1;
+ const float sys = status->sys ? *status->sys / TICKS_PER_SEC : -1;
+
+ printf (" Times:\n"
+ " Real %7.3fs\n"
+ " User %7.3fs\n"
+ " Sys %7.3fs\n",
+ wall, user, sys);
+ }
+
+ puts ("");
+}
+
+
/**
Placholder output footer function, unneeded for text output and console
viewing.
*/
-static void print_footer_plain () {}
+static void
+print_footer_plain (const struct target_status *summary)
+{
+ printf ("PROGRAM SUMMARY:\n"
+ " Non-zero exit status: %6d\n"
+ " Signalled: %6d\n"
+ " Compiler warnings: %6u\n"
+ " Linker warnings: %6u\n"
+ " Runtime warnings: %6u\n"
+ " Assertions: %6u\n"
+ " Failed assertions: %6u\n",
+ summary->exit,
+ summary->signaled,
+ summary->c_warn,
+ summary->l_warn,
+ summary->t_warn,
+ summary->assert,
+ summary->failed);
+}
-const char* const short_st_name [ST_LAST] = {
- "OK", /*ST_OK*/
- "COMP", /*ST_COMPILE*/
- "LINK", /*ST_LINK*/
- "EXIST", /*ST_EXIST*/
- "XPERM", /*ST_EXECUTE_FLAG*/
- "EXEC", /*ST_EXECUTE*/
- "NOUT", /*ST_NO_OUTPUT*/
- "OUTPUT", /*ST_NO_REF*/
- "BREF", /*ST_BAD_REF*/
- "DIFF", /*ST_BAD_OUTPUT*/
- "FORMAT", /*ST_FORMAT*/
- "OFLOW", /*ST_OVERFLOW*/
- "ERROR", /*ST_SYSTEM_ERROR*/
- "KILLED", /*ST_KILLED*/
- "NKILL" /*ST_NOT_KILLED*/
-};
+static void
+print_footer_verbose (const struct target_status *summary)
+{
+ print_footer_plain (summary);
+}
+
+
+/**
+ Sets the output functions referenced.
+*/
+void set_output_format (enum OutputFmt format)
+{
+ if (FMT_VERBOSE == format) {
+ print_header = print_header_verbose;
+ print_target = print_target_verbose;
+ print_status = print_status_verbose;
+ print_footer = print_footer_verbose;
+ }
+ else {
+ /* only two formats implemented */
+ assert (FMT_PLAIN == format);
+
+ print_header = print_header_plain;
+ print_target = print_target_plain;
+ print_status = print_status_plain;
+ print_footer = print_footer_plain;
+ }
+}
-void (*print_header) () = print_header_plain;
+void (*print_header) (const char* const*) = print_header_plain;
void (*print_target) (const struct target_opts*) = print_target_plain;
-void (*print_status) (const struct target_status* status) =
print_status_plain;
-void (*print_footer) () = print_footer_plain;
+void (*print_status) (const struct target_status*) = print_status_plain;
+void (*print_footer) (const struct target_status*) = print_footer_plain;
Modified: incubator/stdcxx/trunk/util/display.h
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/display.h?view=diff&rev=559941&r1=559940&r2=559941
==============================================================================
--- incubator/stdcxx/trunk/util/display.h (original)
+++ incubator/stdcxx/trunk/util/display.h Thu Jul 26 12:04:16 2007
@@ -43,11 +43,6 @@
};
/**
- ProcessStatus enum lookup table for 'short' (6 character) strings.
-*/
-extern const char* const short_st_name [ST_LAST];
-
-/**
Sets the output functions referenced.
*/
void set_output_format (enum OutputFmt format);
@@ -62,7 +57,7 @@
/**
Prints the table preamble formatting, followed by the formatted header row.
*/
-extern void (*print_header) ();
+extern void (*print_header) (const char* const argv[]);
/**
Prints the formatted header column for a target row.
@@ -94,6 +89,7 @@
/**
Prints the closing formatting for the table.
*/
-extern void (*print_footer) ();
+extern void (*print_footer) (const struct target_status* status);
+
#endif /* RW_DISPLAY_H */
Modified: incubator/stdcxx/trunk/util/exec.cpp
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/exec.cpp?view=diff&rev=559941&r1=559940&r2=559941
==============================================================================
--- incubator/stdcxx/trunk/util/exec.cpp (original)
+++ incubator/stdcxx/trunk/util/exec.cpp Thu Jul 26 12:04:16 2007
@@ -643,9 +643,8 @@
int intermit = -1;
assert (0 != exec_name);
- assert (0 != data_dir);
- if (strlen (data_dir)) {
+ if (data_dir && data_dir) {
char* tmp_name;
/* Try data_dir/manual/in/exec_name.in */
@@ -982,10 +981,9 @@
char* tmp_name;
assert (0 != exec_name);
- assert (0 != data_dir);
assert (0 != child_sa);
- if (!strlen (data_dir))
+ if (0 == data_dir || '\0' == *data_dir)
return 0;
/* Try data_dir\manual\in\exec_name.in */
Modified: incubator/stdcxx/trunk/util/output.cpp
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/output.cpp?view=diff&rev=559941&r1=559940&r2=559941
==============================================================================
--- incubator/stdcxx/trunk/util/output.cpp (original)
+++ incubator/stdcxx/trunk/util/output.cpp Thu Jul 26 12:04:16 2007
@@ -342,7 +342,7 @@
status->status = ST_NO_OUTPUT;
}
else {
- if (!strlen (options->data_dir)) {
+ if (0 == options->data_dir || '\0' == *options->data_dir) {
/* If there is not an input directory, look at the assertion tags
*/
if (!options->compat)
Modified: incubator/stdcxx/trunk/util/runall.cpp
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/runall.cpp?view=diff&rev=559941&r1=559940&r2=559941
==============================================================================
--- incubator/stdcxx/trunk/util/runall.cpp (original)
+++ incubator/stdcxx/trunk/util/runall.cpp Thu Jul 26 12:04:16 2007
@@ -87,7 +87,7 @@
@return processed argv array, usable in exec ()
*/
static char**
-merge_argv (char* const target, char* const argv [])
+merge_argv (const char* target, char* const argv [])
{
size_t tlen;
char ** split;
@@ -420,7 +420,9 @@
@see process_results
*/
static void
-run_target (char* target, const struct target_opts *target_template)
+run_target (struct target_status *summary,
+ const char *target,
+ const struct target_opts *target_template)
{
struct target_opts options;
struct target_status results;
@@ -449,10 +451,24 @@
print_status (&results);
+ if (summary) {
+ /* increment summary the counters */
+ if (0 == results.signaled && results.exit)
+ ++summary->exit;
+
+ summary->signaled += results.signaled;
+ summary->c_warn += results.c_warn;
+ summary->l_warn += results.l_warn;
+ summary->t_warn += results.t_warn;
+ summary->assert += results.assert;
+ summary->failed += results.failed;
+ }
+
free (options.argv [0]);
free (options.argv);
}
+
/**
Entry point to the application.
@@ -469,12 +485,9 @@
{
struct target_opts target_template;
const char* exe_opts = "";
+ const char* const* const saved_argv = (const char* const*)argv;
exe_name = argv [0];
- memset (&target_template, 0, sizeof target_template);
-
- target_template.timeout = 10;
- target_template.data_dir = "";
if (1 < argc && '-' == argv [1][0]) {
const int nopts =
@@ -487,23 +500,36 @@
argv += nopts;
}
else {
+ /* initialize data members */
+ memset (&target_template, 0, sizeof target_template);
+
--argc;
++argv;
}
+ /* set the program output mode */
+ if (target_template.verbose)
+ set_output_format (FMT_VERBOSE);
+ else
+ set_output_format (FMT_PLAIN);
+
if (0 < argc) {
int i;
target_template.argv = split_opt_string (exe_opts);
assert (0 != target_template.argv);
- print_header ();
+ /* print out the program's argv array in verbose mode */
+ print_header (target_template.verbose ? saved_argv : 0);
+
+ struct target_status summary;
+ memset (&summary, 0, sizeof summary);
for (i = 0; i < argc; ++i) {
- run_target (argv [i], &target_template);
+ run_target (&summary, argv [i], &target_template);
}
- print_footer ();
+ print_footer (&summary);
if (target_template.argv [0])
free (target_template.argv [0]);
Modified: incubator/stdcxx/trunk/util/target.h
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/target.h?view=diff&rev=559941&r1=559940&r2=559941
==============================================================================
--- incubator/stdcxx/trunk/util/target.h (original)
+++ incubator/stdcxx/trunk/util/target.h Thu Jul 26 12:04:16 2007
@@ -79,6 +79,7 @@
const char* c_warn; /**< Warning flag string when compiling. */
const char* l_warn; /**< Warning flag string when linking. */
int compat; /**< Test suite compatability mode switch. */
+ int verbose; /**< Verbose mode. */
rw_rlimit* core;
rw_rlimit* cpu;
rw_rlimit* data;
Modified: incubator/stdcxx/trunk/util/util.cpp
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/util.cpp?view=diff&rev=559941&r1=559940&r2=559941
==============================================================================
--- incubator/stdcxx/trunk/util/util.cpp (original)
+++ incubator/stdcxx/trunk/util/util.cpp Thu Jul 26 12:04:16 2007
@@ -1,22 +1,26 @@
/************************************************************************
*
- * util.cpp - Utility function definitions for the runall utility
+ * util.cpp - Utility function definitions for the exec utility
*
* $Id$
*
************************************************************************
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*
**************************************************************************/
@@ -114,12 +118,11 @@
char* tail;
const char* const target_name = get_target ();
- assert (0 != data_dir);
assert (0 != target_name);
assert (0 != subdir);
assert (0 != mode);
- root_len = strlen (data_dir);
+ root_len = data_dir ? strlen (data_dir) : 0;
cmp_len = strlen (target_name) - exe_suffix_len;
dir_len = strlen (subdir);
mode_len = strlen (mode);