[fprint] [PATCH 3/8] lib: Add test program to test dynamic driver loading.

Kunal Gangakhedkar kunal.gangakhedkar at gmail.com
Mon Oct 8 07:39:27 PDT 2012


Also, enable building of the program in examples/Makefile.am as well.

Signed-off-by: Kunal Gangakhedkar <kunal.gangakhedkar at gmail.com>
---
 examples/Makefile.am   |    5 ++++-
 examples/test_driver.c |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 examples/test_driver.c

diff --git a/examples/Makefile.am b/examples/Makefile.am
index b045ddb..7d44efe 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,5 +1,5 @@
 INCLUDES = -I$(top_srcdir)
-noinst_PROGRAMS = verify_live enroll verify img_capture cpp-test
+noinst_PROGRAMS = verify_live enroll verify img_capture cpp-test test_driver
 
 verify_live_SOURCES = verify_live.c
 verify_live_LDADD = ../libfprint/libfprint.la
@@ -16,6 +16,9 @@ img_capture_LDADD = ../libfprint/libfprint.la
 cpp_test_SOURCES = cpp-test.cpp
 cpp_test_LDADD = ../libfprint/libfprint.la
 
+test_driver_SOURCES = test_driver.c
+test_driver_LDADD = ../libfprint/libfprint.la
+
 if BUILD_X11_EXAMPLES
 noinst_PROGRAMS += img_capture_continuous
 
diff --git a/examples/test_driver.c b/examples/test_driver.c
new file mode 100644
index 0000000..d03d1bb
--- /dev/null
+++ b/examples/test_driver.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+
+#include "libfprint/module.h"
+
+int main(int argc, char** argv)
+{
+	int rc = 0;
+	rc = load_module("drv_vfs101.so");
+	if (rc < 0)
+		goto out;
+
+	rc = load_module("drv_uru4000.so");
+	if (rc < 0)
+		goto out;
+
+	rc = load_module("drv_nonexistent.so");
+
+	if (argc > 1) {
+		rc = load_module(argv[1]);
+	}
+
+	// Try unloading a module.
+	rc = unload_module("drv_vfs101.so");
+
+	// try unloading a non-existent module..
+	rc = unload_module("drv_nonexistent.so");
+
+	// Try unloading another module.
+	rc = unload_module("drv_uru4000.so");
+out:
+	return rc;
+}
-- 
1.7.9.5



More information about the fprint mailing list