[Forensics-changes] [yara] 71/135: Add test case for functions in modules
Hilko Bengen
bengen at moszumanska.debian.org
Sat Jul 1 10:27:33 UTC 2017
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag v3.1.0
in repository yara.
commit 8552b47a45b8a9a159320c777687ae1854859369
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Thu Jul 24 11:08:33 2014 +0200
Add test case for functions in modules
---
libyara/modules/tests.c | 14 ++++++++++++++
yara-python/tests.py | 4 +++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/libyara/modules/tests.c b/libyara/modules/tests.c
index 58000da..1192237 100644
--- a/libyara/modules/tests.c
+++ b/libyara/modules/tests.c
@@ -18,6 +18,18 @@ limitations under the License.
#define MODULE_NAME tests
+
+define_function(sum)
+{
+ int64_t a = integer_argument(1);
+ int64_t b = integer_argument(1);
+
+ if (a == UNDEFINED || b == UNDEFINED)
+ return_integer(UNDEFINED);
+
+ return_integer(a + b);
+}
+
begin_declarations;
begin_struct("constants");
@@ -34,6 +46,8 @@ begin_declarations;
string("s");
end_struct_array("struct_array");
+ function("sum", "ii", "i", sum);
+
end_declarations;
diff --git a/yara-python/tests.py b/yara-python/tests.py
index caf7a78..b56de87 100644
--- a/yara-python/tests.py
+++ b/yara-python/tests.py
@@ -703,10 +703,12 @@ class TestYara(unittest.TestCase):
'import "tests" rule test { condition: tests.integer_array[1] == 1}',
'import "tests" rule test { condition: tests.string_array[0] == "foo"}',
'import "tests" rule test { condition: tests.string_array[2] == "baz"}',
+ 'import "tests" rule test { condition: tests.sum(1,1) == 2}',
])
self.assertFalseRules([
- 'import "tests" rule test { condition: tests.struct_array[0].i == 1 }'
+ 'import "tests" rule test { condition: tests.struct_array[0].i == 1 }',
+ 'import "tests" rule test { condition: tests.sum(1,1) == 3}',
])
--
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