exercise.sh
2599b316
 #!/usr/bin/env bash
 
27e32699
 # **exercise.sh**
 
 # Keep track of the current devstack directory.
 TOP_DIR=$(cd $(dirname "$0") && pwd)
 
05530caf
 # Import common functions
 source $TOP_DIR/functions
 
27e32699
 # Load local configuration
 source $TOP_DIR/stackrc
 
2599b316
 # Run everything in the exercises/ directory that isn't explicitly disabled
 
 # comma separated list of script basenames to skip
 # to refrain from exercising euca.sh use SKIP_EXERCISES=euca
 SKIP_EXERCISES=${SKIP_EXERCISES:-""}
 
9e9132dd
 # Locate the scripts we should run
2599b316
 EXERCISE_DIR=$(dirname "$0")/exercises
0367cf15
 basenames=$(for b in `ls $EXERCISE_DIR/*.sh`; do basename $b .sh; done)
2599b316
 
9e9132dd
 # Track the state of each script
 passes=""
 failures=""
 skips=""
 
 # Loop over each possible script (by basename)
0367cf15
 for script in $basenames; do
2599b316
     if [[ "$SKIP_EXERCISES" =~ $script ]] ; then
9e9132dd
         skips="$skips $script"
2599b316
     else
27e32699
         echo "====================================================================="
2599b316
         echo Running $script
27e32699
         echo "====================================================================="
9e9132dd
         $EXERCISE_DIR/$script.sh
408b009c
         exitcode=$?
         if [[ $exitcode == 55 ]]; then
             skips="$skips $script"
         elif [[ $exitcode -ne 0 ]] ; then
9e9132dd
             failures="$failures $script"
2599b316
         else
9e9132dd
             passes="$passes $script"
2599b316
         fi
     fi
 done
9e9132dd
 
 # output status of exercise run
27e32699
 echo "====================================================================="
0367cf15
 for script in $skips; do
9e9132dd
     echo SKIP $script
 done
0367cf15
 for script in $passes; do
9e9132dd
     echo PASS $script
 done
0367cf15
 for script in $failures; do
9e9132dd
     echo FAILED $script
 done
27e32699
 echo "====================================================================="
c639ef01
 
 if [ -n "$failures" ] ; then
     exit 1
 fi