This project provides a few Bash scripts to perform automated tests. Main features are:
You can see it in action in the tests performed here:
You can either checkout the git repository:
git clone git://piggledy.org/ldstest.git
Or install it using the available Gentoo overlay, by emerging the ebuild dev-util/ldstest.
When writing test scripts, you mainly want to have an overview of what test was successful and which test was a failure. In order to do that you would use the script ldstest_check like this:
ldstest_check "Testing: ls /" 5 ls / ldstest_check "Testing: touch /" 5 touch / ldstest_check "Testing: sleep 10" 5 sleep 10
Where arguments to the ldstest_check are:
In case of failure the output of the command is displayed. The previous example would show:
Testing: ls / OK Testing: touch / FAILED touch / touch: setting times of `/': Permission denied Testing: sleep 10 TIMEOUT sleep 10 /home/lds/dev/ldstest/ldstest_check: line 52: 15596 Killed ldstest_log_to_file "$@"
To test C code ldstest provides a ldstest_check_c command to transparently run the test under valgrind. The ldstest_check_c command exports a $STARTER environment variable that provides a helper script that will run the test under Valgrind. To use it:
ldstest_check_c "1 2 3" "Testing echo output" ./test_echo_output.sh
Where arguments to the ldstest_check are:
The test_echo_output.sh would contain :
#!/bin/bash # Check the output of "echo blah" is really blah if [ $("$STARTER" echo blah) != "blah" ] then echo "Doo!" exit 1 fi
At runtime the $STARTER variable is replaced by the correct, issuing such tests:
Testing echo output OK Valgrind check: Testing echo output OK Helgrind check: Testing echo output OK
Some options can be exported as global variables to modify the behavior of tests:
Variable | Description |
HELGRIND_OPT | Arguments passed to helgrind |
VALGRIND_OPT | Arguments passed to valgrind |
Generated with KisssPM