summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2013-02-18 12:02:33 -0800
committerLucas De Marchi <lucas.de.marchi@gmail.com>2013-02-19 19:19:51 -0300
commite87352d289aa19ed388e9e19507d86a39936f3b4 (patch)
tree8d6fd59dc0fd13a35e8c86ba6229e19ff8bda3b0 /testsuite
parent144d1826f1a0fcd6cc59c4535f0a8145163c640c (diff)
downloadkmod-e87352d289aa19ed388e9e19507d86a39936f3b4.tar.gz
kmod-e87352d289aa19ed388e9e19507d86a39936f3b4.tar.bz2
kmod-e87352d289aa19ed388e9e19507d86a39936f3b4.zip
testsuite: handle finit_module
This adds the finit_module logic to the testsuite.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/init_module.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/testsuite/init_module.c b/testsuite/init_module.c
index c4d7efb..ca9f84c 100644
--- a/testsuite/init_module.c
+++ b/testsuite/init_module.c
@@ -28,6 +28,7 @@
#include <stddef.h>
#include <string.h>
#include <stdio.h>
+#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -274,6 +275,29 @@ long init_module(void *mem, unsigned long len, const char *args)
return err;
}
+TS_EXPORT int finit_module(const int fd, const char *args, const int flags);
+
+int finit_module(const int fd, const char *args, const int flags)
+{
+ int err;
+ void *mem;
+ unsigned long len;
+ struct stat st;
+
+ if (fstat(fd, &st) < 0)
+ return -1;
+
+ len = st.st_size;
+ mem = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (mem == MAP_FAILED)
+ return -1;
+
+ err = init_module(mem, len, args);
+ munmap(mem, len);
+
+ return err;
+}
+
/* the test is going away anyway, but lets keep valgrind happy */
void free_resources(void) __attribute__((destructor));
void free_resources(void)