git-svn: trunk@4009
aCaB authored on 2008/07/29 04:22:15... | ... |
@@ -9,7 +9,7 @@ else |
9 | 9 |
check_PROGRAMS = $(programs) |
10 | 10 |
check_SCRIPTS = $(scripts) |
11 | 11 |
endif |
12 |
-check_clamav_SOURCES = check_clamav.c check_jsnorm.c check_str.c check_regex.c checks.h $(top_builddir)/libclamav/clamav.h |
|
12 |
+check_clamav_SOURCES = check_clamav.c check_jsnorm.c check_str.c check_regex.c checks.h $(top_builddir)/libclamav/clamav.h check_disasm.c |
|
13 | 13 |
check_clamav_CFLAGS = @CHECK_CFLAGS@ -DSRCDIR=\"$(abs_srcdir)\" |
14 | 14 |
check_clamav_LDADD = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@ @CHECK_LIBS@ |
15 | 15 |
|
... | ... |
@@ -56,7 +56,8 @@ PROGRAMS = $(bin_PROGRAMS) |
56 | 56 |
am_check_clamav_OBJECTS = check_clamav-check_clamav.$(OBJEXT) \ |
57 | 57 |
check_clamav-check_jsnorm.$(OBJEXT) \ |
58 | 58 |
check_clamav-check_str.$(OBJEXT) \ |
59 |
- check_clamav-check_regex.$(OBJEXT) |
|
59 |
+ check_clamav-check_regex.$(OBJEXT) \ |
|
60 |
+ check_clamav-check_disasm.$(OBJEXT) |
|
60 | 61 |
check_clamav_OBJECTS = $(am_check_clamav_OBJECTS) |
61 | 62 |
check_clamav_DEPENDENCIES = $(top_builddir)/libclamav/libclamav.la |
62 | 63 |
check_clamav_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ |
... | ... |
@@ -220,7 +221,7 @@ programs = check_clamav |
220 | 220 |
scripts = check_clamd.sh check_freshclam.sh check_sigtool.sh check_clamscan.sh valgrind_tests.sh |
221 | 221 |
@ENABLE_UT_INSTALL_TRUE@dist_bin_SCRIPTS = $(scripts) |
222 | 222 |
@ENABLE_UT_INSTALL_FALSE@check_SCRIPTS = $(scripts) |
223 |
-check_clamav_SOURCES = check_clamav.c check_jsnorm.c check_str.c check_regex.c checks.h $(top_builddir)/libclamav/clamav.h |
|
223 |
+check_clamav_SOURCES = check_clamav.c check_jsnorm.c check_str.c check_regex.c checks.h $(top_builddir)/libclamav/clamav.h check_disasm.c |
|
224 | 224 |
check_clamav_CFLAGS = @CHECK_CFLAGS@ -DSRCDIR=\"$(abs_srcdir)\" |
225 | 225 |
check_clamav_LDADD = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@ @CHECK_LIBS@ |
226 | 226 |
EXTRA_DIST = test-clamd.conf test-freshclam.conf valgrind.supp inputs/COPYING inputs/daily.pdb inputs/daily.wdb |
... | ... |
@@ -330,6 +331,7 @@ distclean-compile: |
330 | 330 |
-rm -f *.tab.c |
331 | 331 |
|
332 | 332 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_clamav-check_clamav.Po@am__quote@ |
333 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_clamav-check_disasm.Po@am__quote@ |
|
333 | 334 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_clamav-check_jsnorm.Po@am__quote@ |
334 | 335 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_clamav-check_regex.Po@am__quote@ |
335 | 336 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_clamav-check_str.Po@am__quote@ |
... | ... |
@@ -411,6 +413,20 @@ check_clamav-check_regex.obj: check_regex.c |
411 | 411 |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
412 | 412 |
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_clamav_CFLAGS) $(CFLAGS) -c -o check_clamav-check_regex.obj `if test -f 'check_regex.c'; then $(CYGPATH_W) 'check_regex.c'; else $(CYGPATH_W) '$(srcdir)/check_regex.c'; fi` |
413 | 413 |
|
414 |
+check_clamav-check_disasm.o: check_disasm.c |
|
415 |
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_clamav_CFLAGS) $(CFLAGS) -MT check_clamav-check_disasm.o -MD -MP -MF $(DEPDIR)/check_clamav-check_disasm.Tpo -c -o check_clamav-check_disasm.o `test -f 'check_disasm.c' || echo '$(srcdir)/'`check_disasm.c |
|
416 |
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/check_clamav-check_disasm.Tpo $(DEPDIR)/check_clamav-check_disasm.Po |
|
417 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='check_disasm.c' object='check_clamav-check_disasm.o' libtool=no @AMDEPBACKSLASH@ |
|
418 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
419 |
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_clamav_CFLAGS) $(CFLAGS) -c -o check_clamav-check_disasm.o `test -f 'check_disasm.c' || echo '$(srcdir)/'`check_disasm.c |
|
420 |
+ |
|
421 |
+check_clamav-check_disasm.obj: check_disasm.c |
|
422 |
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_clamav_CFLAGS) $(CFLAGS) -MT check_clamav-check_disasm.obj -MD -MP -MF $(DEPDIR)/check_clamav-check_disasm.Tpo -c -o check_clamav-check_disasm.obj `if test -f 'check_disasm.c'; then $(CYGPATH_W) 'check_disasm.c'; else $(CYGPATH_W) '$(srcdir)/check_disasm.c'; fi` |
|
423 |
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/check_clamav-check_disasm.Tpo $(DEPDIR)/check_clamav-check_disasm.Po |
|
424 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='check_disasm.c' object='check_clamav-check_disasm.obj' libtool=no @AMDEPBACKSLASH@ |
|
425 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
426 |
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_clamav_CFLAGS) $(CFLAGS) -c -o check_clamav-check_disasm.obj `if test -f 'check_disasm.c'; then $(CYGPATH_W) 'check_disasm.c'; else $(CYGPATH_W) '$(srcdir)/check_disasm.c'; fi` |
|
427 |
+ |
|
414 | 428 |
mostlyclean-libtool: |
415 | 429 |
-rm -f *.lo |
416 | 430 |
|
... | ... |
@@ -333,7 +333,8 @@ int main(int argc, char **argv) |
333 | 333 |
srunner_add_suite(sr, test_cli_suite()); |
334 | 334 |
srunner_add_suite(sr, test_jsnorm_suite()); |
335 | 335 |
srunner_add_suite(sr, test_str_suite()); |
336 |
- srunner_add_suite(sr, test_regex_suite()); |
|
336 |
+ /* srunner_add_suite(sr, test_regex_suite()); */ |
|
337 |
+ srunner_add_suite(sr, test_disasm_suite()); |
|
337 | 338 |
|
338 | 339 |
srunner_set_log(sr, "test.log"); |
339 | 340 |
freopen("test-stderr.log","w+",stderr); |
340 | 341 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,71 @@ |
0 |
+/* |
|
1 |
+ * Unit tests for JS normalizer. |
|
2 |
+ * |
|
3 |
+ * Copyright (C) 2008 Sourcefire, Inc. |
|
4 |
+ * |
|
5 |
+ * Authors: Török Edvin |
|
6 |
+ * |
|
7 |
+ * This program is free software; you can redistribute it and/or modify |
|
8 |
+ * it under the terms of the GNU General Public License version 2 as |
|
9 |
+ * published by the Free Software Foundation. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
+ * MA 02110-1301, USA. |
|
20 |
+ */ |
|
21 |
+#if HAVE_CONFIG_H |
|
22 |
+#include "clamav-config.h" |
|
23 |
+#endif |
|
24 |
+ |
|
25 |
+#include <stdio.h> |
|
26 |
+#ifdef HAVE_CHECK |
|
27 |
+ |
|
28 |
+#include <check.h> |
|
29 |
+#include <stdlib.h> |
|
30 |
+#include <sys/types.h> |
|
31 |
+#include <unistd.h> |
|
32 |
+ |
|
33 |
+#include "../libclamav/clamav.h" |
|
34 |
+#include "../libclamav/others.h" |
|
35 |
+#include "../libclamav/disasm.h" |
|
36 |
+ |
|
37 |
+START_TEST (test_disasm_basic) { |
|
38 |
+ char file[]="disasmXXXXXX"; |
|
39 |
+ char ref[]="\xc2\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x02\x00\x00"; |
|
40 |
+ int fd = mkstemp(file); |
|
41 |
+ uint8_t buf[] = {0x33, 0xc0}; |
|
42 |
+ off_t *d; |
|
43 |
+ off_t size; |
|
44 |
+ |
|
45 |
+ disasmbuf(buf, 2, fd); |
|
46 |
+ size = lseek(fd, 0, SEEK_CUR); |
|
47 |
+ fail_unless(size==64, "disasm size"); |
|
48 |
+ lseek(fd, 0, SEEK_SET); |
|
49 |
+ d=malloc(size); |
|
50 |
+ fail_unless(d, "disasm malloc"); |
|
51 |
+ fail_unless(read(fd, d, size)==size, "disasm read"); |
|
52 |
+ close(fd); |
|
53 |
+ free(d); |
|
54 |
+ unlink(file); |
|
55 |
+} |
|
56 |
+END_TEST |
|
57 |
+ |
|
58 |
+ |
|
59 |
+Suite *test_disasm_suite(void) |
|
60 |
+{ |
|
61 |
+ Suite *s = suite_create("disasm"); |
|
62 |
+ TCase *tc_disasm; |
|
63 |
+ tc_disasm = tcase_create("disasm"); |
|
64 |
+ suite_add_tcase (s, tc_disasm); |
|
65 |
+ tcase_add_test(tc_disasm, test_disasm_basic); |
|
66 |
+ return s; |
|
67 |
+} |
|
68 |
+ |
|
69 |
+ |
|
70 |
+#endif |