summaryrefslogtreecommitdiffstats
path: root/qa/test-conntrack.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2012-05-26 17:43:49 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2012-05-26 17:44:51 +0200
commit0e1ce4f491e2134d6207f55c4a5f52e157a54707 (patch)
tree8acfb557824eeb93f645622edd1d5be06501a533 /qa/test-conntrack.c
parent1975dc432a57a78880e28aadceb3d7bcf923fe8b (diff)
move qa directory to tests/conntrack/
All automated testing for the conntrack-tools will now reside under the test directory. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'qa/test-conntrack.c')
-rw-r--r--qa/test-conntrack.c94
1 files changed, 0 insertions, 94 deletions
diff --git a/qa/test-conntrack.c b/qa/test-conntrack.c
deleted file mode 100644
index c9097b6..0000000
--- a/qa/test-conntrack.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Very simple test-tool for the command line tool `conntrack'.
- * This code is released under GPLv2 or any later at your option.
- *
- * gcc test-conntrack.c -o test
- *
- * Do not forget that you need *root* or CAP_NET_ADMIN capabilities ;-)
- *
- * (c) 2008 Pablo Neira Ayuso <pablo@netfilter.org>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <dirent.h>
-
-#define CT_PROG "/usr/sbin/conntrack"
-
-int main()
-{
- int ret, ok = 0, bad = 0, line;
- FILE *fp;
- DIR *d;
- char buf[1024];
- struct dirent *dent;
- char file[1024];
-
- d = opendir("testsuite");
-
- while ((dent = readdir(d)) != NULL) {
-
- sprintf(file, "testsuite/%s", dent->d_name);
-
- line = 0;
-
- fp = fopen(file, "r");
- if (fp == NULL) {
- perror("cannot find testsuite file");
- exit(EXIT_FAILURE);
- }
-
- while (fgets(buf, sizeof(buf), fp)) {
- char tmp[1024] = CT_PROG, *res;
- tmp[strlen(CT_PROG)] = ' ';
-
- line++;
-
- if (buf[0] == '#' || buf[0] == ' ')
- continue;
-
- res = strchr(buf, ';');
- if (!res) {
- printf("malformed file %s at line %d\n",
- dent->d_name, line);
- exit(EXIT_FAILURE);
- }
- *res = '\0';
- res+=2;
-
- strcpy(tmp + strlen(CT_PROG) + 1, buf);
- printf("(%d) Executing: %s\n", line, tmp);
-
- ret = system(tmp);
-
- if (WIFEXITED(ret) &&
- WEXITSTATUS(ret) == EXIT_SUCCESS) {
- if (res[0] == 'O' &&
- res[1] == 'K')
- ok++;
- else {
- bad++;
- printf("^----- BAD\n");
- }
- } else {
- if (res[0] == 'B' &&
- res[1] == 'A' &&
- res[2] == 'D')
- ok++;
- else {
- bad++;
- printf("^----- BAD\n");
- }
- }
- printf("=====\n");
- }
- fclose(fp);
- }
- closedir(d);
-
- fprintf(stdout, "OK: %d BAD: %d\n", ok, bad);
-}