[Discuss] Run a command with retries
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Fri Mar 19 12:22:42 PDT 2010
On 2010-03-19 11:46-0700 p.willis at telus.net wrote:
> Quoting Steven Kurylo <sk at infinitepigeons.org>:
>
>>
>> You're asking to much of wget. If there was a DNS error, or network
>> error, wget would do the right thing.
>>
>> wget fetches pages and thats it. You then need to use a tool which
>> checks the returned html. From an html validator to custom parsing
>> code, depending on what you need.
>>
>>
>
>
> Yes, I agree.
> I already use scripts to do as you described in your examples.
>
> But, how can I do this generically so that I can apply
> some higher level output filtering to a number of different
> programs without having to rewrite the script each time?
>
> Can I make those high level tests inside a generic
> wrapper that provides a PASS/FAIL result?
>
> I guess the short answer is that I need to make
> that tool myself.
Yes, but all you need to do is to generalize Steve's script (or yours) for
this task. I am thinking along the lines of a bash function where you pass
it the application you are going to test, the stdin file (if needed) to run
the application, the options (if needed) to run the application, and a
string to look for in the stdout and stderr generated by the application
which marks that test as a failure. Then call that function in a loop
that runs through all your tests.
This is slightly off topic, but I should mention that CMake is probably a
better tool than bash for setting up test suites. Currently, I am using
CMake to put together an extended test suite for FreeEOS where I just have a
single application (free_eos_test) which is run in a large number of
different ways depending on the stdin file that is used. So I have a CMake
foreach loop that configures a different stdin file for each of the tests I
want to run and which sets up a make target with correct dependencies (on
the configured file and also on the free_eos_test application) for each of
those tests. I also configure an overall comprehensive_test target which
depends on all of these tests configured in the foreach loop.
Thus after cmake is run to configure the Makefiles, any FreeEOS user will be
able to run
make -j4 comprehensive_test
with the result that automatic comprehensive testing of FreeEOS is done with
a large number of specific tests (in parallel for speed on multiprocessor
hardware) on their platform.
Of course, this is just one specific example, and you could also easily use
CMake this way for your use case where you change the application, stdin
file (configured or not), options, and error phrase to look for for each
iteration of the foreach loop.
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
More information about the Discuss
mailing list