tests: avoid bash in shebang and fix wrong "==" in test
[ddiss/samba.git] / lib / subunit / shell / tests / test_source_library.sh
1 #!/bin/sh
2 #  subunit shell bindings.
3 #  Copyright (C) 2006  Robert Collins <robertc@robertcollins.net>
4 #
5 #  Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
6 #  license at the users choice. A copy of both licenses are available in the
7 #  project source as Apache-2.0 and BSD. You may not use this file except in
8 #  compliance with one of these two licences.
9 #  
10 #  Unless required by applicable law or agreed to in writing, software
11 #  distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
12 #  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
13 #  license you chose for the specific language governing permissions and
14 #  limitations under that license.
15 #
16
17
18 # this script tests that we can source the subunit shell bindings successfully.
19 # It manually implements the control protocol so that it des not depend on the
20 # bindings being complete yet.
21
22 # we expect to be run from the tree root.
23
24 echo 'test: shell bindings can be sourced'
25 # if any output occurs, this has failed to source cleanly
26 source_output=$(. ${SHELL_SHARE}subunit.sh 2>&1)
27 if [ $? -eq 0 -a "x$source_output" = "x" ]; then
28   echo 'success: shell bindings can be sourced'
29 else
30   echo 'failure: shell bindings can be sourced ['
31   echo 'got an error code or output during sourcing.:'
32   echo $source_output
33   echo ']' ;
34 fi
35
36 # now source it for real
37 . ${SHELL_SHARE}subunit.sh
38
39 # we should have a start_test function
40 echo 'test: subunit_start_test exists'
41 found_type=$(type -t subunit_start_test)
42 status=$?
43 if [ $status -eq 0 -a "x$found_type" = "xfunction" ]; then
44   echo 'success: subunit_start_test exists'
45 else
46   echo 'failure: subunit_start_test exists ['
47   echo 'subunit_start_test is not a function:'
48   echo "type -t status: $status"
49   echo "output: $found_type"
50   echo ']' ;
51 fi
52
53 # we should have a pass_test function
54 echo 'test: subunit_pass_test exists'
55 found_type=$(type -t subunit_pass_test)
56 status=$?
57 if [ $status -eq 0 -a "x$found_type" = "xfunction" ]; then
58   echo 'success: subunit_pass_test exists'
59 else
60   echo 'failure: subunit_pass_test exists ['
61   echo 'subunit_pass_test is not a function:'
62   echo "type -t status: $status"
63   echo "output: $found_type"
64   echo ']' ;
65 fi
66
67 # we should have a fail_test function
68 echo 'test: subunit_fail_test exists'
69 found_type=$(type -t subunit_fail_test)
70 status=$?
71 if [ $status -eq 0 -a "x$found_type" = "xfunction" ]; then
72   echo 'success: subunit_fail_test exists'
73 else
74   echo 'failure: subunit_fail_test exists ['
75   echo 'subunit_fail_test is not a function:'
76   echo "type -t status: $status"
77   echo "output: $found_type"
78   echo ']' ;
79 fi
80
81 # we should have a error_test function
82 echo 'test: subunit_error_test exists'
83 found_type=$(type -t subunit_error_test)
84 status=$?
85 if [ $status -eq 0 -a "x$found_type" = "xfunction" ]; then
86   echo 'success: subunit_error_test exists'
87 else
88   echo 'failure: subunit_error_test exists ['
89   echo 'subunit_error_test is not a function:'
90   echo "type -t status: $status"
91   echo "output: $found_type"
92   echo ']' ;
93 fi
94
95 # we should have a skip_test function
96 echo 'test: subunit_skip_test exists'
97 found_type=$(type -t subunit_skip_test)
98 status=$?
99 if [ $status -eq 0 -a "x$found_type" = "xfunction" ]; then
100   echo 'success: subunit_skip_test exists'
101 else
102   echo 'failure: subunit_skip_test exists ['
103   echo 'subunit_skip_test is not a function:'
104   echo "type -t status: $status"
105   echo "output: $found_type"
106   echo ']' ;
107 fi
108