15
2
Background:
I am writing a test script for a piece of computational biology software. The software I am testing can take days or even weeks to run, so it has a recover functionality built in, in the case of system crashes or power failures.
I am trying to figure out how to test the recovery system. Specifically, I can't figure out a way to "crash" the program in a controlled manner. I was thinking of somehow timing a SIGKILL instruction to run after some amount of time. This is probably not ideal, as the test case isn't guaranteed to run the same speed every time (it runs in a shared environment), so comparing the logs to desired output would be difficult.
This software DOES print a line for each section of analysis it completes.
Question:
I was wondering if there was a good/elegant way (in a shell script) to capture output from a program and then kill the program when a given line/# of lines is output by the program?
1
Possible duplicate of "watch" the output of a command until a particular string is observed and then exit
– Ciro Santilli 新疆改造中心法轮功六四事件 – 2018-04-17T22:08:27.1631Why do you need to stop the program at a specific time? Due to output buffering you may end up killing the program a long time after it outputs the text you are checking for. – stardt – 2012-03-20T20:33:25.347
@stardt I wanted to stop the program at a specific time so that test results were more controlled and reproducible. I have found a way around this now. I will kill the program only once manually, then test only the recovery code. All recovery attempts will start from the same point. I am testing how it recovers, not how it crashes after all :) – Paul – 2012-03-21T17:21:00.150