| 1 | # test/byo-server-lib.sh
 | 
| 2 | #
 | 
| 3 | # Usage:
 | 
| 4 | #   source test/byo-server-lib.sh
 | 
| 5 | #
 | 
| 6 | # The client creates a clean process state and directory state for each tests.
 | 
| 7 | 
 | 
| 8 | byo-maybe-main() {
 | 
| 9 |   if test -n "${BYO_LIST_TESTS:-}"; then
 | 
| 10 |     # bash extension that OSH also implements
 | 
| 11 |     compgen -A function | grep '^test-'
 | 
| 12 |     exit 0
 | 
| 13 |   fi
 | 
| 14 | 
 | 
| 15 |   local test_name=${BYO_TEST_NAME:-}
 | 
| 16 |   if test -n "$test_name"; then
 | 
| 17 |     # Shell convention: we name functions test-*
 | 
| 18 |     $test_name
 | 
| 19 | 
 | 
| 20 |     # Only run if not set -e.  Either way it's equivalent
 | 
| 21 |     exit $?
 | 
| 22 |   fi
 | 
| 23 | 
 | 
| 24 |   # Do nothing if none of those variables is set.
 | 
| 25 |   # The program continues to its "main".
 | 
| 26 | }
 |