Overview¶
This project provides a few Bash scripts to perform automated tests.Main features are:
- Transparently run tests under Valgrind
- Kills buggy tests after a certain timeout
- Generic
- Easy to use
- Easy to modify
Installation¶
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.
Documentation¶
Checking simple commands:¶
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 10Where arguments to the ldstest_check are:
- The description of the test
- The timeout of the test
- The command to run
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 "$@"
Checking C code:¶
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.shWhere arguments to the ldstest_check are:
- The timeouts when running the test normally, the under valgrind, then under helgrind
- The description of the test
- The command to run
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
Other options¶
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 |