All of lore.kernel.org
 help / color / mirror / Atom feed
* [libnftables PATCH 1/6] test: return EXIT_FAILURE if some error was found
@ 2013-10-31 12:36 Arturo Borrero Gonzalez
  2013-10-31 12:36 ` [libnftables PATCH 2/6] test: fix memleak in XML testing Arturo Borrero Gonzalez
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Arturo Borrero Gonzalez @ 2013-10-31 12:36 UTC (permalink / raw)
  To: netfilter-devel

Before this patch, 0 was returned unconditionally.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 tests/nft-parsing-test.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c
index 866c985..70028a0 100644
--- a/tests/nft-parsing-test.c
+++ b/tests/nft-parsing-test.c
@@ -234,7 +234,7 @@ static int test_json(const char *filename)
 			if (nft_ruleset_parse(rs, NFT_RULESET_PARSE_JSON, json) == 0)
 				ret = compare_test(TEST_JSON_RULESET, rs, filename);
 			else
-				ret = -1;
+				goto failparsing;
 
 			nft_ruleset_free(rs);
 			}
@@ -329,7 +329,7 @@ static int test_xml(const char *filename)
 				ret = compare_test(TEST_XML_RULESET, rs,
 						   filename);
 			else
-				ret = -1;
+				goto failparsing;
 
 			nft_ruleset_free(rs);
 		}
@@ -352,6 +352,7 @@ int main(int argc, char *argv[])
 	DIR *d;
 	struct dirent *dent;
 	char path[PATH_MAX];
+	int ret = 0, exit_code = 0;
 
 	if (argc != 2) {
 		fprintf(stderr, "Usage: %s <directory>\n", argv[0]);
@@ -374,19 +375,25 @@ int main(int argc, char *argv[])
 		snprintf(path, sizeof(path), "%s/%s", argv[1], dent->d_name);
 
 		if (strcmp(&dent->d_name[len-4], ".xml") == 0) {
-			if (test_xml(path) == 0) {
+			if ((ret = test_xml(path)) == 0) {
 				printf("parsing and validating %s: ", path);
 				printf("\033[32mOK\e[0m\n");
 			}
+			exit_code += ret;
 		}
 		if (strcmp(&dent->d_name[len-5], ".json") == 0) {
-			if (test_json(path) == 0) {
+			if ((ret = test_json(path)) == 0) {
 				printf("parsing and validating %s: ", path);
 				printf("\033[32mOK\e[0m\n");
 			}
+			exit_code += ret;
 		}
 	}
 
 	closedir(d);
+
+	if (exit_code != 0)
+		exit(EXIT_FAILURE);
+
 	return 0;
 }


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-11-03 21:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-31 12:36 [libnftables PATCH 1/6] test: return EXIT_FAILURE if some error was found Arturo Borrero Gonzalez
2013-10-31 12:36 ` [libnftables PATCH 2/6] test: fix memleak in XML testing Arturo Borrero Gonzalez
2013-11-03 21:30   ` Pablo Neira Ayuso
2013-10-31 12:36 ` [libnftables PATCH 3/6] test: use constants for coloured strings Arturo Borrero Gonzalez
2013-11-03 21:31   ` Pablo Neira Ayuso
2013-10-31 12:36 ` [libnftables PATCH 4/6] test: report errors building XML tree Arturo Borrero Gonzalez
2013-11-03 21:31   ` Pablo Neira Ayuso
2013-10-31 12:36 ` [libnftables PATCH 5/6] test: style cleanup Arturo Borrero Gonzalez
2013-11-03 21:33   ` Pablo Neira Ayuso
2013-10-31 12:36 ` [libnftables PATCH 6/6] test: report compilation without support Arturo Borrero Gonzalez
2013-11-03 21:33   ` Pablo Neira Ayuso
2013-11-03 21:29 ` [libnftables PATCH 1/6] test: return EXIT_FAILURE if some error was found Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.