Browse code

add initial support for unit tests

git-svn: trunk@3710

Tomasz Kojm authored on 2008/03/13 19:44:34
Showing 9 changed files
... ...
@@ -1,3 +1,8 @@
1
+Thu Mar 13 10:50:36 CET 2008 (tk)
2
+---------------------------------
3
+  * unit_tests: add initial support for unit tests; based on a patch by
4
+		Brian Caswell <bmc*sourcefire.com>
5
+
1 6
 Mon Mar 10 19:40:25 CET 2008 (acab)
2 7
 -----------------------------------
3 8
   * libclamav/nsis: unpack broken files too - bb#873
... ...
@@ -17,7 +17,7 @@
17 17
 #  MA 02110-1301, USA.
18 18
 
19 19
 ACLOCAL_AMFLAGS=-I m4
20
-SUBDIRS = libclamunrar libclamunrar_iface libclamav clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter test
20
+SUBDIRS = libclamunrar libclamunrar_iface libclamav clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter test unit_tests
21 21
 EXTRA_DIST = FAQ examples BUGS shared libclamav.pc.in UPGRADE COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.file COPYING.zlib
22 22
 
23 23
 bin_SCRIPTS=clamav-config
... ...
@@ -247,7 +247,7 @@ target_vendor = @target_vendor@
247 247
 top_builddir = @top_builddir@
248 248
 top_srcdir = @top_srcdir@
249 249
 ACLOCAL_AMFLAGS = -I m4
250
-SUBDIRS = libclamunrar libclamunrar_iface libclamav clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter test
250
+SUBDIRS = libclamunrar libclamunrar_iface libclamav clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter test unit_tests
251 251
 EXTRA_DIST = FAQ examples BUGS shared libclamav.pc.in UPGRADE COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.file COPYING.zlib
252 252
 bin_SCRIPTS = clamav-config
253 253
 pkgconfigdir = $(libdir)/pkgconfig
... ...
@@ -108,6 +108,12 @@
108 108
 /* have bzip2 */
109 109
 #undef HAVE_BZLIB_H
110 110
 
111
+/* Enable 'check' unit tests */
112
+#undef HAVE_CHECK
113
+
114
+/* Define to 1 if you have the <check.h> header file. */
115
+#undef HAVE_CHECK_H
116
+
111 117
 /* ancillary data style fd pass */
112 118
 #undef HAVE_CONTROL_IN_MSGHDR
113 119
 
... ...
@@ -159,6 +165,9 @@
159 159
 /* in_port_t is defined */
160 160
 #undef HAVE_IN_PORT_T
161 161
 
162
+/* Define to 1 if you have the `check' library (-lcheck). */
163
+#undef HAVE_LIBCHECK
164
+
162 165
 /* Define if you have the gmp library. */
163 166
 #undef HAVE_LIBGMP
164 167
 
... ...
@@ -1496,6 +1496,7 @@ Optional Features:
1496 1496
   --disable-libtool-lock  avoid locking (might break parallel builds)
1497 1497
   --disable-gcc-vcheck	  do not check for buggy gcc version
1498 1498
   --enable-experimental	enable experimental code
1499
+  --enable-check           Enable 'check' unit tests
1499 1500
   --enable-maintainer-mode enable make rules and dependencies not useful
1500 1501
                           (and sometimes confusing) to the casual installer
1501 1502
   --disable-zlib-vcheck	  do not check for buggy zlib version
... ...
@@ -4764,7 +4765,7 @@ ia64-*-hpux*)
4764 4764
   ;;
4765 4765
 *-*-irix6*)
4766 4766
   # Find out which ABI we are using.
4767
-  echo '#line 4767 "configure"' > conftest.$ac_ext
4767
+  echo '#line 4768 "configure"' > conftest.$ac_ext
4768 4768
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4769 4769
   (eval $ac_compile) 2>&5
4770 4770
   ac_status=$?
... ...
@@ -6854,11 +6855,11 @@ else
6854 6854
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
6855 6855
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
6856 6856
    -e 's:$: $lt_compiler_flag:'`
6857
-   (eval echo "\"\$as_me:6857: $lt_compile\"" >&5)
6857
+   (eval echo "\"\$as_me:6858: $lt_compile\"" >&5)
6858 6858
    (eval "$lt_compile" 2>conftest.err)
6859 6859
    ac_status=$?
6860 6860
    cat conftest.err >&5
6861
-   echo "$as_me:6861: \$? = $ac_status" >&5
6861
+   echo "$as_me:6862: \$? = $ac_status" >&5
6862 6862
    if (exit $ac_status) && test -s "$ac_outfile"; then
6863 6863
      # The compiler can only warn and ignore the option if not recognized
6864 6864
      # So say no if there are warnings other than the usual output.
... ...
@@ -7144,11 +7145,11 @@ else
7144 7144
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7145 7145
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7146 7146
    -e 's:$: $lt_compiler_flag:'`
7147
-   (eval echo "\"\$as_me:7147: $lt_compile\"" >&5)
7147
+   (eval echo "\"\$as_me:7148: $lt_compile\"" >&5)
7148 7148
    (eval "$lt_compile" 2>conftest.err)
7149 7149
    ac_status=$?
7150 7150
    cat conftest.err >&5
7151
-   echo "$as_me:7151: \$? = $ac_status" >&5
7151
+   echo "$as_me:7152: \$? = $ac_status" >&5
7152 7152
    if (exit $ac_status) && test -s "$ac_outfile"; then
7153 7153
      # The compiler can only warn and ignore the option if not recognized
7154 7154
      # So say no if there are warnings other than the usual output.
... ...
@@ -7248,11 +7249,11 @@ else
7248 7248
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7249 7249
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7250 7250
    -e 's:$: $lt_compiler_flag:'`
7251
-   (eval echo "\"\$as_me:7251: $lt_compile\"" >&5)
7251
+   (eval echo "\"\$as_me:7252: $lt_compile\"" >&5)
7252 7252
    (eval "$lt_compile" 2>out/conftest.err)
7253 7253
    ac_status=$?
7254 7254
    cat out/conftest.err >&5
7255
-   echo "$as_me:7255: \$? = $ac_status" >&5
7255
+   echo "$as_me:7256: \$? = $ac_status" >&5
7256 7256
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
7257 7257
    then
7258 7258
      # The compiler can only warn and ignore the option if not recognized
... ...
@@ -9625,7 +9626,7 @@ else
9625 9625
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
9626 9626
   lt_status=$lt_dlunknown
9627 9627
   cat > conftest.$ac_ext <<EOF
9628
-#line 9628 "configure"
9628
+#line 9629 "configure"
9629 9629
 #include "confdefs.h"
9630 9630
 
9631 9631
 #if HAVE_DLFCN_H
... ...
@@ -9725,7 +9726,7 @@ else
9725 9725
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
9726 9726
   lt_status=$lt_dlunknown
9727 9727
   cat > conftest.$ac_ext <<EOF
9728
-#line 9728 "configure"
9728
+#line 9729 "configure"
9729 9729
 #include "confdefs.h"
9730 9730
 
9731 9731
 #if HAVE_DLFCN_H
... ...
@@ -13034,6 +13035,246 @@ _ACEOF
13034 13034
 fi
13035 13035
 
13036 13036
 
13037
+enable_check_ut=no
13038
+# Check whether --enable-check was given.
13039
+if test "${enable_check+set}" = set; then
13040
+  enableval=$enable_check; enable_check_ut=yes
13041
+fi
13042
+
13043
+
13044
+LCHECK=""
13045
+if test "$enable_check_ut" != "no" ; then
13046
+
13047
+cat >>confdefs.h <<\_ACEOF
13048
+#define HAVE_CHECK 1
13049
+_ACEOF
13050
+
13051
+
13052
+for ac_header in check.h
13053
+do
13054
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
13055
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
13056
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
13057
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
13058
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
13059
+  echo $ECHO_N "(cached) $ECHO_C" >&6
13060
+fi
13061
+ac_res=`eval echo '${'$as_ac_Header'}'`
13062
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
13063
+echo "${ECHO_T}$ac_res" >&6; }
13064
+else
13065
+  # Is the header compilable?
13066
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
13067
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
13068
+cat >conftest.$ac_ext <<_ACEOF
13069
+/* confdefs.h.  */
13070
+_ACEOF
13071
+cat confdefs.h >>conftest.$ac_ext
13072
+cat >>conftest.$ac_ext <<_ACEOF
13073
+/* end confdefs.h.  */
13074
+$ac_includes_default
13075
+#include <$ac_header>
13076
+_ACEOF
13077
+rm -f conftest.$ac_objext
13078
+if { (ac_try="$ac_compile"
13079
+case "(($ac_try" in
13080
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13081
+  *) ac_try_echo=$ac_try;;
13082
+esac
13083
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13084
+  (eval "$ac_compile") 2>conftest.er1
13085
+  ac_status=$?
13086
+  grep -v '^ *+' conftest.er1 >conftest.err
13087
+  rm -f conftest.er1
13088
+  cat conftest.err >&5
13089
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
13090
+  (exit $ac_status); } && {
13091
+	 test -z "$ac_c_werror_flag" ||
13092
+	 test ! -s conftest.err
13093
+       } && test -s conftest.$ac_objext; then
13094
+  ac_header_compiler=yes
13095
+else
13096
+  echo "$as_me: failed program was:" >&5
13097
+sed 's/^/| /' conftest.$ac_ext >&5
13098
+
13099
+	ac_header_compiler=no
13100
+fi
13101
+
13102
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13103
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
13104
+echo "${ECHO_T}$ac_header_compiler" >&6; }
13105
+
13106
+# Is the header present?
13107
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
13108
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
13109
+cat >conftest.$ac_ext <<_ACEOF
13110
+/* confdefs.h.  */
13111
+_ACEOF
13112
+cat confdefs.h >>conftest.$ac_ext
13113
+cat >>conftest.$ac_ext <<_ACEOF
13114
+/* end confdefs.h.  */
13115
+#include <$ac_header>
13116
+_ACEOF
13117
+if { (ac_try="$ac_cpp conftest.$ac_ext"
13118
+case "(($ac_try" in
13119
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13120
+  *) ac_try_echo=$ac_try;;
13121
+esac
13122
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13123
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
13124
+  ac_status=$?
13125
+  grep -v '^ *+' conftest.er1 >conftest.err
13126
+  rm -f conftest.er1
13127
+  cat conftest.err >&5
13128
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
13129
+  (exit $ac_status); } >/dev/null && {
13130
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
13131
+	 test ! -s conftest.err
13132
+       }; then
13133
+  ac_header_preproc=yes
13134
+else
13135
+  echo "$as_me: failed program was:" >&5
13136
+sed 's/^/| /' conftest.$ac_ext >&5
13137
+
13138
+  ac_header_preproc=no
13139
+fi
13140
+
13141
+rm -f conftest.err conftest.$ac_ext
13142
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
13143
+echo "${ECHO_T}$ac_header_preproc" >&6; }
13144
+
13145
+# So?  What about this header?
13146
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
13147
+  yes:no: )
13148
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
13149
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
13150
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
13151
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
13152
+    ac_header_preproc=yes
13153
+    ;;
13154
+  no:yes:* )
13155
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
13156
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
13157
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
13158
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
13159
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
13160
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
13161
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
13162
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
13163
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
13164
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
13165
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
13166
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
13167
+    ( cat <<\_ASBOX
13168
+## -------------------------------------- ##
13169
+## Report this to http://bugs.clamav.net/ ##
13170
+## -------------------------------------- ##
13171
+_ASBOX
13172
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
13173
+    ;;
13174
+esac
13175
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
13176
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
13177
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
13178
+  echo $ECHO_N "(cached) $ECHO_C" >&6
13179
+else
13180
+  eval "$as_ac_Header=\$ac_header_preproc"
13181
+fi
13182
+ac_res=`eval echo '${'$as_ac_Header'}'`
13183
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
13184
+echo "${ECHO_T}$ac_res" >&6; }
13185
+
13186
+fi
13187
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
13188
+  cat >>confdefs.h <<_ACEOF
13189
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
13190
+_ACEOF
13191
+
13192
+fi
13193
+
13194
+done
13195
+
13196
+
13197
+{ echo "$as_me:$LINENO: checking for srunner_create in -lcheck" >&5
13198
+echo $ECHO_N "checking for srunner_create in -lcheck... $ECHO_C" >&6; }
13199
+if test "${ac_cv_lib_check_srunner_create+set}" = set; then
13200
+  echo $ECHO_N "(cached) $ECHO_C" >&6
13201
+else
13202
+  ac_check_lib_save_LIBS=$LIBS
13203
+LIBS="-lcheck  $LIBS"
13204
+cat >conftest.$ac_ext <<_ACEOF
13205
+/* confdefs.h.  */
13206
+_ACEOF
13207
+cat confdefs.h >>conftest.$ac_ext
13208
+cat >>conftest.$ac_ext <<_ACEOF
13209
+/* end confdefs.h.  */
13210
+
13211
+/* Override any GCC internal prototype to avoid an error.
13212
+   Use char because int might match the return type of a GCC
13213
+   builtin and then its argument prototype would still apply.  */
13214
+#ifdef __cplusplus
13215
+extern "C"
13216
+#endif
13217
+char srunner_create ();
13218
+int
13219
+main ()
13220
+{
13221
+return srunner_create ();
13222
+  ;
13223
+  return 0;
13224
+}
13225
+_ACEOF
13226
+rm -f conftest.$ac_objext conftest$ac_exeext
13227
+if { (ac_try="$ac_link"
13228
+case "(($ac_try" in
13229
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13230
+  *) ac_try_echo=$ac_try;;
13231
+esac
13232
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13233
+  (eval "$ac_link") 2>conftest.er1
13234
+  ac_status=$?
13235
+  grep -v '^ *+' conftest.er1 >conftest.err
13236
+  rm -f conftest.er1
13237
+  cat conftest.err >&5
13238
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
13239
+  (exit $ac_status); } && {
13240
+	 test -z "$ac_c_werror_flag" ||
13241
+	 test ! -s conftest.err
13242
+       } && test -s conftest$ac_exeext &&
13243
+       $as_test_x conftest$ac_exeext; then
13244
+  ac_cv_lib_check_srunner_create=yes
13245
+else
13246
+  echo "$as_me: failed program was:" >&5
13247
+sed 's/^/| /' conftest.$ac_ext >&5
13248
+
13249
+	ac_cv_lib_check_srunner_create=no
13250
+fi
13251
+
13252
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
13253
+      conftest$ac_exeext conftest.$ac_ext
13254
+LIBS=$ac_check_lib_save_LIBS
13255
+fi
13256
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_check_srunner_create" >&5
13257
+echo "${ECHO_T}$ac_cv_lib_check_srunner_create" >&6; }
13258
+if test $ac_cv_lib_check_srunner_create = yes; then
13259
+  cat >>confdefs.h <<_ACEOF
13260
+#define HAVE_LIBCHECK 1
13261
+_ACEOF
13262
+
13263
+  LIBS="-lcheck $LIBS"
13264
+
13265
+else
13266
+  LCHECK="no"
13267
+fi
13268
+
13269
+fi
13270
+
13271
+if test "$LCHECK" = "no"; then
13272
+    echo
13273
+    echo "   ERROR!  Check was configured, but not found.  Get it from http://check.sf.net/"
13274
+    exit 1
13275
+fi
13276
+
13037 13277
 have_pthreads=no
13038 13278
 if test "${ac_cv_header_pthread_h+set}" = set; then
13039 13279
   { echo "$as_me:$LINENO: checking for pthread.h" >&5
... ...
@@ -18382,7 +18623,7 @@ fi
18382 18382
 { echo "$as_me:$LINENO: result: $have_signed_rightshift_extended" >&5
18383 18383
 echo "${ECHO_T}$have_signed_rightshift_extended" >&6; };
18384 18384
 
18385
-ac_config_files="$ac_config_files libclamunrar/Makefile libclamunrar_iface/Makefile libclamav/Makefile libclamav/lzma/Makefile clamscan/Makefile database/Makefile docs/Makefile clamd/Makefile clamdscan/Makefile clamav-milter/Makefile freshclam/Makefile sigtool/Makefile clamconf/Makefile etc/Makefile test/Makefile Makefile clamav-config libclamav.pc docs/man/clamav-milter.8 docs/man/clamconf.1 docs/man/clamd.8 docs/man/clamd.conf.5 docs/man/clamdscan.1 docs/man/clamscan.1 docs/man/freshclam.1 docs/man/freshclam.conf.5 docs/man/sigtool.1"
18385
+ac_config_files="$ac_config_files libclamunrar/Makefile libclamunrar_iface/Makefile libclamav/Makefile libclamav/lzma/Makefile clamscan/Makefile database/Makefile docs/Makefile clamd/Makefile clamdscan/Makefile clamav-milter/Makefile freshclam/Makefile sigtool/Makefile clamconf/Makefile etc/Makefile test/Makefile unit_tests/Makefile Makefile clamav-config libclamav.pc docs/man/clamav-milter.8 docs/man/clamconf.1 docs/man/clamd.8 docs/man/clamd.conf.5 docs/man/clamdscan.1 docs/man/clamscan.1 docs/man/freshclam.1 docs/man/freshclam.conf.5 docs/man/sigtool.1"
18386 18386
 
18387 18387
 cat >confcache <<\_ACEOF
18388 18388
 # This file is a shell script that caches the results of configure
... ...
@@ -19013,6 +19254,7 @@ do
19013 19013
     "clamconf/Makefile") CONFIG_FILES="$CONFIG_FILES clamconf/Makefile" ;;
19014 19014
     "etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;;
19015 19015
     "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
19016
+    "unit_tests/Makefile") CONFIG_FILES="$CONFIG_FILES unit_tests/Makefile" ;;
19016 19017
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
19017 19018
     "clamav-config") CONFIG_FILES="$CONFIG_FILES clamav-config" ;;
19018 19019
     "libclamav.pc") CONFIG_FILES="$CONFIG_FILES libclamav.pc" ;;
... ...
@@ -314,6 +314,25 @@ AC_CHECK_FUNCS([poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat
314 314
 AC_FUNC_MMAP
315 315
 AC_FUNC_FSEEKO
316 316
 
317
+enable_check_ut=no
318
+AC_ARG_ENABLE(check,
319
+[  --enable-check           Enable 'check' unit tests], enable_check_ut=yes, )
320
+
321
+LCHECK=""
322
+if test "$enable_check_ut" != "no" ; then
323
+dnl    CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
324
+dnl    LDFLAGS="$LDFLAGS -lgcov"
325
+    AC_DEFINE([HAVE_CHECK], 1, [Enable 'check' unit tests])
326
+    AC_CHECK_HEADERS(check.h)
327
+    AC_CHECK_LIB(check, srunner_create, , LCHECK="no")
328
+fi
329
+
330
+if test "$LCHECK" = "no"; then
331
+    echo
332
+    echo "   ERROR!  Check was configured, but not found.  Get it from http://check.sf.net/"
333
+    exit 1
334
+fi
335
+
317 336
 have_pthreads=no
318 337
 AC_CHECK_HEADER([pthread.h],[have_pthreads=yes],)
319 338
 
... ...
@@ -1416,6 +1435,7 @@ sigtool/Makefile
1416 1416
 clamconf/Makefile
1417 1417
 etc/Makefile
1418 1418
 test/Makefile
1419
+unit_tests/Makefile
1419 1420
 Makefile
1420 1421
 clamav-config
1421 1422
 libclamav.pc
1422 1423
new file mode 100644
... ...
@@ -0,0 +1,5 @@
0
+TESTS = check_clamav
1
+bin_PROGRAMS = check_clamav
2
+check_clamav_SOURCES = check_clamav.c $(top_builddir)/libclamav/libclamav.h
3
+check_clamav_CFLAGS = 
4
+check_clamav_LDADD = $(top_builddir)/libclamav/libclamav.la
0 5
new file mode 100644
... ...
@@ -0,0 +1,572 @@
0
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
1
+# @configure_input@
2
+
3
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
5
+# This Makefile.in is free software; the Free Software Foundation
6
+# gives unlimited permission to copy and/or distribute it,
7
+# with or without modifications, as long as this notice is preserved.
8
+
9
+# This program is distributed in the hope that it will be useful,
10
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12
+# PARTICULAR PURPOSE.
13
+
14
+@SET_MAKE@
15
+
16
+VPATH = @srcdir@
17
+pkgdatadir = $(datadir)/@PACKAGE@
18
+pkglibdir = $(libdir)/@PACKAGE@
19
+pkgincludedir = $(includedir)/@PACKAGE@
20
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
21
+install_sh_DATA = $(install_sh) -c -m 644
22
+install_sh_PROGRAM = $(install_sh) -c
23
+install_sh_SCRIPT = $(install_sh) -c
24
+INSTALL_HEADER = $(INSTALL_DATA)
25
+transform = $(program_transform_name)
26
+NORMAL_INSTALL = :
27
+PRE_INSTALL = :
28
+POST_INSTALL = :
29
+NORMAL_UNINSTALL = :
30
+PRE_UNINSTALL = :
31
+POST_UNINSTALL = :
32
+build_triplet = @build@
33
+host_triplet = @host@
34
+target_triplet = @target@
35
+TESTS = check_clamav$(EXEEXT)
36
+bin_PROGRAMS = check_clamav$(EXEEXT)
37
+subdir = unit_tests
38
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
39
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
40
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
41
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
42
+	$(top_srcdir)/configure.in
43
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
44
+	$(ACLOCAL_M4)
45
+mkinstalldirs = $(install_sh) -d
46
+CONFIG_HEADER = $(top_builddir)/clamav-config.h
47
+CONFIG_CLEAN_FILES =
48
+am__installdirs = "$(DESTDIR)$(bindir)"
49
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
50
+PROGRAMS = $(bin_PROGRAMS)
51
+am_check_clamav_OBJECTS = check_clamav-check_clamav.$(OBJEXT)
52
+check_clamav_OBJECTS = $(am_check_clamav_OBJECTS)
53
+check_clamav_DEPENDENCIES = $(top_builddir)/libclamav/libclamav.la
54
+check_clamav_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
55
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(check_clamav_CFLAGS) \
56
+	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
57
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
58
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
59
+am__depfiles_maybe = depfiles
60
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
61
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
62
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
63
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
64
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
65
+CCLD = $(CC)
66
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
67
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
68
+	$(LDFLAGS) -o $@
69
+SOURCES = $(check_clamav_SOURCES)
70
+DIST_SOURCES = $(check_clamav_SOURCES)
71
+ETAGS = etags
72
+CTAGS = ctags
73
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
74
+ACLOCAL = @ACLOCAL@
75
+AMTAR = @AMTAR@
76
+AR = @AR@
77
+AUTOCONF = @AUTOCONF@
78
+AUTOHEADER = @AUTOHEADER@
79
+AUTOMAKE = @AUTOMAKE@
80
+AWK = @AWK@
81
+CC = @CC@
82
+CCDEPMODE = @CCDEPMODE@
83
+CFGDIR = @CFGDIR@
84
+CFLAGS = @CFLAGS@
85
+CLAMAVGROUP = @CLAMAVGROUP@
86
+CLAMAVUSER = @CLAMAVUSER@
87
+CLAMAV_MILTER_LIBS = @CLAMAV_MILTER_LIBS@
88
+CLAMD_LIBS = @CLAMD_LIBS@
89
+CPP = @CPP@
90
+CPPFLAGS = @CPPFLAGS@
91
+CYGPATH_W = @CYGPATH_W@
92
+DBDIR = @DBDIR@
93
+DEFS = @DEFS@
94
+DEPDIR = @DEPDIR@
95
+DSYMUTIL = @DSYMUTIL@
96
+ECHO = @ECHO@
97
+ECHO_C = @ECHO_C@
98
+ECHO_N = @ECHO_N@
99
+ECHO_T = @ECHO_T@
100
+EGREP = @EGREP@
101
+EXEEXT = @EXEEXT@
102
+FRESHCLAM_LIBS = @FRESHCLAM_LIBS@
103
+GETENT = @GETENT@
104
+GREP = @GREP@
105
+HAVE_LIBGMP = @HAVE_LIBGMP@
106
+INSTALL = @INSTALL@
107
+INSTALL_DATA = @INSTALL_DATA@
108
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
109
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
110
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
111
+LDFLAGS = @LDFLAGS@
112
+LIBBZ2 = @LIBBZ2@
113
+LIBBZ2_PREFIX = @LIBBZ2_PREFIX@
114
+LIBCLAMAV_LIBS = @LIBCLAMAV_LIBS@
115
+LIBCLAMAV_VERSION = @LIBCLAMAV_VERSION@
116
+LIBGMP = @LIBGMP@
117
+LIBGMP_PREFIX = @LIBGMP_PREFIX@
118
+LIBOBJS = @LIBOBJS@
119
+LIBS = @LIBS@
120
+LIBTOOL = @LIBTOOL@
121
+LN_S = @LN_S@
122
+LTLIBBZ2 = @LTLIBBZ2@
123
+LTLIBGMP = @LTLIBGMP@
124
+LTLIBOBJS = @LTLIBOBJS@
125
+MAINT = @MAINT@
126
+MAKEINFO = @MAKEINFO@
127
+MKDIR_P = @MKDIR_P@
128
+NMEDIT = @NMEDIT@
129
+OBJEXT = @OBJEXT@
130
+PACKAGE = @PACKAGE@
131
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
132
+PACKAGE_NAME = @PACKAGE_NAME@
133
+PACKAGE_STRING = @PACKAGE_STRING@
134
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
135
+PACKAGE_VERSION = @PACKAGE_VERSION@
136
+PATH_SEPARATOR = @PATH_SEPARATOR@
137
+RANLIB = @RANLIB@
138
+SED = @SED@
139
+SET_MAKE = @SET_MAKE@
140
+SHELL = @SHELL@
141
+STRIP = @STRIP@
142
+THREAD_LIBS = @THREAD_LIBS@
143
+TH_SAFE = @TH_SAFE@
144
+VERSION = @VERSION@
145
+VERSIONSCRIPTFLAG = @VERSIONSCRIPTFLAG@
146
+abs_builddir = @abs_builddir@
147
+abs_srcdir = @abs_srcdir@
148
+abs_top_builddir = @abs_top_builddir@
149
+abs_top_srcdir = @abs_top_srcdir@
150
+ac_ct_CC = @ac_ct_CC@
151
+am__include = @am__include@
152
+am__leading_dot = @am__leading_dot@
153
+am__quote = @am__quote@
154
+am__tar = @am__tar@
155
+am__untar = @am__untar@
156
+bindir = @bindir@
157
+build = @build@
158
+build_alias = @build_alias@
159
+build_cpu = @build_cpu@
160
+build_os = @build_os@
161
+build_vendor = @build_vendor@
162
+builddir = @builddir@
163
+datadir = @datadir@
164
+datarootdir = @datarootdir@
165
+docdir = @docdir@
166
+dvidir = @dvidir@
167
+exec_prefix = @exec_prefix@
168
+host = @host@
169
+host_alias = @host_alias@
170
+host_cpu = @host_cpu@
171
+host_os = @host_os@
172
+host_vendor = @host_vendor@
173
+htmldir = @htmldir@
174
+includedir = @includedir@
175
+infodir = @infodir@
176
+install_sh = @install_sh@
177
+libdir = @libdir@
178
+libexecdir = @libexecdir@
179
+localedir = @localedir@
180
+localstatedir = @localstatedir@
181
+mandir = @mandir@
182
+mkdir_p = @mkdir_p@
183
+oldincludedir = @oldincludedir@
184
+pdfdir = @pdfdir@
185
+prefix = @prefix@
186
+program_transform_name = @program_transform_name@
187
+psdir = @psdir@
188
+sbindir = @sbindir@
189
+sendmailprog = @sendmailprog@
190
+sharedstatedir = @sharedstatedir@
191
+srcdir = @srcdir@
192
+sysconfdir = @sysconfdir@
193
+target = @target@
194
+target_alias = @target_alias@
195
+target_cpu = @target_cpu@
196
+target_os = @target_os@
197
+target_vendor = @target_vendor@
198
+top_builddir = @top_builddir@
199
+top_srcdir = @top_srcdir@
200
+check_clamav_SOURCES = check_clamav.c $(top_builddir)/libclamav/libclamav.h
201
+check_clamav_CFLAGS = 
202
+check_clamav_LDADD = $(top_builddir)/libclamav/libclamav.la
203
+all: all-am
204
+
205
+.SUFFIXES:
206
+.SUFFIXES: .c .lo .o .obj
207
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
208
+	@for dep in $?; do \
209
+	  case '$(am__configure_deps)' in \
210
+	    *$$dep*) \
211
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
212
+		&& exit 0; \
213
+	      exit 1;; \
214
+	  esac; \
215
+	done; \
216
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  unit_tests/Makefile'; \
217
+	cd $(top_srcdir) && \
218
+	  $(AUTOMAKE) --foreign  unit_tests/Makefile
219
+.PRECIOUS: Makefile
220
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
221
+	@case '$?' in \
222
+	  *config.status*) \
223
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
224
+	  *) \
225
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
226
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
227
+	esac;
228
+
229
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
230
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
231
+
232
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
233
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
234
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
235
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
236
+install-binPROGRAMS: $(bin_PROGRAMS)
237
+	@$(NORMAL_INSTALL)
238
+	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
239
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
240
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
241
+	  if test -f $$p \
242
+	     || test -f $$p1 \
243
+	  ; then \
244
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
245
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
246
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
247
+	  else :; fi; \
248
+	done
249
+
250
+uninstall-binPROGRAMS:
251
+	@$(NORMAL_UNINSTALL)
252
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
253
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
254
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
255
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
256
+	done
257
+
258
+clean-binPROGRAMS:
259
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
260
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
261
+	  echo " rm -f $$p $$f"; \
262
+	  rm -f $$p $$f ; \
263
+	done
264
+check_clamav$(EXEEXT): $(check_clamav_OBJECTS) $(check_clamav_DEPENDENCIES) 
265
+	@rm -f check_clamav$(EXEEXT)
266
+	$(check_clamav_LINK) $(check_clamav_OBJECTS) $(check_clamav_LDADD) $(LIBS)
267
+
268
+mostlyclean-compile:
269
+	-rm -f *.$(OBJEXT)
270
+
271
+distclean-compile:
272
+	-rm -f *.tab.c
273
+
274
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_clamav-check_clamav.Po@am__quote@
275
+
276
+.c.o:
277
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
278
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
279
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
280
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
281
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
282
+
283
+.c.obj:
284
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
285
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
286
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
287
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
288
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
289
+
290
+.c.lo:
291
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
292
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
293
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
294
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
295
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
296
+
297
+check_clamav-check_clamav.o: check_clamav.c
298
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_clamav_CFLAGS) $(CFLAGS) -MT check_clamav-check_clamav.o -MD -MP -MF $(DEPDIR)/check_clamav-check_clamav.Tpo -c -o check_clamav-check_clamav.o `test -f 'check_clamav.c' || echo '$(srcdir)/'`check_clamav.c
299
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/check_clamav-check_clamav.Tpo $(DEPDIR)/check_clamav-check_clamav.Po
300
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='check_clamav.c' object='check_clamav-check_clamav.o' libtool=no @AMDEPBACKSLASH@
301
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
302
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_clamav_CFLAGS) $(CFLAGS) -c -o check_clamav-check_clamav.o `test -f 'check_clamav.c' || echo '$(srcdir)/'`check_clamav.c
303
+
304
+check_clamav-check_clamav.obj: check_clamav.c
305
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_clamav_CFLAGS) $(CFLAGS) -MT check_clamav-check_clamav.obj -MD -MP -MF $(DEPDIR)/check_clamav-check_clamav.Tpo -c -o check_clamav-check_clamav.obj `if test -f 'check_clamav.c'; then $(CYGPATH_W) 'check_clamav.c'; else $(CYGPATH_W) '$(srcdir)/check_clamav.c'; fi`
306
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/check_clamav-check_clamav.Tpo $(DEPDIR)/check_clamav-check_clamav.Po
307
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='check_clamav.c' object='check_clamav-check_clamav.obj' libtool=no @AMDEPBACKSLASH@
308
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
309
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_clamav_CFLAGS) $(CFLAGS) -c -o check_clamav-check_clamav.obj `if test -f 'check_clamav.c'; then $(CYGPATH_W) 'check_clamav.c'; else $(CYGPATH_W) '$(srcdir)/check_clamav.c'; fi`
310
+
311
+mostlyclean-libtool:
312
+	-rm -f *.lo
313
+
314
+clean-libtool:
315
+	-rm -rf .libs _libs
316
+
317
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
318
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
319
+	unique=`for i in $$list; do \
320
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
321
+	  done | \
322
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
323
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
324
+	mkid -fID $$unique
325
+tags: TAGS
326
+
327
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
328
+		$(TAGS_FILES) $(LISP)
329
+	tags=; \
330
+	here=`pwd`; \
331
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
332
+	unique=`for i in $$list; do \
333
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
334
+	  done | \
335
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
336
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
337
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
338
+	  test -n "$$unique" || unique=$$empty_fix; \
339
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
340
+	    $$tags $$unique; \
341
+	fi
342
+ctags: CTAGS
343
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
344
+		$(TAGS_FILES) $(LISP)
345
+	tags=; \
346
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
347
+	unique=`for i in $$list; do \
348
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
349
+	  done | \
350
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
351
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
352
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
353
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
354
+	     $$tags $$unique
355
+
356
+GTAGS:
357
+	here=`$(am__cd) $(top_builddir) && pwd` \
358
+	  && cd $(top_srcdir) \
359
+	  && gtags -i $(GTAGS_ARGS) $$here
360
+
361
+distclean-tags:
362
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
363
+
364
+check-TESTS: $(TESTS)
365
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[	 ]'; \
366
+	srcdir=$(srcdir); export srcdir; \
367
+	list=' $(TESTS) '; \
368
+	if test -n "$$list"; then \
369
+	  for tst in $$list; do \
370
+	    if test -f ./$$tst; then dir=./; \
371
+	    elif test -f $$tst; then dir=; \
372
+	    else dir="$(srcdir)/"; fi; \
373
+	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
374
+	      all=`expr $$all + 1`; \
375
+	      case " $(XFAIL_TESTS) " in \
376
+	      *$$ws$$tst$$ws*) \
377
+		xpass=`expr $$xpass + 1`; \
378
+		failed=`expr $$failed + 1`; \
379
+		echo "XPASS: $$tst"; \
380
+	      ;; \
381
+	      *) \
382
+		echo "PASS: $$tst"; \
383
+	      ;; \
384
+	      esac; \
385
+	    elif test $$? -ne 77; then \
386
+	      all=`expr $$all + 1`; \
387
+	      case " $(XFAIL_TESTS) " in \
388
+	      *$$ws$$tst$$ws*) \
389
+		xfail=`expr $$xfail + 1`; \
390
+		echo "XFAIL: $$tst"; \
391
+	      ;; \
392
+	      *) \
393
+		failed=`expr $$failed + 1`; \
394
+		echo "FAIL: $$tst"; \
395
+	      ;; \
396
+	      esac; \
397
+	    else \
398
+	      skip=`expr $$skip + 1`; \
399
+	      echo "SKIP: $$tst"; \
400
+	    fi; \
401
+	  done; \
402
+	  if test "$$failed" -eq 0; then \
403
+	    if test "$$xfail" -eq 0; then \
404
+	      banner="All $$all tests passed"; \
405
+	    else \
406
+	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
407
+	    fi; \
408
+	  else \
409
+	    if test "$$xpass" -eq 0; then \
410
+	      banner="$$failed of $$all tests failed"; \
411
+	    else \
412
+	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
413
+	    fi; \
414
+	  fi; \
415
+	  dashes="$$banner"; \
416
+	  skipped=""; \
417
+	  if test "$$skip" -ne 0; then \
418
+	    skipped="($$skip tests were not run)"; \
419
+	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
420
+	      dashes="$$skipped"; \
421
+	  fi; \
422
+	  report=""; \
423
+	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
424
+	    report="Please report to $(PACKAGE_BUGREPORT)"; \
425
+	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
426
+	      dashes="$$report"; \
427
+	  fi; \
428
+	  dashes=`echo "$$dashes" | sed s/./=/g`; \
429
+	  echo "$$dashes"; \
430
+	  echo "$$banner"; \
431
+	  test -z "$$skipped" || echo "$$skipped"; \
432
+	  test -z "$$report" || echo "$$report"; \
433
+	  echo "$$dashes"; \
434
+	  test "$$failed" -eq 0; \
435
+	else :; fi
436
+
437
+distdir: $(DISTFILES)
438
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
439
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
440
+	list='$(DISTFILES)'; \
441
+	  dist_files=`for file in $$list; do echo $$file; done | \
442
+	  sed -e "s|^$$srcdirstrip/||;t" \
443
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
444
+	case $$dist_files in \
445
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
446
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
447
+			   sort -u` ;; \
448
+	esac; \
449
+	for file in $$dist_files; do \
450
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
451
+	  if test -d $$d/$$file; then \
452
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
453
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
454
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
455
+	    fi; \
456
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
457
+	  else \
458
+	    test -f $(distdir)/$$file \
459
+	    || cp -p $$d/$$file $(distdir)/$$file \
460
+	    || exit 1; \
461
+	  fi; \
462
+	done
463
+check-am: all-am
464
+	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
465
+check: check-am
466
+all-am: Makefile $(PROGRAMS)
467
+installdirs:
468
+	for dir in "$(DESTDIR)$(bindir)"; do \
469
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
470
+	done
471
+install: install-am
472
+install-exec: install-exec-am
473
+install-data: install-data-am
474
+uninstall: uninstall-am
475
+
476
+install-am: all-am
477
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
478
+
479
+installcheck: installcheck-am
480
+install-strip:
481
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
482
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
483
+	  `test -z '$(STRIP)' || \
484
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
485
+mostlyclean-generic:
486
+
487
+clean-generic:
488
+
489
+distclean-generic:
490
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
491
+
492
+maintainer-clean-generic:
493
+	@echo "This command is intended for maintainers to use"
494
+	@echo "it deletes files that may require special tools to rebuild."
495
+clean: clean-am
496
+
497
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
498
+
499
+distclean: distclean-am
500
+	-rm -rf ./$(DEPDIR)
501
+	-rm -f Makefile
502
+distclean-am: clean-am distclean-compile distclean-generic \
503
+	distclean-tags
504
+
505
+dvi: dvi-am
506
+
507
+dvi-am:
508
+
509
+html: html-am
510
+
511
+info: info-am
512
+
513
+info-am:
514
+
515
+install-data-am:
516
+
517
+install-dvi: install-dvi-am
518
+
519
+install-exec-am: install-binPROGRAMS
520
+
521
+install-html: install-html-am
522
+
523
+install-info: install-info-am
524
+
525
+install-man:
526
+
527
+install-pdf: install-pdf-am
528
+
529
+install-ps: install-ps-am
530
+
531
+installcheck-am:
532
+
533
+maintainer-clean: maintainer-clean-am
534
+	-rm -rf ./$(DEPDIR)
535
+	-rm -f Makefile
536
+maintainer-clean-am: distclean-am maintainer-clean-generic
537
+
538
+mostlyclean: mostlyclean-am
539
+
540
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
541
+	mostlyclean-libtool
542
+
543
+pdf: pdf-am
544
+
545
+pdf-am:
546
+
547
+ps: ps-am
548
+
549
+ps-am:
550
+
551
+uninstall-am: uninstall-binPROGRAMS
552
+
553
+.MAKE: install-am install-strip
554
+
555
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
556
+	clean-binPROGRAMS clean-generic clean-libtool ctags distclean \
557
+	distclean-compile distclean-generic distclean-libtool \
558
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
559
+	install install-am install-binPROGRAMS install-data \
560
+	install-data-am install-dvi install-dvi-am install-exec \
561
+	install-exec-am install-html install-html-am install-info \
562
+	install-info-am install-man install-pdf install-pdf-am \
563
+	install-ps install-ps-am install-strip installcheck \
564
+	installcheck-am installdirs maintainer-clean \
565
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
566
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
567
+	tags uninstall uninstall-am uninstall-binPROGRAMS
568
+
569
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
570
+# Otherwise a system limit (for SysV at least) may be exceeded.
571
+.NOEXPORT:
0 572
new file mode 100644
... ...
@@ -0,0 +1,211 @@
0
+#if HAVE_CONFIG_H
1
+#include "clamav-config.h"
2
+#endif
3
+
4
+#include <stdio.h>
5
+
6
+#ifndef HAVE_CHECK
7
+int main(int argc, char **argv)
8
+{
9
+    printf("Unit tests disabled in build\n");
10
+    return 0;
11
+}
12
+#else
13
+
14
+#include <stdlib.h>
15
+#include <limits.h>
16
+#include <string.h>
17
+#include <check.h>
18
+#include "../libclamav/clamav.h"
19
+#include "../libclamav/others.h"
20
+#include "../libclamav/matcher.h"
21
+
22
+/* extern void cl_free(struct cl_engine *engine); */
23
+START_TEST (test_cl_free)
24
+/*
25
+    struct cl_engine *engine = NULL;
26
+    cl_free(NULL);
27
+*/
28
+END_TEST
29
+
30
+/* extern struct cl_engine *cl_dup(struct cl_engine *engine); */
31
+START_TEST (test_cl_dup)
32
+    /*
33
+    struct cl_engine *engine;
34
+    fail_unless(NULL == cl_dup(NULL), "cl_dup null pointer");
35
+    */
36
+END_TEST
37
+
38
+/* extern int cl_build(struct cl_engine *engine); */
39
+START_TEST (test_cl_build)
40
+    /*
41
+    struct cl_engine *engine;
42
+    fail_unless(CL_ENULLARG == cl_build(NULL), "cl_build null pointer");
43
+    engine = calloc(sizeof(struct cl_engine),1);
44
+    fail_unless(engine, "cl_build calloc");
45
+    fail_unless(CL_ENULLARG == cl_build(engine), "cl_build(engine) with null ->root");
46
+    */
47
+/*    engine->root = cli_calloc(CL_TARGET_TABLE_SIZE, sizeof(struct cli_matcher *)); */
48
+END_TEST
49
+
50
+/* extern void cl_debug(void); */
51
+START_TEST (test_cl_debug)
52
+    cli_debug_flag = 0;
53
+    cl_debug();
54
+    fail_unless(1 == cli_debug_flag, "cl_debug failed to set cli_debug_flag");
55
+
56
+    cli_debug_flag = 1;
57
+    cl_debug();
58
+    fail_unless(1 == cli_debug_flag, "cl_debug failed when flag was already set");
59
+END_TEST
60
+
61
+/* extern const char *cl_retdbdir(void); */
62
+START_TEST (test_cl_retdbdir)
63
+    fail_unless(!strcmp(DATADIR, cl_retdbdir()), "cl_retdbdir");
64
+END_TEST
65
+
66
+/* extern const char *cl_retver(void); */
67
+START_TEST (test_cl_retver)
68
+    fail_unless(!strcmp(VERSION, cl_retver()), "cl_retver");
69
+END_TEST
70
+
71
+/* extern void cl_cvdfree(struct cl_cvd *cvd); */
72
+START_TEST (test_cl_cvdfree)
73
+/*
74
+    struct cl_cvd *cvd1, *cvd2;
75
+
76
+    cvd1 = malloc(sizeof(struct cl_cvd));
77
+    fail_unless(cvd1, "cvd malloc");
78
+    cl_cvdfree(cvd1);
79
+
80
+    cvd2 = malloc(sizeof(struct cl_cvd));
81
+    cvd2->time = malloc(1);
82
+    cvd2->md5 = malloc(1);
83
+    cvd2->dsig= malloc(1);
84
+    cvd2->builder = malloc(1);
85
+    fail_unless(cvd2, "cvd malloc");
86
+    fail_unless(cvd2->time, "cvd malloc");
87
+    fail_unless(cvd2->md5, "cvd malloc");
88
+    fail_unless(cvd2->dsig, "cvd malloc");
89
+    fail_unless(cvd2->builder, "cvd malloc");
90
+    cl_cvdfree(cvd2);
91
+    cl_cvdfree(NULL);
92
+*/
93
+END_TEST
94
+
95
+/* extern int cl_statfree(struct cl_stat *dbstat); */
96
+START_TEST (test_cl_statfree)
97
+/*
98
+    struct cl_stat *stat;
99
+    fail_unless(CL_ENULLARG == cl_statfree(NULL), "cl_statfree(NULL)");
100
+    
101
+    stat = malloc(sizeof(struct cl_stat));
102
+    fail_unless(NULL != stat, "malloc");
103
+    fail_unless(CL_SUCCESS == cl_statfree(stat), "cl_statfree(empty_struct)");
104
+    
105
+    stat = malloc(sizeof(struct cl_stat));
106
+    fail_unless(NULL != stat, "malloc");
107
+    stat->stattab = strdup("test");
108
+    fail_unless(NULL != stat->stattab, "strdup");
109
+    fail_unless(CL_SUCCESS == cl_statfree(stat), "cl_statfree(stat with stattab)");
110
+
111
+    stat = malloc(sizeof(struct cl_stat));
112
+    fail_unless(NULL != stat, "malloc");
113
+    stat->stattab = NULL;
114
+    fail_unless(CL_SUCCESS == cl_statfree(stat), "cl_statfree(stat with stattab) set to NULL");
115
+*/
116
+END_TEST
117
+
118
+/* extern unsigned int cl_retflevel(void); */
119
+START_TEST (test_cl_retflevel)
120
+END_TEST    
121
+
122
+/* extern struct cl_cvd *cl_cvdhead(const char *file); */
123
+START_TEST (test_cl_cvdhead)
124
+/*
125
+    fail_unless(NULL == cl_cvdhead(NULL), "cl_cvdhead(null)");
126
+    fail_unless(NULL == cl_cvdhead("input/cl_cvdhead/1.txt"), "cl_cvdhead(515 byte file, all nulls)");
127
+*/
128
+    /* the data read from the file is passed to cl_cvdparse, test cases for that are separate */
129
+END_TEST
130
+
131
+/* extern struct cl_cvd *cl_cvdparse(const char *head); */
132
+START_TEST (test_cl_cvdparse)
133
+END_TEST
134
+
135
+/* int cl_scandesc(int desc, const char **virname, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options) */
136
+START_TEST (test_cl_scandesc)
137
+END_TEST
138
+
139
+/* int cl_scanfile(const char *filename, const char **virname, unsigned long int *scanned, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options) */
140
+START_TEST (test_cl_scanfile)
141
+END_TEST
142
+
143
+/* int cl_load(const char *path, struct cl_engine **engine, unsigned int *signo, unsigned int options) */
144
+START_TEST (test_cl_load)
145
+END_TEST
146
+
147
+/* int cl_cvdverify(const char *file) */
148
+START_TEST (test_cl_cvdverify)
149
+END_TEST
150
+
151
+/* int cl_statinidir(const char *dirname, struct cl_stat *dbstat) */
152
+START_TEST (test_cl_statinidir)
153
+END_TEST
154
+
155
+/* int cl_statchkdir(const struct cl_stat *dbstat) */
156
+START_TEST (test_cl_statchkdir)
157
+END_TEST
158
+
159
+/* void cl_settempdir(const char *dir, short leavetemps) */
160
+START_TEST (test_cl_settempdir)
161
+END_TEST
162
+
163
+/* const char *cl_strerror(int clerror) */
164
+START_TEST (test_cl_strerror)
165
+END_TEST
166
+
167
+Suite *test_cl_suite(void)
168
+{
169
+	Suite *s = suite_create("cl_api");
170
+	TCase *tc_cl = tcase_create("cl_dup");
171
+
172
+    suite_add_tcase (s, tc_cl);
173
+    tcase_add_test(tc_cl, test_cl_free);
174
+    tcase_add_test(tc_cl, test_cl_dup);
175
+    tcase_add_test(tc_cl, test_cl_build);
176
+    tcase_add_test(tc_cl, test_cl_debug);
177
+    tcase_add_test(tc_cl, test_cl_retdbdir);
178
+    tcase_add_test(tc_cl, test_cl_retver);
179
+    tcase_add_test(tc_cl, test_cl_cvdfree);
180
+    tcase_add_test(tc_cl, test_cl_statfree);
181
+    tcase_add_test(tc_cl, test_cl_retflevel);
182
+    tcase_add_test(tc_cl, test_cl_cvdhead);
183
+    tcase_add_test(tc_cl, test_cl_cvdparse);
184
+    tcase_add_test(tc_cl, test_cl_scandesc);
185
+    tcase_add_test(tc_cl, test_cl_scanfile);
186
+    tcase_add_test(tc_cl, test_cl_load);
187
+    tcase_add_test(tc_cl, test_cl_cvdverify);
188
+    tcase_add_test(tc_cl, test_cl_statinidir);
189
+    tcase_add_test(tc_cl, test_cl_statchkdir);
190
+    tcase_add_test(tc_cl, test_cl_settempdir);
191
+    tcase_add_test(tc_cl, test_cl_strerror);
192
+
193
+    return s;
194
+}
195
+
196
+int main(int argc, char **argv)
197
+{
198
+	int nf;
199
+	Suite *s = test_cl_suite();
200
+	SRunner *sr = srunner_create(s);
201
+
202
+    srunner_set_log(sr, "test.log");
203
+    srunner_run_all(sr, CK_NORMAL);
204
+    nf = srunner_ntests_failed(sr);
205
+    srunner_free(sr);
206
+
207
+    return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
208
+}
209
+
210
+#endif /* HAVE_CHECK */