| Sean Dague | e0f4065 | 2013-10-14 17:46:51 -0400 | [diff] [blame] | 1 | #!/bin/bash | 
|  | 2 | # | 
|  | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 4 | # you may not use this file except in compliance with the License. | 
|  | 5 | # You may obtain a copy of the License at | 
|  | 6 | # | 
|  | 7 | #    http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 8 | # | 
|  | 9 | # Unless required by applicable law or agreed to in writing, software | 
|  | 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 
|  | 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | 
|  | 12 | # License for the specific language governing permissions and limitations | 
|  | 13 | # under the License. | 
|  | 14 | # | 
|  | 15 | # | 
|  | 16 | # this runs a series of unit tests for devstack to ensure it's functioning | 
|  | 17 |  | 
| Dean Troyer | d401c84 | 2014-03-21 11:48:01 -0500 | [diff] [blame] | 18 | PASSES="" | 
|  | 19 | FAILURES="" | 
|  | 20 |  | 
|  | 21 | # Check the return code and add the test to PASSES or FAILURES as appropriate | 
|  | 22 | # pass_fail <result> <expected> <name> | 
|  | 23 | function pass_fail { | 
|  | 24 | local result=$1 | 
|  | 25 | local expected=$2 | 
|  | 26 | local test_name=$3 | 
|  | 27 |  | 
|  | 28 | if [[ $result -ne $expected ]]; then | 
|  | 29 | FAILURES="$FAILURES $test_name" | 
|  | 30 | else | 
|  | 31 | PASSES="$PASSES $test_name" | 
|  | 32 | fi | 
|  | 33 | } | 
|  | 34 |  | 
| Sean Dague | e0f4065 | 2013-10-14 17:46:51 -0400 | [diff] [blame] | 35 | if [[ -n $@ ]]; then | 
|  | 36 | FILES=$@ | 
|  | 37 | else | 
|  | 38 | LIBS=`find lib -type f | grep -v \.md` | 
|  | 39 | SCRIPTS=`find . -type f -name \*\.sh` | 
| Ian Wienand | 09bb9e6 | 2014-02-21 14:33:29 +1100 | [diff] [blame] | 40 | EXTRA="functions functions-common stackrc openrc exerciserc eucarc" | 
| Sean Dague | e0f4065 | 2013-10-14 17:46:51 -0400 | [diff] [blame] | 41 | FILES="$SCRIPTS $LIBS $EXTRA" | 
|  | 42 | fi | 
|  | 43 |  | 
|  | 44 | echo "Running bash8..." | 
|  | 45 |  | 
| Sean Dague | b93ee25 | 2014-02-23 20:41:07 -0500 | [diff] [blame] | 46 | ./tools/bash8.py -v $FILES | 
| Dean Troyer | d401c84 | 2014-03-21 11:48:01 -0500 | [diff] [blame] | 47 | pass_fail $? 0 bash8 | 
| Sean Dague | f5d2a5c | 2014-03-06 13:45:42 -0500 | [diff] [blame] | 48 |  | 
|  | 49 |  | 
|  | 50 | # Test that no one is trying to land crazy refs as branches | 
|  | 51 |  | 
|  | 52 | echo "Ensuring we don't have crazy refs" | 
|  | 53 |  | 
|  | 54 | REFS=`grep BRANCH stackrc | grep -v -- '-master'` | 
|  | 55 | rc=$? | 
| Dean Troyer | d401c84 | 2014-03-21 11:48:01 -0500 | [diff] [blame] | 56 | pass_fail $rc 1 crazy-refs | 
| Sean Dague | f5d2a5c | 2014-03-06 13:45:42 -0500 | [diff] [blame] | 57 | if [[ $rc -eq 0 ]]; then | 
|  | 58 | echo "Branch defaults must be master. Found:" | 
|  | 59 | echo $REFS | 
| Dean Troyer | d401c84 | 2014-03-21 11:48:01 -0500 | [diff] [blame] | 60 | fi | 
|  | 61 |  | 
|  | 62 | echo "=====================================================================" | 
|  | 63 | for script in $PASSES; do | 
|  | 64 | echo PASS $script | 
|  | 65 | done | 
|  | 66 | for script in $FAILURES; do | 
|  | 67 | echo FAILED $script | 
|  | 68 | done | 
|  | 69 | echo "=====================================================================" | 
|  | 70 |  | 
|  | 71 | if [[ -n "$FAILURES" ]]; then | 
| Sean Dague | f5d2a5c | 2014-03-06 13:45:42 -0500 | [diff] [blame] | 72 | exit 1 | 
|  | 73 | fi |