[Forensics-changes] [yara] 164/407: Add test case for functions receiving strings

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:28:22 UTC 2017


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag v3.3.0
in repository yara.

commit 557aa9ac480f9272647a8ed4e762af92835955b7
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Thu Oct 30 11:56:07 2014 +0100

    Add test case for functions receiving strings
---
 libyara/modules/tests.c | 9 +++++++++
 yara-python/tests.py    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libyara/modules/tests.c b/libyara/modules/tests.c
index af11277..04295dc 100644
--- a/libyara/modules/tests.c
+++ b/libyara/modules/tests.c
@@ -43,6 +43,14 @@ define_function(sum_3)
   return_integer(a + b + c);
 }
 
+
+define_function(length)
+{
+  char* s = string_argument(1);
+
+  return_integer(strlen(s));
+}
+
 begin_declarations;
 
   begin_struct("constants");
@@ -69,6 +77,7 @@ begin_declarations;
 
   declare_function("sum", "ii", "i", sum_2);
   declare_function("sum", "iii", "i", sum_3);
+  declare_function("length", "s", "i", length);
 
 end_declarations;
 
diff --git a/yara-python/tests.py b/yara-python/tests.py
index cb89074..9ec5a63 100644
--- a/yara-python/tests.py
+++ b/yara-python/tests.py
@@ -711,7 +711,8 @@ class TestYara(unittest.TestCase):
             'import "tests" rule test { condition: tests.string_dict["foo"] == "foo"}',
             'import "tests" rule test { condition: tests.string_dict["bar"] == "bar"}',
             'import "tests" rule test { condition: tests.sum(1,2) == 3}',
-            'import "tests" rule test { condition: tests.sum(1,2,3) == 6}'
+            'import "tests" rule test { condition: tests.sum(1,2,3) == 6}',
+            'import "tests" rule test { condition: tests.length("dummy") == 5}',
           ])
 
         self.assertFalseRules([

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git



More information about the forensics-changes mailing list