blob: b1aef4f81f36524ff748c653f54ab98f420928f9 [file] [log] [blame]
Sean Daguee0f40652013-10-14 17:46:51 -04001#!/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 Troyerd401c842014-03-21 11:48:01 -050018PASSES=""
19FAILURES=""
20
21# Check the return code and add the test to PASSES or FAILURES as appropriate
22# pass_fail <result> <expected> <name>
23function 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 Daguee0f40652013-10-14 17:46:51 -040035if [[ -n $@ ]]; then
36 FILES=$@
37else
38 LIBS=`find lib -type f | grep -v \.md`
39 SCRIPTS=`find . -type f -name \*\.sh`
Ian Wienand09bb9e62014-02-21 14:33:29 +110040 EXTRA="functions functions-common stackrc openrc exerciserc eucarc"
Sean Daguee0f40652013-10-14 17:46:51 -040041 FILES="$SCRIPTS $LIBS $EXTRA"
42fi
43
44echo "Running bash8..."
45
Sean Dagueb93ee252014-02-23 20:41:07 -050046./tools/bash8.py -v $FILES
Dean Troyerd401c842014-03-21 11:48:01 -050047pass_fail $? 0 bash8
Sean Daguef5d2a5c2014-03-06 13:45:42 -050048
49
50# Test that no one is trying to land crazy refs as branches
51
52echo "Ensuring we don't have crazy refs"
53
54REFS=`grep BRANCH stackrc | grep -v -- '-master'`
55rc=$?
Dean Troyerd401c842014-03-21 11:48:01 -050056pass_fail $rc 1 crazy-refs
Sean Daguef5d2a5c2014-03-06 13:45:42 -050057if [[ $rc -eq 0 ]]; then
58 echo "Branch defaults must be master. Found:"
59 echo $REFS
Dean Troyerd401c842014-03-21 11:48:01 -050060fi
61
62echo "====================================================================="
63for script in $PASSES; do
64 echo PASS $script
65done
66for script in $FAILURES; do
67 echo FAILED $script
68done
69echo "====================================================================="
70
71if [[ -n "$FAILURES" ]]; then
Sean Daguef5d2a5c2014-03-06 13:45:42 -050072 exit 1
73fi