... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Fri May 14 17:16:19 EEST 2010 (edwin) |
|
2 |
+------------------------------------- |
|
3 |
+ * unit_tests: add bytecode.cvd load test |
|
4 |
+ |
|
1 | 5 |
Fri May 14 11:28:52 EEST 2010 (edwin) |
2 | 6 |
------------------------------------- |
3 | 7 |
* libclamav/bytecode.c: handle global gep parameter correctly (bb #1955) |
... | ... |
@@ -460,6 +460,60 @@ START_TEST (test_testadt_int) |
460 | 460 |
} |
461 | 461 |
END_TEST |
462 | 462 |
|
463 |
+ |
|
464 |
+static void runload(const char *dbname, struct cl_engine* engine, unsigned signoexp) |
|
465 |
+{ |
|
466 |
+ const char * srcdir = getenv("srcdir"); |
|
467 |
+ char *str; |
|
468 |
+ unsigned signo = 0; |
|
469 |
+ int rc; |
|
470 |
+ if(!srcdir) { |
|
471 |
+ /* when run from automake srcdir is set, but if run manually then not */ |
|
472 |
+ srcdir = SRCDIR; |
|
473 |
+ } |
|
474 |
+ str = cli_malloc(strlen(dbname)+strlen(srcdir)+2); |
|
475 |
+ fail_unless(!!str, "cli_malloc"); |
|
476 |
+ sprintf(str, "%s/%s", srcdir, dbname); |
|
477 |
+ |
|
478 |
+ rc = cl_load(str, engine, &signo, CL_DB_STDOPT); |
|
479 |
+ fail_unless_fmt(rc == CL_SUCCESS, "failed to load %s: %s\n", |
|
480 |
+ dbname, cl_strerror(rc)); |
|
481 |
+ fail_unless_fmt(signo == signoexp, "different number of signatures loaded, expected %u, got %u\n", |
|
482 |
+ signoexp, signo); |
|
483 |
+ free(str); |
|
484 |
+ |
|
485 |
+ rc = cl_engine_compile(engine); |
|
486 |
+ fail_unless_fmt(rc == CL_SUCCESS, "failed to load %s: %s\n", |
|
487 |
+ dbname, cl_strerror(rc)); |
|
488 |
+} |
|
489 |
+ |
|
490 |
+START_TEST (test_load_bytecode_jit) |
|
491 |
+{ |
|
492 |
+ struct cl_engine *engine; |
|
493 |
+ cl_init(CL_INIT_DEFAULT); |
|
494 |
+ engine = cl_engine_new(); |
|
495 |
+ fail_unless(!!engine, "failed to create engine\n"); |
|
496 |
+ |
|
497 |
+ runload("input/bytecode.cvd", engine, 5); |
|
498 |
+ |
|
499 |
+ cl_engine_free(engine); |
|
500 |
+} |
|
501 |
+END_TEST |
|
502 |
+ |
|
503 |
+START_TEST (test_load_bytecode_int) |
|
504 |
+{ |
|
505 |
+ struct cl_engine *engine; |
|
506 |
+ cl_init(CL_INIT_DEFAULT); |
|
507 |
+ engine = cl_engine_new(); |
|
508 |
+ engine->dconf->bytecode = BYTECODE_INTERPRETER; |
|
509 |
+ fail_unless(!!engine, "failed to create engine\n"); |
|
510 |
+ |
|
511 |
+ runload("input/bytecode.cvd", engine, 5); |
|
512 |
+ |
|
513 |
+ cl_engine_free(engine); |
|
514 |
+} |
|
515 |
+END_TEST |
|
516 |
+ |
|
463 | 517 |
Suite *test_bytecode_suite(void) |
464 | 518 |
{ |
465 | 519 |
Suite *s = suite_create("bytecode"); |
... | ... |
@@ -515,5 +569,8 @@ Suite *test_bytecode_suite(void) |
515 | 515 |
tcase_add_test(tc_cli_arith, test_retmagic_int); |
516 | 516 |
tcase_add_test(tc_cli_arith, test_testadt_int); |
517 | 517 |
|
518 |
+ tcase_add_test(tc_cli_arith, test_load_bytecode_jit); |
|
519 |
+ tcase_add_test(tc_cli_arith, test_load_bytecode_int); |
|
520 |
+ |
|
518 | 521 |
return s; |
519 | 522 |
} |