blob: a0349ce46975b7a4a6287871511cf2794a1f2e2b [file] [log] [blame]
Todd Willey2599b312011-11-04 10:31:37 -04001#!/usr/bin/env bash
2
Dean Troyer27e32692012-03-16 16:16:56 -05003# **exercise.sh**
4
5# Keep track of the current devstack directory.
6TOP_DIR=$(cd $(dirname "$0") && pwd)
7
Dean Troyer05530ca2012-07-06 15:09:10 -05008# Import common functions
9source $TOP_DIR/functions
10
Dean Troyer27e32692012-03-16 16:16:56 -050011# Load local configuration
12source $TOP_DIR/stackrc
13
Todd Willey2599b312011-11-04 10:31:37 -040014# Run everything in the exercises/ directory that isn't explicitly disabled
15
16# comma separated list of script basenames to skip
17# to refrain from exercising euca.sh use SKIP_EXERCISES=euca
18SKIP_EXERCISES=${SKIP_EXERCISES:-""}
19
Todd Willey9e9132d2011-11-04 12:09:54 -040020# Locate the scripts we should run
Todd Willey2599b312011-11-04 10:31:37 -040021EXERCISE_DIR=$(dirname "$0")/exercises
Todd Willey0367cf12011-11-05 10:46:56 -040022basenames=$(for b in `ls $EXERCISE_DIR/*.sh`; do basename $b .sh; done)
Todd Willey2599b312011-11-04 10:31:37 -040023
Todd Willey9e9132d2011-11-04 12:09:54 -040024# Track the state of each script
25passes=""
26failures=""
27skips=""
28
29# Loop over each possible script (by basename)
Todd Willey0367cf12011-11-05 10:46:56 -040030for script in $basenames; do
Todd Willey2599b312011-11-04 10:31:37 -040031 if [[ "$SKIP_EXERCISES" =~ $script ]] ; then
Todd Willey9e9132d2011-11-04 12:09:54 -040032 skips="$skips $script"
Todd Willey2599b312011-11-04 10:31:37 -040033 else
Dean Troyer27e32692012-03-16 16:16:56 -050034 echo "====================================================================="
Todd Willey2599b312011-11-04 10:31:37 -040035 echo Running $script
Dean Troyer27e32692012-03-16 16:16:56 -050036 echo "====================================================================="
Todd Willey9e9132d2011-11-04 12:09:54 -040037 $EXERCISE_DIR/$script.sh
Chmouel Boudjnah408b0092012-03-15 23:21:55 +000038 exitcode=$?
39 if [[ $exitcode == 55 ]]; then
40 skips="$skips $script"
41 elif [[ $exitcode -ne 0 ]] ; then
Todd Willey9e9132d2011-11-04 12:09:54 -040042 failures="$failures $script"
Todd Willey2599b312011-11-04 10:31:37 -040043 else
Todd Willey9e9132d2011-11-04 12:09:54 -040044 passes="$passes $script"
Todd Willey2599b312011-11-04 10:31:37 -040045 fi
46 fi
47done
Todd Willey9e9132d2011-11-04 12:09:54 -040048
49# output status of exercise run
Dean Troyer27e32692012-03-16 16:16:56 -050050echo "====================================================================="
Todd Willey0367cf12011-11-05 10:46:56 -040051for script in $skips; do
Todd Willey9e9132d2011-11-04 12:09:54 -040052 echo SKIP $script
53done
Todd Willey0367cf12011-11-05 10:46:56 -040054for script in $passes; do
Todd Willey9e9132d2011-11-04 12:09:54 -040055 echo PASS $script
56done
Todd Willey0367cf12011-11-05 10:46:56 -040057for script in $failures; do
Todd Willey9e9132d2011-11-04 12:09:54 -040058 echo FAILED $script
59done
Dean Troyer27e32692012-03-16 16:16:56 -050060echo "====================================================================="
James E. Blairc639ef02011-11-10 15:11:28 -080061
62if [ -n "$failures" ] ; then
63 exit 1
64fi