Commit Graph

22554 Commits (cfe37cbfb5bdec0aa01c86a608ecc6cdc3df8a2a)

Author SHA1 Message Date
Nat Goodspeed cfe37cbfb5 Break out std::ostream << CaptureLog routine for general use. 2012-03-01 22:45:16 -05:00
Nat Goodspeed 0ef99cd33b Add LLLeap class, initial implementation, initial unit tests.
Instantiating LLLeap with a command to execute a particular child process sets
up machinery to speak LLSD Event API Plugin protocol with that child process.
LLLeap is an LLInstanceTracker subclass, so the code that instantiates need
not hold the pointer. LLLeap monitors child-process termination and deletes
itself when done.
2012-03-01 17:46:44 -05:00
Nat Goodspeed f0612f6fc4 Allow CaptureLog's consumer to specify desired log level.
Of course, given the way the log machinery works, it's really "everything at
that level or stronger."
2012-03-01 17:30:50 -05:00
Nat Goodspeed c8032de94e Add NamedExtTempFile to invent arbitrary name with specified ext.
This arises, for instance, if you want to be able to create a temporary Python
module you can import from test scripts. The Python module file MUST have the
.py extension.
2012-03-01 14:37:41 -05:00
Nat Goodspeed f904867720 Make CaptureLog::withMessage() raise tut::failure if not found.
All known callers were using ensure(! withMessage(...).empty()). Centralize
that logic. Make failure message report the string being sought and the log
messages in which it wasn't found.
In case someone does want to permit the search to fail, add an optional
'required' parameter, default true.
Leverage new functionality in llprocess_test.cpp.
2012-03-01 14:33:23 -05:00
Nat Goodspeed 22fcb563ce Log better error message in case of apr_proc_create() failure.
We were using uniform macro to report the APR function and its C++ parameter
expressions. But specifically for apr_proc_create() failure, better to report
the command we're attempting to execute.
2012-03-01 14:27:32 -05:00
Nat Goodspeed 2596816f31 Break out TestRecorder class as CaptureLog into wrapllerrs.h.
Giving more unit tests the ability to capture and examine log output is
generally useful. Renaming the class just makes it less ambiguous: what's a
TestRecorder? Something that records tests?
2012-03-01 13:43:52 -05:00
Nat Goodspeed 40dc3e0d3b When constructing a pipe to child stdin on Posix, ignore SIGPIPE.
We can't count on every child process reading everything we try to write to
it. And if the child terminates with WritePipe data still pending, unless we
explicitly suppress it, Posix will hit us with SIGPIPE. That would terminate
the calling process, boom. "Ignoring" it means APR gets the correct errno,
passes it back to us, we log it, etc.
2012-02-29 19:40:18 -05:00
Nat Goodspeed 3649eda62a Guarantee LLProcess::Params::postend listener any ReadPipe data.
Previously one might get process-terminated notification but still have to
wait for the child process's final data to arrive on one or more ReadPipes.
That required complex consumer timing logic to handle incomplete pending
ReadPipe data, e.g. a partial last line with no terminating newline. New code
guarantees that by the time LLProcess sends process-terminated notification,
all pending pipe data will have been buffered in ReadPipes.
Document LLProcess::ReadPipe::getPump() notification event; add "eof" key.
Add LLProcess::ReadPipe::getline() and read() convenience methods.
Add static LLProcess::getline() and basename() convenience methods, publishing
logic already present elsewhere.
Use ReadPipe::getline() and read() in unit tests.
Add unit test for "eof" event on ReadPipe::getPump().
Add unit test verifying that final data have been buffered by termination
notification event.
2012-02-29 17:10:19 -05:00
Nat Goodspeed 7fd281ac99 Reduce redundancy in llprocess_test.cpp using get_test_name(). 2012-02-27 15:24:14 -05:00
Nat Goodspeed 063edac43f Automated merge with file:///Users/nat/linden/viewer-leap-daggy 2012-02-27 14:48:39 -05:00
Nat Goodspeed 6f53796ccf Add LLInstanceTracker test for exception in subclass constructor.
We want to verify the sequence:
LLInstanceTracker constructor adds instance to underlying container
Subclass constructor throws exception
LLInstanceTracker destructor removes instance from underlying container.
2012-02-27 14:47:40 -05:00
Nat Goodspeed e7ab3da7a7 Automated merge with file:///Users/nat/linden/viewer-leap-daggy 2012-02-27 11:51:57 -05:00
Nat Goodspeed c0318d1bf9 Make LLInstanceTracker<T, T*>::getInstance(T*) validate passed T*.
For the T* specialization (no string, or whatever, key), the original
getInstance() method simply returned the passed-in T* value. It was defined,
as the comments noted, for completeness of the analogy with the keyed
LLInstanceTracker specialization.
It turns out, though, that getInstance(T*) can still be useful to ask whether
the T* you have in hand still references a valid T instance. Support that
usage.
2012-02-27 11:50:47 -05:00
Nat Goodspeed 4a7848148e Add TODOs for getTokens() to known places that scan command lines.
Lacking time to properly test new LLStringUtil::getTokens() against the
present (different!) command-line scanners in LLExternalEditor::tokenize() and
LLCommandLineParser::parseCommandLineString(), just annotate as future work
the goal of unifying them... SIGH.
2012-02-26 07:21:51 -05:00
Nat Goodspeed bf7c215692 Add LLStringUtil::getTokens() test for quoted empty string.
This is an important differentiator between getTokens() and the present
LLCommandLineParser::parseCommandLineString() logic: you cannot currently
--set SomeVar to an empty string value because parseCommandLineString()
discards empty strings.
2012-02-26 07:17:08 -05:00
Nat Goodspeed d2faf5d25a Get rid of indra/llcommon/tests/setpython.py.
run_build_test.py already has the capability to set environment variables, and
we may as well direct it to set PYTHON to the running Python interpreter. That
completely eliminates one level of process wrapper.
2012-02-24 17:14:07 -05:00
Nat Goodspeed 4edf93d6d9 "Then there's Windows..." Fix llstring.h to build there too. 2012-02-24 16:50:47 -05:00
Nat Goodspeed 5adc39753b Update llevents_tut.cpp to use StringVec, not local StringList. 2012-02-24 16:02:39 -05:00
Nat Goodspeed 025329b6a2 Add LLStringUtil::getTokens() overload handling quoted substrings.
We didn't have any tokenizer suitable for scanning something like a bash
command line. We do have a couple hacks, e.g. LLExternalEditor::tokenize() and
LLCommandLineParser::parseCommandLineString(). Both try to work around
boost::tokenizer limitations; but existing boost::tokenizer support just
doesn't address this case. Neither of the above is available as a general
scanner anyway, and parseCommandLineString() fails outright when passed "".
New getTokens() also distinguishes between "drop delimiters" (e.g. space,
return, newline) to be discarded from the token stream, versus "keep
delimiters" (e.g. "+-*/") to be returned as tokens in their own right.
There's an overload that honors escapes and a more efficient one that doesn't;
each has a convenience overload that returns the scanned string vector rather
than requiring a separate declaration.
Tweak and comment older getTokens() implementation.
Add unit tests for both old and new getTokens() implementations.
Break out StringVec and std::ostream << StringVec from
indra/llcommon/tests/listener.h to StringVec.h: that's coming in handy for a
number of different TUT test sources.
2012-02-24 15:06:44 -05:00
Nat Goodspeed 14ddc6474a Tighten up LLProcess pipe support, per Richard's code review.
Clarify wording in some of the doc comments; be a bit more explicit about some
of the parameter fields.
Make some query methods 'const'.
Change default LLProcess::ReadPipe::getLimit() value to 0: don't post any
incoming data with notification event unless caller requests it. But do post
pertinent FILESLOT in case caller reuses same listener for both stdout and
stderr.
Use more idiomatic, readable syntax for accessing LLProcess::Params data.
2012-02-23 13:41:26 -05:00
Nat Goodspeed 999484a608 Let LLProcess consumer specify desired description for logging.
If caller runs (e.g.) a Python script, it's not very helpful to a human log
reader to keep seeing LLProcess instances logged as /pathname/to/python (pid).
If caller is aware, the code can at least use the script name as the desc --
or maybe even a hint as to the script's purpose.
If caller doesn't explicitly pass a desc, at least shorten to just the
basename of the executable.
2012-02-20 14:22:32 -05:00
Nat Goodspeed 8b5d5f9652 Make LLProcess post termination event to specified pump if desired.
This way a caller need not spin on isRunning(); we can just listen for the
requested termination event.
Post a similar event containing error message if for any reason
LLProcess::create() failed to launch the child.
Add unit tests for both cases.
2012-02-20 12:40:38 -05:00
Nat Goodspeed e98438bda7 Fix subtle bug in ReadPipeImpl: wouldn't tolerate multiple instances.
That is, trying to instantiate a ReadPipeImpl while another already existed
would throw an LLEventPump::DupPumpName exception. Fortunately this behavior
is easily bypassed.
2012-02-18 12:00:13 -05:00
Nat Goodspeed f52cf4be70 Fix typos in a few LLProcess::ReadPipe::find() unit tests.
The typos didn't make for invalid tests, but they made a few tests redundant
while leaving other (subtly different) cases untested.
2012-02-16 21:10:06 -05:00
Nat Goodspeed d6ed77a598 Attempt to fix Windows link error for LLProcess::BasePipe::npos. 2012-02-16 17:39:56 -05:00
Nat Goodspeed a06ba836c7 Fix bug in LLProcess::ReadPipe::peek() substring computation.
Add unit tests for peek() with substring args, reimplemented contains(),
various forms of find().
(yay unit tests)
2012-02-16 17:35:34 -05:00
Nat Goodspeed 4ecf9d6a2d Add unit test for LLProcess::ReadPipe::setLimit(). 2012-02-16 16:40:14 -05:00
Nat Goodspeed e92c311354 Add LLProcess::ReadPipe::find() methods, with corresponding npos.
If it's useful to have contains() to tell you whether incoming data contains a
particular substring, and if it's useful for contains() and peek() to accept
an offset within that data, then it's useful to allow you to get the offset of
a desired substring within that data. But of course a find() returning offset
needs something like std::string::npos for "not found"; borrow that
convention.
Support both find(const std::string&) and find(char); the latter permits a
more efficient implementation. In fact, make find(string) recognize a string
of length 1 and leverage the find(char) implementation.
Given that, reimplement contains(mumble) as shorthand for find(mumble) != npos.
Implement find() overloads using std::search() and std::find() on
boost::asio::streambuf character iterators, rather than copying to std::string
and then using string search like previous contains() implementation.
Reimplement WritePipeImpl::tick() and ReadPipeImpl::tick() to write/read
directly from/to boost::asio::streambuf data, instead of copying to/from a
temporary flat buffer.
As long as ReadPipeImpl::tick() keeps successfully filling buffers, keep
reading. Previous implementation would only handle a long child write over
successive tick() calls. Stop on read error or when we come up short.
2012-02-16 16:05:04 -05:00
Nat Goodspeed 85057908c3 Add unit test for listening on LLProcess::ReadPipe::getPump(). 2012-02-15 21:55:53 -05:00
Nat Goodspeed fc6d70db87 Don't be confused by "\r\n" line endings on pipe on Windows.
These are all very well when we just want to dump the output to a log, or
whatever, but in a unit-test context it matters for comparison.
2012-02-15 20:57:25 -05:00
Nat Goodspeed 56d931216e Add LLProcess::ReadPipe::size(), peek(), contains().
Also add "len" key to event data on LLProcess::getPump(). If you've used
setLimit(), event["data"].length() may not reflect the length of the
accumulated data in the ReadPipe.
Add unit test with stdin/stdout handshake with child process.
2012-02-15 15:47:03 -05:00
Nat Goodspeed 9b02f483ff VS2010 doesn't know how to compute min(4096, size_t) :-P 2012-02-15 14:04:46 -05:00
Nat Goodspeed 10ab4adc86 Fix llprocess_test.cpp's exception catching for Linux.
In the course of re-enabling the indra/test tests last year, Log generalized a
workaround I'd introduced in llsdmessage_test.cpp. In Linux viewer land, a
test program trying to catch an expected exception can't seem to catch it by
its specific class (across the libllcommon.so boundary), but must instead
catch std::runtime_error and validate the typeid().name() string. Log added a
macro for this idiom in llevents_tut.cpp. Generalize that macro further for
normal-case processing as well, move it to a header file of its own and use it
in all known places -- plus the new exception-catching tests in
llprocess_test.cpp.
2012-02-15 13:44:43 -05:00
Nat Goodspeed c6ccdb5b50 Add tests for LLProcess::get[Opt][Read|Write]Pipe() validations. 2012-02-15 12:11:38 -05:00
Nat Goodspeed e239cad1f5 Preliminary pipe support for LLProcess.
Add LLProcess::FileParam to specify how to construct each child's standard
file slot, with lots of comments about features designed but not yet
implemented. The point is to design it with enough flexibility to be able to
extend to foreseeable use cases.
Add LLProcess::Params::files to collect up to 3 FileParam items. Naturally
this extends the accepted LLSD syntax as well.
Implement type="" (child inherits parent file descriptor) and "pipe" (parent
constructs anonymous pipe to pass to child).
Add LLProcess::FILESLOT enum, plus methods:
getReadPipe(FILESLOT), getOptReadPipe(FILESLOT)
getWritePipe(), getOptWritePipe()
getPipeName(FILESLOT): placeholder implementation for now
Add LLProcess::ReadPipe and WritePipe classes, as returned by get*Pipe().
WritePipe supports get_ostream() method for streaming to child stdin.
ReadPipe supports get_istream() method for reading from child stdout/stderr.
It also provides getPump() returning LLEventPump& so interested parties can
listen for arrival of new data on the aforementioned std::istream.
For "pipe" slots, instantiate appropriate *Pipe class.
ReadPipe and WritePipe classes are pure virtual bases for ReadPipeImpl and
WritePipeImpl, respectively: all implementation data are hidden in the latter
classes, visible only in llprocess.cpp. In fact each *PipeImpl class registers
itself for "mainloop" ticks, attempting nonblocking I/O to the underlying
apr_file_t on each tick. Data are buffered in a boost::asio::streambuf, which
bridges between std::[io]stream and the APR I/O calls.
Sanity-test ReadPipeImpl by using a pipe to absorb the Python "SyntaxError"
output from the successful syntax_error test, rather than alarming the user.
Add first few unit tests for validating FileParam. More tests coming!
2012-02-15 10:07:09 -05:00
Nat Goodspeed aae61392be Use per-frame ticks on "mainloop" LLEventPump to update LLProcess.
When we reimplemented LLProcess on APR, necessitating APR's funny callback
mechanism to sense child-process status, every isRunning() or getStatus() call
called the APR poll function that calls ALL registered LLProcess callbacks. In
other words, every time any consumer called any LLProcess::isRunning() method,
all LLProcess callbacks were redundantly fired. Change that so that the single
APR poll function is called once per frame, courtesy of the "mainloop"
LLEventPump. Once per viewer frame should be well within the realtime duration
in which it's reasonable to expect child-process status to change.
In effect, this changes LLProcess's public API to introduce a dependency on
"mainloop" ticks. Add such ticks to llprocess_test.cpp as well.
2012-02-13 17:38:25 -05:00
Nat Goodspeed d4f887e43c Add unit tests for LLProcess::Status functionality. 2012-02-13 16:18:46 -05:00
Nat Goodspeed 0f2882ec95 Suppress a specific unused-var warning on Posix platforms. 2012-02-13 09:41:50 -05:00
Nat Goodspeed 6da3f0907c Automated merge with ssh://hg.lindenlab.com/nat/viewer-new-apr 2012-02-12 21:59:51 -05:00
Nat Goodspeed 8804fa524c Update viewer to official builds of http://hg.secondlife.com/3p-apr. 2012-02-11 06:16:39 -05:00
Nat Goodspeed acd46062fd Eliminate ManifestError for wildcards matching 0 files.
Turns out that some (many?) wildcard LLManifest.path(wildcard) calls are "just
in case": sweep up any (e.g.) "*.tga" files there may be, but no problem if
there are none.
Change path() logic so it tries the next tree (source, artwork, build) if
either a specific (non-wildcard) filename doesn't exist, as now, OR if a
wildcard matches 0 files in the current tree. This continues to support "just
in case" wildcards, while permitting wildcards to work in the artwork and
build trees as well as the source tree.
Use a more specific exception than ManifestError for missing file. Only in
that case should we try the next tree. Any other ManifestError should
propagate.
2012-02-10 16:45:18 -05:00
Nat Goodspeed 9011b04496 Try using Log's new APR packages for Windows, Mac, Linux.
This APR merges work from Huseby, Log, Leslie, Nat.
2012-02-10 12:11:18 -05:00
Nat Goodspeed 4849173fd8 Merge daggy fix in rev a05866ebfea2 (Linux lib wildcards) 2012-02-10 12:06:01 -05:00
Nat Goodspeed 028a05e794 Use wildcards instead of many version-specific lib names on Linux.
viewer_manifest.py's Linux_i686Manifest class has contained directives to copy
library files with names like (e.g.) "libapr-1.so.0.4.2", which means that
every update to any such library requires messing with viewer_manifest.py.
But LLManifest.path() claims to support wildcards, and it's more robust to
specify "libapr-1.so*" instead.
Unfortunately LLManifest.path()'s wildcard support only used to work for files
in the source tree (vs. the artwork tree or the build tree). The logic in
path() tries each tree in turn, relying on an exception to make it try the
next tree. This exception was raised for a nonexistent specific filename --
but it never used to raise that exception for a wildcard matching 0 files.
Instead it would simply report "0 files" and proceed, producing an invalid
viewer install.
Raise that exception for a wildcard matching nothing. This forces path() to
consider the artwork tree and the build tree, permitting us to use wildcards
in library names.
Define an exception specific to LLManifest: ManifestException rather than the
generic Python RuntimeException. Make it a subclass of RuntimeException so any
existing callers expecting to catch RuntimeException will continue to work.
2012-02-10 12:04:27 -05:00
Nat Goodspeed 90a1b67cc4 Remove LLJob class: apr_procattr_autokill_set() should now handle.
LLJob was vestigial code from before migrating Job Object support into APR.
Also add APR signal-name string to getStatusString() output.
2012-02-09 15:22:24 -05:00
Nat Goodspeed 58348bd862 Use newer (Linden extension) TC APR builds for Windows, Mac. 2012-02-09 15:07:02 -05:00
Nat Goodspeed 2d360cb08d Use new 3p-apr package builds for Windows, Mac.
On Linux, new (Feb 2012) APR package produces link errors. Until those are
resolved, leave Linux viewer build with older (Feb 2011) APR package.
2012-02-09 07:44:23 -05:00
Nat Goodspeed 2681d5403c Automated merge with file:C%3A%5CUsers%5CNat%5Clinden%5Cviewer-tut-fix 2012-02-07 14:31:27 -05:00
Nat Goodspeed 33a42b32ca Disable MSVC warning C4702 (unreachable code) in Boost headers. 2012-02-07 13:06:38 -05:00