summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--configure.in2
-rw-r--r--qa/Makefile.am7
-rw-r--r--qa/test_api.c102
4 files changed, 111 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 262028c..f31ebb4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@ include $(top_srcdir)/Make_global.am
AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6
-SUBDIRS = include src utils
+SUBDIRS = include src utils qa
man_MANS = #nfnetlink_conntrack.3 nfnetlink_conntrack.7
diff --git a/configure.in b/configure.in
index 6768235..0aa9c40 100644
--- a/configure.in
+++ b/configure.in
@@ -78,5 +78,5 @@ LIBNFCONNTRACK_LIBS="$LIBNFNETLINK_LIBS"
AC_SUBST(LIBNFCONNTRACK_LIBS)
dnl Output the makefile
-AC_OUTPUT(Makefile src/Makefile include/Makefile utils/Makefile include/libnetfilter_conntrack/Makefile include/internal/Makefile src/conntrack/Makefile src/expect/Makefile src/deprecated/Makefile src/deprecated/l3extensions/Makefile src/deprecated/extensions/Makefile libnetfilter_conntrack.pc)
+AC_OUTPUT(Makefile src/Makefile include/Makefile utils/Makefile qa/Makefile include/libnetfilter_conntrack/Makefile include/internal/Makefile src/conntrack/Makefile src/expect/Makefile src/deprecated/Makefile src/deprecated/l3extensions/Makefile src/deprecated/extensions/Makefile libnetfilter_conntrack.pc)
diff --git a/qa/Makefile.am b/qa/Makefile.am
new file mode 100644
index 0000000..6a9471b
--- /dev/null
+++ b/qa/Makefile.am
@@ -0,0 +1,7 @@
+include $(top_srcdir)/Make_global.am
+
+check_PROGRAMS = test_api
+
+test_api_SOURCES = test_api.c
+test_api_LDADD = ../src/libnetfilter_conntrack.la
+test_api_LDFLAGS = -dynamic -ldl
diff --git a/qa/test_api.c b/qa/test_api.c
new file mode 100644
index 0000000..eda9d49
--- /dev/null
+++ b/qa/test_api.c
@@ -0,0 +1,102 @@
+/*
+ * Run this after adding a new attribute to the nf_conntrack object
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
+
+/*
+ * this file contains a test to check the set/get/copy/cmp APIs.
+ */
+
+static eval_sigterm(int status)
+{
+ switch(WTERMSIG(status)) {
+ case SIGSEGV:
+ printf("received SIGSEV\n");
+ break;
+ case 0:
+ printf("OK\n", WTERMSIG(status));
+ break;
+ default:
+ printf("exited with signal: %d\n", WTERMSIG(status));
+ break;
+ }
+}
+
+int main()
+{
+ int ret, i;
+ struct nfct_handle *h;
+ struct nf_conntrack *ct, *tmp;
+ char data[32];
+ int status;
+
+ /* initialize fake data for testing purposes */
+ for (i=0; i<sizeof(data); i++)
+ data[i] = 0x01;
+
+ ct = nfct_new();
+ if (!ct) {
+ perror("nfct_new");
+ return 0;
+ }
+ tmp = nfct_new();
+ if (!tmp) {
+ perror("nfct_new");
+ return 0;
+ }
+
+ printf("== test set API ==\n");
+ ret = fork();
+ if (ret == 0) {
+ for (i=0; i<ATTR_MAX; i++)
+ nfct_set_attr(ct, i, data);
+ exit(0);
+ } else {
+ wait(&status);
+ eval_sigterm(status);
+ }
+
+ for (i=0; i<ATTR_MAX; i++)
+ nfct_set_attr(ct, i, data);
+
+ printf("== test get API ==\n");
+ ret = fork();
+ if (ret == 0) {
+ for (i=0; i<ATTR_MAX; i++)
+ nfct_get_attr(ct, i);
+ exit(0);
+ } else {
+ wait(&status);
+ eval_sigterm(status);
+ }
+
+ printf("== test copy API ==\n");
+ ret = fork();
+ if (ret == 0) {
+ for (i=0; i<ATTR_MAX; i++)
+ nfct_copy_attr(tmp, ct, i);
+ exit(0);
+ } else {
+ wait(&status);
+ eval_sigterm(status);
+ }
+
+ printf("== test cmp API ==\n");
+ ret = fork();
+ if (ret == 0) {
+ nfct_cmp(tmp, ct, NFCT_CMP_ALL);
+ exit(0);
+ } else {
+ wait(&status);
+ eval_sigterm(status);
+ }
+
+ nfct_destroy(ct);
+ nfct_destroy(tmp);
+}