Author: faridz
Date: Thu Sep 13 10:39:29 2007
New Revision: 575378
URL: http://svn.apache.org/viewvc?rev=575378&view=rev
Log:
2007-09-13 Farid Zaripov <[EMAIL PROTECTED]>
STDCXX-543
* runall.cpp (main): Added ability to pass list of the targets
using the text file.
* cmdopt.cpp: Updated usage_text with description of the
changes above.
* runall.wsf (runAllExamples): Pass targets using text file
rather than using command line if the resulting command line
length would exceed the maximum value.
Modified:
incubator/stdcxx/trunk/etc/config/windows/runall.wsf
incubator/stdcxx/trunk/util/cmdopt.cpp
incubator/stdcxx/trunk/util/runall.cpp
Modified: incubator/stdcxx/trunk/etc/config/windows/runall.wsf
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/etc/config/windows/runall.wsf?rev=575378&r1=575377&r2=575378&view=diff
==============================================================================
--- incubator/stdcxx/trunk/etc/config/windows/runall.wsf (original)
+++ incubator/stdcxx/trunk/etc/config/windows/runall.wsf Thu Sep 13 10:39:29
2007
@@ -249,31 +249,59 @@
runCmd += " -d \"" + srcDir + "\"";
if (0 < runflags.length)
- runCmd += " " + runflags;
-
- runCmd += " " + exeFiles.join(" ");
+ runCmd += " " + runflags + " ";
+ var targets = exeFiles.join(" ");
+ var target_list = null;
+
var prevDir = WshShell.CurrentDirectory;
WshShell.CurrentDirectory = exeDir;
- var oExec = WshShell.Exec("cmd /c " + runCmd + " 2>&1");
- WshShell.CurrentDirectory = prevDir;
- if (!oExec)
+ // the max command line len == 2047 for Win2000
+ // http://support.microsoft.com/kb/830473
+ var MaxCmdLineLen = 2047;
+ if (MaxCmdLineLen >= runCmd.length + targets.length)
+ runCmd += exeFiles.join(" ");
+ else
{
- // WScript.Echo(itemInfo.name + " failed to run");
- return;
+ target_list = "targets.lst";
+
+ var strm = fso.CreateTextFile(target_list, true);
+ for (var i = 0; i < exeFiles.length; ++i)
+ strm.WriteLine(exeFiles[i]);
+ strm.Close();
+
+ runCmd += "@" + target_list;
}
- var execOut = "";
- while (oExec.Status == 0)
+ try
{
+ runCmd = "cmd /c " + runCmd + " 2>&1";
+ var oExec = WshShell.Exec(runCmd);
+
+ var execOut = "";
+ while (oExec.Status == 0)
+ {
+ execOut += oExec.StdOut.ReadAll();
+ WScript.Sleep(100);
+ }
+
execOut += oExec.StdOut.ReadAll();
- WScript.Sleep(100);
+ WScript.Echo(execOut);
}
-
- execOut += oExec.StdOut.ReadAll();
- WScript.Echo(execOut);
-
+ catch (e)
+ {
+ WScript.Echo("Exception in WshShell.Exec(" + runCmd + "): " +
e.message);
+ return;
+ }
+ finally
+ {
+ if (null != target_list)
+ fso.DeleteFile(target_list);
+
+ WshShell.CurrentDirectory = prevDir;
+ }
+
for (var i = 0; i < arrInfo.length; ++i)
{
var itemInfo = arrInfo[i];
Modified: incubator/stdcxx/trunk/util/cmdopt.cpp
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/cmdopt.cpp?rev=575378&r1=575377&r2=575378&view=diff
==============================================================================
--- incubator/stdcxx/trunk/util/cmdopt.cpp (original)
+++ incubator/stdcxx/trunk/util/cmdopt.cpp Thu Sep 13 10:39:29 2007
@@ -89,6 +89,8 @@
"\n"
" Treats each token in targets as the path to an executable. Each
target\n"
" enumerated is executed, and the output is processed after
termination.\n"
+ " If target prepended by '@' character, target is treated as text file\n"
+ " with list of targets (one target per line).\n"
" If the execution takes longer than a certain (configurable) amount of\n"
" time, the process is killed.\n"
"\n"
Modified: incubator/stdcxx/trunk/util/runall.cpp
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/runall.cpp?rev=575378&r1=575377&r2=575378&view=diff
==============================================================================
--- incubator/stdcxx/trunk/util/runall.cpp (original)
+++ incubator/stdcxx/trunk/util/runall.cpp Thu Sep 13 10:39:29 2007
@@ -31,6 +31,7 @@
#include <stdio.h> /* for FILE, fopen(), ... */
#include <ctype.h> /* for isspace */
+#include <limits.h> /* for PATH_MAX */
#include <sys/types.h>
#include <sys/stat.h>
#if !defined (_WIN32) && !defined (_WIN64)
@@ -61,6 +62,12 @@
# define S_IXOTH 0001
#endif /* S_IXOTH */
+#if !defined (PATH_MAX) || PATH_MAX < 128 || 4096 < PATH_MAX
+ // deal with undefined, bogus, or excessive values
+# undef PATH_MAX
+# define PATH_MAX 1024
+#endif
+
/**
Utility function to rework the argv array
@@ -537,11 +544,50 @@
struct target_status summary;
memset (&summary, 0, sizeof summary);
+ /* number of program's executed */
+ int progs_count = 0;
+
for (i = 0; i < argc; ++i) {
- run_target (&summary, argv [i], &target_template);
+ const char* target = argv [i];
+
+ if ('@' == target [0]) {
+ /* read targets from specified file */
+ const char* lst_name = target + 1;
+ FILE* lst = fopen (lst_name, "r");
+ if (0 == lst) {
+ warn ("Error opening %s: %s\n", lst_name, strerror
(errno));
+ break;
+ }
+
+ while (!feof (lst)) {
+ char buf [PATH_MAX];
+ target = fgets (buf, sizeof (buf), lst);
+
+ if (ferror (lst)) {
+ warn ("Error reading %s: %s\n", lst_name, strerror
(errno));
+ break;
+ }
+
+ if (target) {
+ /* remove terminating newline character if present */
+ if (char* pos = strchr (target, '\n'))
+ *pos = '\0';
+ if (*target) {
+ ++progs_count;
+ run_target (&summary, target, &target_template);
+ }
+ }
+ }
+
+ fclose (lst);
+ }
+ else {
+ ++progs_count;
+ run_target (&summary, target, &target_template);
+ }
}
- print_footer (argc, &summary);
+ print_footer (progs_count, &summary);
if (target_template.argv [0])
free (target_template.argv [0]);