Add OID unit tests. Bug 9294 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id...
[metze/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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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=$SOURCE_DIR/wireshark-gtk2/`basename $DUT`
52         fi
53
54         $DUT $ARGS > 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=$SOURCE_DIR/epan/exntest
68         ARGS=
69         unittests_step_test
70 }
71
72 unittests_step_oids_test() {
73         DUT=$SOURCE_DIR/epan/oids_test
74         ARGS=
75         unittests_step_test
76 }
77
78 unittests_step_reassemble_test() {
79         DUT=$SOURCE_DIR/epan/reassemble_test
80         ARGS=
81         unittests_step_test
82 }
83
84 unittests_step_tvbtest() {
85         DUT=$SOURCE_DIR/epan/tvbtest
86         ARGS=
87         unittests_step_test
88 }
89
90 unittests_step_wmem_test() {
91         DUT=$SOURCE_DIR/epan/wmem/wmem_test
92         ARGS=--verbose
93         unittests_step_test
94 }
95
96 unittests_cleanup_step() {
97         rm -f ./testout.txt
98 }
99
100 unittests_suite() {
101         test_step_set_pre unittests_cleanup_step
102         test_step_set_post unittests_cleanup_step
103         test_step_add "exntest" unittests_step_exntest
104         test_step_add "oids_test" unittests_step_oids_test
105         test_step_add "reassemble_test" unittests_step_reassemble_test
106         test_step_add "tvbtest" unittests_step_tvbtest
107         test_step_add "wmem_test" unittests_step_wmem_test
108 }
109 #
110 # Editor modelines  -  http://www.wireshark.org/tools/modelines.html
111 #
112 # Local variables:
113 # c-basic-offset: 8
114 # tab-width: 8
115 # indent-tabs-mode: t
116 # End:
117 #
118 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
119 # :indentSize=8:tabSize=8:noTabs=false:
120 #