Expose confdb write to the library.
[openais.git] / test / testmake.sh
blobb51767650369832b1dd97e588621396323ab0b31
1 #!/bin/sh
3 # author: Angus Salkeld (ahsalkeld@gmail.com)
5 # usage:
6 # run this from the base directory of openais
10 SRCDIR=$(pwd)
11 ALL_TESTS="1 2 3 4"
13 MAKE_LOG=/tmp/openais-make-test.log
15 test_1()
17 TEST="[1] simple make"
18 rm -f $SRCDIR/make_o_path
19 make >$MAKE_LOG 2>&1
20 return $?
23 make_clean()
25 if [ -f $SRCDIR/make_o_path ]
26 then
27 make $(cat $SRCDIR/make_o_path) clean >$MAKE_LOG 2>&1
28 RES=$?
29 else
30 if [ -n "$BUILD_DIR" ]
31 then
32 pushd $BUILD_DIR >/dev/null
33 make -f $SRCDIR/Makefile clean >$MAKE_LOG 2>&1
34 RES=$?
35 popd >/dev/null
36 else
37 make clean >$MAKE_LOG 2>&1
38 RES=$?
42 return $RES
45 test_2()
47 rm -f $SRCDIR/make_o_path
48 TEST="[2] make from exec dir"
49 pushd $SRCDIR/exec >/dev/null
50 make >$MAKE_LOG 2>&1
51 RES=$?
52 popd >/dev/null
53 return $RES
56 test_3()
58 local BUILD_DIR=/tmp/openais-make-test
59 echo "O=$BUILD_DIR" > $SRCDIR/make_o_path
61 TEST="[3] make objects separately from the source"
62 rm -rf $BUILD_DIR
63 make O=$BUILD_DIR >$MAKE_LOG 2>&1
64 unset BUILD_DIR
65 return $?
68 test_4()
70 BUILD_DIR=/tmp/openais-make-test
71 rm -f $SRCDIR/make_o_path
73 TEST="[4] make -f SRCDIR/Makefile from the builddir"
75 rm -rf $BUILD_DIR
76 mkdir -p $BUILD_DIR
78 pushd $BUILD_DIR >/dev/null
79 make -f $SRCDIR/Makefile >$MAKE_LOG 2>&1
80 RES=$?
81 popd >/dev/null
82 return $RES
85 if [ -n "$1" ]
86 then
87 TESTS_TO_RUN=$1
88 else
89 TESTS_TO_RUN=$ALL_TESTS
92 for t in $TESTS_TO_RUN
94 test_$t
95 if [ $? -ne 0 ]
96 then
97 echo "$0 $TEST [failed]."
98 cat $MAKE_LOG
99 exit 1
100 else
101 echo "$0 $TEST [passed]."
103 make_clean
104 if [ $? -ne 0 ]
105 then
106 echo "$0 $TEST [failed to clean]."
107 cat $MAKE_LOG
108 exit 1
109 else
110 echo "$0 $TEST [cleaned]."
112 done
114 echo $0 all make tests passed!
115 exit 0