blob: 435cc3a58bf9955ce3a7fff8d203a9d05d6057e6 [file] [log] [blame]
Sean Dague53753292014-12-04 19:38:15 -05001#!/usr/bin/env bash
2
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# 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# we always start with no errors
16ERROR=0
17FAILED_FUNCS=""
18
19function assert_equal {
20 local lineno=`caller 0 | awk '{print $1}'`
21 local function=`caller 0 | awk '{print $2}'`
22 local msg=$3
23 if [[ "$1" != "$2" ]]; then
24 FAILED_FUNCS+="$function:L$lineno\n"
25 echo "ERROR: $1 != $2 in $function:L$lineno!"
26 echo " $msg"
27 ERROR=1
28 else
29 echo "$function:L$lineno - ok"
30 fi
31}
32
33function report_results {
34 if [[ $ERROR -eq 1 ]]; then
35 echo "Tests FAILED"
36 echo $FAILED_FUNCS
37 exit 1
38 fi
39}