diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2012-03-13 14:15:11 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2012-03-13 14:15:11 -0400 |
commit | 7d3cf544c7962ae6cc8e0e8b8e8db817e366a9cc (patch) | |
tree | 8ce50f5b84c704c1888f13756e0e7851df2f8de7 /indra/llcommon | |
parent | cf6aabff08d8bc4e38b2b271085978486451eda2 (diff) |
Add timeout functionality to waitfor() helper functions.
Otherwise, a stuck child process could potentially hang the test, and thus the
whole viewer build.
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/tests/llprocess_test.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp index 6103764f24..99186ed434 100644 --- a/indra/llcommon/tests/llprocess_test.cpp +++ b/indra/llcommon/tests/llprocess_test.cpp @@ -101,20 +101,26 @@ void yield(int seconds=1) LLEventPumps::instance().obtain("mainloop").post(LLSD()); } -void waitfor(LLProcess& proc) +void waitfor(LLProcess& proc, int timeout=60) { - while (proc.isRunning()) + int i = 0; + for ( ; i < timeout && proc.isRunning(); ++i) { yield(); } + tut::ensure(STRINGIZE("process took longer than " << timeout << " seconds to terminate"), + i < timeout); } -void waitfor(LLProcess::handle h, const std::string& desc) +void waitfor(LLProcess::handle h, const std::string& desc, int timeout=60) { - while (LLProcess::isRunning(h, desc)) + int i = 0; + for ( ; i < timeout && LLProcess::isRunning(h, desc); ++i) { yield(); } + tut::ensure(STRINGIZE("process took longer than " << timeout << " seconds to terminate"), + i < timeout); } /** |