[Forensics-changes] [yara] 245/368: Add assert_false_rule_file macro

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:30:44 UTC 2017


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

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

commit cdcacdeb511cd8dd8481e4a40431843e5d960de6
Author: Hilko Bengen <bengen at hilluzination.de>
Date:   Thu Mar 31 01:15:44 2016 +0200

    Add assert_false_rule_file macro
---
 tests/util.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/tests/util.h b/tests/util.h
index 8ecb168..80919e7 100644
--- a/tests/util.h
+++ b/tests/util.h
@@ -97,6 +97,23 @@ int read_file(
     }                                                                   \
   } while (0);
 
+#define assert_false_rule_file(rule, filename)                          \
+  do {                                                                  \
+    char* buf;                                                          \
+    size_t sz;                                                          \
+    if ((sz = read_file(filename, &buf)) == -1) {                       \
+      fprintf(stderr, "%s:%d: cannot read file '%s'\n",                 \
+              __FILE__, __LINE__, filename);                            \
+      exit(EXIT_FAILURE);                                               \
+    }                                                                   \
+    if (matches_blob(rule, (uint8_t*) (buf), sz)) {                     \
+      fprintf(stderr, "%s:%d: rule matches contents of"                 \
+              "'%s' (but shouldn't)\n",                                 \
+              __FILE__, __LINE__, filename);                            \
+      exit(EXIT_FAILURE);                                               \
+    }                                                                   \
+  } while (0);
+
 #define assert_syntax_correct(rule) do {                                \
     if (compile_rule(rule) == NULL) {                                   \
       fprintf(stderr, "%s:%d: rule << %s >> can't be compiled: %s\n",   \

-- 
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