| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *  Unit tests for bytecode functions.  | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  Copyright (C) 2009 Sourcefire, Inc. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  Authors: Török Edvin | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |  *  it under the terms of the GNU General Public License version 2 as | 
					
						
							|  |  |  |  *  published by the Free Software Foundation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  *  but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  *  GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  *  along with this program; if not, write to the Free Software | 
					
						
							|  |  |  |  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | 
					
						
							|  |  |  |  *  MA 02110-1301, USA. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #if HAVE_CONFIG_H
 | 
					
						
							|  |  |  | #include "clamav-config.h"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <limits.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | #include <check.h>
 | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  | #include <fcntl.h>
 | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | #include <errno.h>
 | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | #include "../libclamav/clamav.h"
 | 
					
						
							|  |  |  | #include "../libclamav/others.h"
 | 
					
						
							|  |  |  | #include "../libclamav/bytecode.h"
 | 
					
						
							|  |  |  | #include "checks.h"
 | 
					
						
							| 
									
										
										
										
											2010-02-15 14:37:09 +02:00
										 |  |  | #include "../libclamav/dconf.h"
 | 
					
						
							| 
									
										
										
										
											2010-03-22 17:16:07 +02:00
										 |  |  | #include "../libclamav/bytecode_priv.h"
 | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  | #include "../libclamav/pe.h"
 | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  | static void runtest(const char *file, uint64_t expected, int fail, int nojit, | 
					
						
							|  |  |  | 		    const char *infile, struct cli_pe_hook_data *pedata, | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  | 		    struct cli_exe_section *sections, const char *expectedvirname, | 
					
						
							|  |  |  | 		    int testmode) | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  |     fmap_t *map = NULL; | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  |     int rc; | 
					
						
							|  |  |  |     int fd = open_testfile(file); | 
					
						
							|  |  |  |     FILE *f; | 
					
						
							|  |  |  |     struct cli_bc bc; | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  |     cli_ctx cctx; | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  |     struct cli_bc_ctx *ctx; | 
					
						
							| 
									
										
										
										
											2009-08-25 18:54:14 +03:00
										 |  |  |     struct cli_all_bc bcs; | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  |     uint64_t v; | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  |     struct cl_engine *engine; | 
					
						
							| 
									
										
										
										
											2010-05-13 23:35:47 +03:00
										 |  |  |     int fdin = -1; | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  |     memset(&cctx, 0, sizeof(cctx)); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  |     cctx.engine = engine = cl_engine_new(); | 
					
						
							|  |  |  |     fail_unless(!!cctx.engine, "cannot create engine"); | 
					
						
							| 
									
										
										
										
											2010-05-13 23:25:11 +03:00
										 |  |  |     rc = cl_engine_compile(engine); | 
					
						
							|  |  |  |     fail_unless(!rc, "cannot compile engine"); | 
					
						
							|  |  |  |     cctx.fmap = cli_calloc(sizeof(fmap_t*), engine->maxreclevel + 2); | 
					
						
							|  |  |  |     fail_unless(!!cctx.fmap, "cannot allocate fmap"); | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  |     fail_unless(fd >= 0, "retmagic open failed"); | 
					
						
							|  |  |  |     f = fdopen(fd, "r"); | 
					
						
							|  |  |  |     fail_unless(!!f, "retmagic fdopen failed"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cl_debug(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-28 20:07:25 +03:00
										 |  |  |     if (!nojit) { | 
					
						
							| 
									
										
										
										
											2010-07-29 13:22:35 +03:00
										 |  |  | 	rc = cli_bytecode_init(&bcs); | 
					
						
							| 
									
										
										
										
											2009-08-28 20:07:25 +03:00
										 |  |  | 	fail_unless(rc == CL_SUCCESS, "cli_bytecode_init failed"); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  | 	bcs.engine = NULL; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-08-25 18:54:14 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bcs.all_bcs = &bc; | 
					
						
							|  |  |  |     bcs.count = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-25 13:28:19 +01:00
										 |  |  |     rc = cli_bytecode_load(&bc, f, NULL, 1); | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  |     fail_unless(rc == CL_SUCCESS, "cli_bytecode_load failed"); | 
					
						
							|  |  |  |     fclose(f); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-29 13:22:35 +03:00
										 |  |  |     if (testmode) | 
					
						
							|  |  |  | 	engine->bytecode_mode = CL_BYTECODE_MODE_TEST; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-11 13:39:49 +03:00
										 |  |  |     rc = cli_bytecode_prepare2(engine, &bcs, BYTECODE_ENGINE_MASK); | 
					
						
							| 
									
										
										
										
											2009-07-23 17:33:11 +03:00
										 |  |  |     fail_unless(rc == CL_SUCCESS, "cli_bytecode_prepare failed"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-28 20:07:25 +03:00
										 |  |  |     if (have_clamjit && !nojit && nojit != -1) { | 
					
						
							|  |  |  | 	fail_unless(bc.state == bc_jit, "preparing for JIT failed"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  |     ctx = cli_bytecode_context_alloc(); | 
					
						
							| 
									
										
										
										
											2010-03-30 11:10:58 +03:00
										 |  |  |     ctx->bytecode_timeout = fail == CL_ETIMEOUT ? 10 : 10000; | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  |     fail_unless(!!ctx, "cli_bytecode_context_alloc failed"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  |     ctx->ctx = &cctx; | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  |     if (infile) { | 
					
						
							| 
									
										
										
										
											2010-05-13 23:35:47 +03:00
										 |  |  | 	fdin = open(infile, O_RDONLY); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | 	if (fdin < 0 && errno == ENOENT) | 
					
						
							|  |  |  | 	    fdin = open_testfile(infile); | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  | 	fail_unless(fdin >= 0, "failed to open infile"); | 
					
						
							|  |  |  | 	map = fmap(fdin, 0, 0); | 
					
						
							|  |  |  | 	fail_unless(!!map, "unable to fmap infile"); | 
					
						
							|  |  |  | 	if (pedata) | 
					
						
							|  |  |  | 	    ctx->hooks.pedata = pedata; | 
					
						
							|  |  |  | 	ctx->sections = sections; | 
					
						
							|  |  |  | 	cli_bytecode_context_setfile(ctx, map); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  |     cli_bytecode_context_setfuncid(ctx, &bc, 0); | 
					
						
							| 
									
										
										
										
											2009-08-27 20:41:29 +03:00
										 |  |  |     rc = cli_bytecode_run(&bcs, &bc, ctx); | 
					
						
							| 
									
										
										
										
											2009-10-02 12:27:52 +03:00
										 |  |  |     fail_unless_fmt(rc == fail, "cli_bytecode_run failed, expected: %u, have: %u\n", | 
					
						
							|  |  |  | 		    fail, rc); | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-28 13:18:17 +03:00
										 |  |  |     if (rc == CL_SUCCESS) { | 
					
						
							|  |  |  | 	v = cli_bytecode_context_getresult_int(ctx); | 
					
						
							|  |  |  | 	fail_unless_fmt(v == expected, "Invalid return value from bytecode run, expected: %llx, have: %llx\n", | 
					
						
							|  |  |  | 			expected, v); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  |     if (infile && expectedvirname) { | 
					
						
							|  |  |  | 	fail_unless(ctx->virname && | 
					
						
							|  |  |  | 		    !strcmp(ctx->virname, expectedvirname), | 
					
						
							|  |  |  | 		    "Invalid virname, expected: %s\n", expectedvirname); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  |     cli_bytecode_context_destroy(ctx); | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  |     if (map) | 
					
						
							|  |  |  | 	funmap(map); | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  |     cli_bytecode_destroy(&bc); | 
					
						
							| 
									
										
										
										
											2009-08-25 18:54:14 +03:00
										 |  |  |     cli_bytecode_done(&bcs); | 
					
						
							| 
									
										
										
										
											2010-05-13 23:25:11 +03:00
										 |  |  |     free(cctx.fmap); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  |     cl_engine_free(engine); | 
					
						
							| 
									
										
										
										
											2010-05-13 23:35:47 +03:00
										 |  |  |     if (fdin >= 0) | 
					
						
							|  |  |  | 	close(fdin); | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | START_TEST (test_retmagic_jit) | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-28 20:07:25 +03:00
										 |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/retmagic.cbc", 0x1234f00d, CL_SUCCESS, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-08-02 17:33:44 +03:00
										 |  |  |     runtest("input/retmagic.cbc", 0x1234f00d, CL_SUCCESS, 0, NULL, NULL, NULL, NULL, 1); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_retmagic_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/retmagic.cbc", 0x1234f00d, CL_SUCCESS, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | START_TEST (test_arith_jit) | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-28 20:07:25 +03:00
										 |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/arith.cbc", 0xd5555555, CL_SUCCESS, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_arith_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/arith.cbc", 0xd5555555, CL_SUCCESS, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							| 
									
										
										
										
											2009-08-20 16:23:43 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | START_TEST (test_apicalls_jit) | 
					
						
							| 
									
										
										
										
											2009-08-20 16:23:43 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-28 20:07:25 +03:00
										 |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/apicalls.cbc", 0xf00d, CL_SUCCESS, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_apicalls_int) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/apicalls.cbc", 0xf00d, CL_SUCCESS, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2009-08-20 16:23:43 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | START_TEST (test_apicalls2_jit) | 
					
						
							| 
									
										
										
										
											2009-09-02 18:53:29 +03:00
										 |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/apicalls2.cbc", 0xf00d, CL_SUCCESS, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_apicalls2_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/apicalls2.cbc", 0xf00d, CL_SUCCESS, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2009-09-02 18:53:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | START_TEST (test_div0_jit) | 
					
						
							| 
									
										
										
										
											2009-08-28 13:18:17 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-08-28 20:07:25 +03:00
										 |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2009-08-28 13:18:17 +03:00
										 |  |  |     /* must not crash on div#0 but catch it */ | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/div0.cbc", 0, CL_EBYTECODE, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_div0_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/div0.cbc", 0, CL_EBYTECODE, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2009-08-28 13:18:17 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							| 
									
										
										
										
											2009-08-20 16:23:43 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | START_TEST (test_lsig_jit) | 
					
						
							| 
									
										
										
										
											2009-09-21 19:24:16 +03:00
										 |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/lsig.cbc", 0, 0, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_lsig_int) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/lsig.cbc", 0, 0, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2009-09-21 19:24:16 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | START_TEST (test_inf_jit) | 
					
						
							| 
									
										
										
										
											2010-03-22 17:16:07 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/inf.cbc", 0, CL_ETIMEOUT, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_inf_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/inf.cbc", 0, CL_ETIMEOUT, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | START_TEST (test_matchwithread_jit) | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     struct cli_exe_section sect; | 
					
						
							|  |  |  |     struct cli_pe_hook_data pedata; | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							|  |  |  |     memset(&pedata, 0, sizeof(pedata)); | 
					
						
							|  |  |  |     pedata.ep = 64; | 
					
						
							| 
									
										
										
										
											2010-04-02 13:07:23 +03:00
										 |  |  |     cli_writeint32(&pedata.opt32.ImageBase, 0x400000); | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  |     pedata.hdr_size = 0x400; | 
					
						
							|  |  |  |     pedata.nsections = 1; | 
					
						
							|  |  |  |     sect.rva = 4096; | 
					
						
							|  |  |  |     sect.vsz = 4096; | 
					
						
							|  |  |  |     sect.raw = 0; | 
					
						
							|  |  |  |     sect.rsz = 512; | 
					
						
							|  |  |  |     sect.urva = 4096; | 
					
						
							|  |  |  |     sect.uvsz = 4096; | 
					
						
							|  |  |  |     sect.uraw = 1; | 
					
						
							|  |  |  |     sect.ursz = 512; | 
					
						
							|  |  |  |     runtest("input/matchwithread.cbc", 0, 0, 0, "../test/clam.exe", &pedata, | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  | 	    §, "ClamAV-Test-File-detected-via-bytecode", 0); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_matchwithread_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     struct cli_exe_section sect; | 
					
						
							|  |  |  |     struct cli_pe_hook_data pedata; | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							|  |  |  |     memset(&pedata, 0, sizeof(pedata)); | 
					
						
							|  |  |  |     pedata.ep = 64; | 
					
						
							| 
									
										
										
										
											2010-04-02 13:07:23 +03:00
										 |  |  |     cli_writeint32(&pedata.opt32.ImageBase, 0x400000); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  |     pedata.hdr_size = 0x400; | 
					
						
							|  |  |  |     pedata.nsections = 1; | 
					
						
							|  |  |  |     sect.rva = 4096; | 
					
						
							|  |  |  |     sect.vsz = 4096; | 
					
						
							|  |  |  |     sect.raw = 0; | 
					
						
							|  |  |  |     sect.rsz = 512; | 
					
						
							|  |  |  |     sect.urva = 4096; | 
					
						
							|  |  |  |     sect.uvsz = 4096; | 
					
						
							|  |  |  |     sect.uraw = 1; | 
					
						
							|  |  |  |     sect.ursz = 512; | 
					
						
							| 
									
										
										
										
											2010-03-24 12:46:34 +02:00
										 |  |  |     runtest("input/matchwithread.cbc", 0, 0, 1, "../test/clam.exe", &pedata, | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  | 	    §, "ClamAV-Test-File-detected-via-bytecode", 0); | 
					
						
							| 
									
										
										
										
											2010-03-22 17:16:07 +02:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_pdf_jit) | 
					
						
							| 
									
										
										
										
											2010-03-24 14:14:33 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/pdf.cbc", 0, 0, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_pdf_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/pdf.cbc", 0, 0, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-24 14:14:33 +02:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | START_TEST (test_bswap_jit) | 
					
						
							| 
									
										
										
										
											2010-03-24 15:27:15 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/bswap.cbc", 0xbeef, 0, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_bswap_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/bswap.cbc", 0xbeef, 0, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-24 15:27:15 +02:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | START_TEST (test_inflate_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/inflate.cbc", 0xbeef, 0, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_inflate_int) | 
					
						
							| 
									
										
										
										
											2010-03-24 17:07:14 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/inflate.cbc", 0xbeef, 0, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_api_extract_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/api_extract_7.cbc", 0xf00d, 0, 0, "input/apitestfile", NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_api_files_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/api_files_7.cbc", 0xf00d, 0, 0, "input/apitestfile", NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_apicalls2_7_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/apicalls2_7.cbc", 0xf00d, 0, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_apicalls_7_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/apicalls_7.cbc", 0xf00d, 0, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_arith_7_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/arith_7.cbc", 0xd55555dd, CL_SUCCESS, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_debug_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/debug_7.cbc", 0xf00d, 0, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_inf_7_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/inf_7.cbc", 0, CL_ETIMEOUT, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_lsig_7_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/lsig_7.cbc", 0, 0, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_retmagic_7_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/retmagic_7.cbc", 0x1234f00d, CL_SUCCESS, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_testadt_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/testadt_7.cbc", 0xf00d, 0, 0, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_api_extract_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/api_extract_7.cbc", 0xf00d, 0, 1, "input/apitestfile", NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_api_files_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/api_files_7.cbc", 0xf00d, 0, 1, "input/apitestfile", NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_apicalls2_7_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/apicalls2_7.cbc", 0xf00d, 0, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_apicalls_7_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/apicalls_7.cbc", 0xf00d, 0, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_arith_7_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/arith_7.cbc", 0xd55555dd, CL_SUCCESS, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_debug_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/debug_7.cbc", 0xf00d, 0, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_inf_7_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/inf_7.cbc", 0, CL_ETIMEOUT, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_lsig_7_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/lsig_7.cbc", 0, 0, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_retmagic_7_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/retmagic_7.cbc", 0x1234f00d, CL_SUCCESS, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_testadt_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							| 
									
										
										
										
											2010-07-29 13:46:41 +03:00
										 |  |  |     runtest("input/testadt_7.cbc", 0xf00d, 0, 1, NULL, NULL, NULL, NULL, 0); | 
					
						
							| 
									
										
										
										
											2010-03-24 17:07:14 +02:00
										 |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-14 17:16:50 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | static void runload(const char *dbname, struct cl_engine* engine, unsigned signoexp) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const char * srcdir = getenv("srcdir"); | 
					
						
							|  |  |  |     char *str; | 
					
						
							|  |  |  |     unsigned signo = 0; | 
					
						
							|  |  |  |     int rc; | 
					
						
							|  |  |  |     if(!srcdir) { | 
					
						
							|  |  |  | 	/* when run from automake srcdir is set, but if run manually then not */ | 
					
						
							|  |  |  | 	srcdir = SRCDIR; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     str = cli_malloc(strlen(dbname)+strlen(srcdir)+2); | 
					
						
							|  |  |  |     fail_unless(!!str, "cli_malloc"); | 
					
						
							|  |  |  |     sprintf(str, "%s/%s", srcdir, dbname); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     rc = cl_load(str, engine, &signo, CL_DB_STDOPT); | 
					
						
							|  |  |  |     fail_unless_fmt(rc == CL_SUCCESS, "failed to load %s: %s\n", | 
					
						
							|  |  |  | 		    dbname, cl_strerror(rc)); | 
					
						
							|  |  |  |     fail_unless_fmt(signo == signoexp, "different number of signatures loaded, expected %u, got %u\n", | 
					
						
							|  |  |  | 		    signoexp, signo); | 
					
						
							|  |  |  |     free(str); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     rc = cl_engine_compile(engine); | 
					
						
							|  |  |  |     fail_unless_fmt(rc == CL_SUCCESS, "failed to load %s: %s\n", | 
					
						
							|  |  |  | 		    dbname, cl_strerror(rc)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_load_bytecode_jit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     struct cl_engine *engine; | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							|  |  |  |     engine = cl_engine_new(); | 
					
						
							|  |  |  |     fail_unless(!!engine, "failed to create engine\n"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     runload("input/bytecode.cvd", engine, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cl_engine_free(engine); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | START_TEST (test_load_bytecode_int) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     struct cl_engine *engine; | 
					
						
							|  |  |  |     cl_init(CL_INIT_DEFAULT); | 
					
						
							|  |  |  |     engine = cl_engine_new(); | 
					
						
							|  |  |  |     engine->dconf->bytecode = BYTECODE_INTERPRETER; | 
					
						
							|  |  |  |     fail_unless(!!engine, "failed to create engine\n"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     runload("input/bytecode.cvd", engine, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cl_engine_free(engine); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | END_TEST | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  | Suite *test_bytecode_suite(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Suite *s = suite_create("bytecode"); | 
					
						
							|  |  |  |     TCase *tc_cli_arith = tcase_create("arithmetic"); | 
					
						
							|  |  |  |     suite_add_tcase(s, tc_cli_arith); | 
					
						
							| 
									
										
										
										
											2010-03-30 11:10:58 +03:00
										 |  |  |     tcase_set_timeout(tc_cli_arith, 20); | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  |     tcase_add_test(tc_cli_arith, test_retmagic_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_arith_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_apicalls_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_apicalls2_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_div0_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_lsig_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_inf_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_matchwithread_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_pdf_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_bswap_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_inflate_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_retmagic_jit); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 12:09:07 +03:00
										 |  |  |     tcase_add_test(tc_cli_arith, test_arith_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_apicalls_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_apicalls2_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_div0_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_lsig_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_inf_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_matchwithread_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_pdf_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_bswap_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_inflate_int); | 
					
						
							| 
									
										
										
										
											2010-04-13 16:19:47 +03:00
										 |  |  |     tcase_add_test(tc_cli_arith, test_retmagic_int); | 
					
						
							| 
									
										
										
										
											2010-05-13 22:44:29 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_api_extract_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_api_files_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_apicalls2_7_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_apicalls_7_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_apicalls_7_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_arith_7_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_debug_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_inf_7_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_lsig_7_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_retmagic_7_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_testadt_jit); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_api_extract_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_api_files_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_apicalls2_7_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_apicalls_7_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_apicalls_7_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_arith_7_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_debug_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_inf_7_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_lsig_7_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_retmagic_int); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_testadt_int); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-14 17:16:50 +03:00
										 |  |  |     tcase_add_test(tc_cli_arith, test_load_bytecode_jit); | 
					
						
							|  |  |  |     tcase_add_test(tc_cli_arith, test_load_bytecode_int); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-13 19:45:05 +03:00
										 |  |  |     return s; | 
					
						
							|  |  |  | } |