(set -e; while true; do TEST_COMMAND; done) | tee log

Reproduce test failure by running the test in loop

If you need to fix a randomly failing test (race condition), you need to run it until you get that hard-to-reproduce failure.
Sample Output
Test run starting...
...
SUCCESS
Test run starting...
...
FAILURE

-3
By: wipu
2011-09-06 12:29:11

These Might Interest You

  • Given a GNU Make file version 3.81 with the following entries: .PHONY: runtest runtest: $(ARCHNAME) $(TESTAUTOEXES) @for i in $(TESTAUTOEXES) ; do \ echo ">>>> Running test harness $$i" ; \ env $(RUNTESTENV) $$i ; done .PHONY: runtestsingle runtestsingle: $(ARCHNAME)/test/auto_$(testsingle).exe $(ARCHNAME) @for i in $< ; do \ echo ">>>> Running test harness $$i" ; \ env $(RUNTESTENV) $$i ; done (ARCHNAME is something like ix86-linux-gnu) Instead of typing gmake runtest to run all the tests, you can run one specific test with the example command. The sample output is from compiling a C++ program using Boost::Test testing framework. Show Sample Output


    -1
    gmake runtestsingle testsingle=udtime
    piyo · 2009-02-13 16:53:26 0
  • Test whether real-time virus detection is working by running this command and checking for eicar.com in /tmp. Requires real-time scanning to be enabled and active on the /tmp directory. If scanning is active, the file should be quarantined/deleted (depending on your settings) moments after running this command. If not, the (harmless) test file should remain in your /tmp directory.


    1
    echo 'K5B!C%@NC[4\CMK54(C^)7PP)7}$RVPNE-FGNAQNEQ-NAGVIVEHF-GRFG-SVYR!$U+U*' | tr '[A-Za-z]' '[N-ZA-Mn-za-m]' > /tmp/eicar.com
    cyberscribe · 2010-08-13 21:39:35 1
  • Useful tool to test if all speaker channels are working properly. speaker-test is part of alsa-utils package Show Sample Output


    5
    speaker-test -D plug:surround51 -c 6 -l 1 -t wav
    alperyilmaz · 2009-11-05 02:57:46 0

  • 2
    NAME=$(nslookup $IP | sed -n 's/.*arpa.*name = \(.*\)/\1/p'); test -z "$NAME" && NAME="NO_NAME"; echo "$NAME"
    morlockhq · 2009-02-05 15:21:22 0
  • Oddly, the isatty(3) glibc C call doesn't have a direct analogue as a command 'isatty(1)'. All is not lost as you can use test(1). For example, your script might be run from a tty or from a GUI menu item but it needs to get user-input or give feedback. Now your script can test STDIN with 'isatty 0' or STDOUT with 'isatty 1' and use xmessage(1) if the tty is not available. The other way to test for this is with 'tty -s' - but that's only for STDIN.


    3
    isatty(){ test -t $1; }
    bhepple · 2010-01-06 06:50:01 0

  • 0
    vim test.c && gcc -x c -o a.out test.c && ./a.out && rm a.out test.c
    ari2015 · 2013-09-08 15:09:09 0

What Others Think

First, read this http://mywiki.wooledge.org/BashFAQ/105 Second, while TEST_command;do ...;done
RanyAlbeg · 349 weeks and 6 days ago
RanyAlbeg, thanks. Your version is of course much better than mine. Even obvious, and I feel stupid for missing that :) And great analysis of set -e. But it's still better than nothing so I keep on using -eu in my scripts(As hinted in http://www.commandlinefu.com/commands/view/5296/robust-expansion-i.e.-crash-of-bash-variables-with-a-typo)
wipu · 349 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: