Re: [PATCH 1/2, libnftnl] tests: Consolidate printing error utilities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/12/2016 01:26 AM, Pablo Neira Ayuso wrote:
On Thu, Aug 11, 2016 at 03:25:06PM +0200, Carlos Falgueras García wrote:
diff --git a/tests/libtest.c b/tests/libtest.c
new file mode 100644
index 0000000..91f2d5e
--- /dev/null
+++ b/tests/libtest.c
@@ -0,0 +1,49 @@
+#include <libtest.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+#include <stdbool.h>
+
+#define COLOR_RED     "\x1b[31m"
+#define COLOR_GREEN   "\x1b[32m"
+#define COLOR_RESET   "\x1b[0m"
+
+static bool test_ok = true;

I don't like this internal test_ok.

I will get rid of this at the next patch. Doing it here means change a lot of code that I will delete in the next patch.

 static void cmp_nftnl_chain(struct nftnl_chain *a, struct nftnl_chain *b)
 {
@@ -73,7 +67,7 @@ int main(int argc, char *argv[])
 	a = nftnl_chain_alloc();
 	b = nftnl_chain_alloc();
 	if (a == NULL || b == NULL)
-		print_err("OOM");
+		oom(argv[0]);

You can replace this above by:

        test_assert(a != NULL);
        test_assert(b != NULL);

I have changed this to 'oom_assert()' to distinguish it from a future 'test_assert' that will replace current 'print_err'.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux