From Tyson Key:
[obnox/wireshark/wip.git] / test / suite-unittests.sh
1 #!/bin/bash
2 #
3 # Run the epan unit tests
4 #
5 # $Id$
6 #
7 # Wireshark - Network traffic analyzer
8 # By Gerald Combs <gerald@wireshark.org>
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License
12 # as published by the Free Software Foundation; either version 2
13 # of the License, or (at your option) any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23
24
25 if [ "$WS_SYSTEM" == "Windows" ] ; then
26         MAKE="nmake -f Makefile.nmake"
27 else
28         MAKE=make
29 fi
30
31 unittests_step_test() {
32         ( cd `dirname $DUT` && $MAKE `basename $DUT` ) >testout.txt 2>&1
33         if [ $? -ne 0 ]; then
34                 echo
35                 cat ./testout.txt
36                 test_step_failed "make $DUT failed"
37                 return
38         fi
39
40     # if we're on windows, we have to copy the test exe to the wireshark-gtk2
41     # dir before we can use them.
42     # {Note that 'INSTALL_DIR' must be a Windows Pathname)
43         if [ "$WS_SYSTEM" == "Windows" ] ; then
44                 (cd `dirname $DUT` && $MAKE `basename $DUT`_install INSTALL_DIR='..\wireshark-gtk2') > testout.txt 2>&1
45                 if [ $? -ne 0 ]; then 
46                         echo
47                         cat ./testout.txt
48                         test_step_failed "install $DUT failed"
49                         return
50                 fi
51                 DUT=../wireshark-gtk2/`basename $DUT`
52         fi
53
54         $DUT > testout.txt 2>&1
55         RETURNVALUE=$?
56         if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
57                 echo
58                 cat ./testout.txt
59                 test_step_failed "exit status of $DUT: $RETURNVALUE"
60                 return
61         fi
62         test_step_ok
63 }
64
65
66 unittests_step_exntest() {
67         DUT=../epan/exntest
68         unittests_step_test
69 }
70
71 unittests_step_reassemble_test() {
72         DUT=../epan/reassemble_test
73         unittests_step_test
74 }
75
76 unittests_step_tvbtest() {
77         DUT=../epan/tvbtest
78         unittests_step_test
79 }
80
81 unittests_cleanup_step() {
82         rm -f ./testout.txt
83 }
84
85 unittests_suite() {
86         test_step_set_pre unittests_cleanup_step
87         test_step_set_post unittests_cleanup_step
88         test_step_add "exntest" unittests_step_exntest
89         test_step_add "reassemble_test" unittests_step_reassemble_test
90         test_step_add "tvbtest" unittests_step_tvbtest
91 }