[Patch 6/8] CLD: cleanup: add a event stub just to test

Pete Zaitcev <[email protected]> Wed, 14 Apr 2010 12:35:08 -0600
Newsgroups org.kernel.vger.hail-devel
Message-ID <[email protected]>
Tests do not really need this kind of thing, in fact if everything
goes well, we should NOT receive any events while test is running.
Still, I am curious about being sure that we do not. This will also
pop if we change something in the library implementation and start
leaking some events.

Signed-off-by: Pete Zaitcev <[email protected]>

---
 test/lock-file.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/test/lock-file.c b/test/lock-file.c
index 36cc62c..3bbe49b 100644
--- a/test/lock-file.c
+++ b/test/lock-file.c
@@ -31,6 +31,15 @@
 #include <ncld.h>
 #include "test.h"
 
+static void sess_event(void *priv, unsigned int what)
+{
+	if (what == CE_SESS_FAILED) {
+		fprintf(stderr, "Session failed\n");
+		exit(1);
+	}
+	fprintf(stderr, "Unknown event %d\n", what);
+}
+
 int main (int argc, char *argv[])
 {
 	struct ncld_sess *nsess;
@@ -49,7 +58,7 @@ int main (int argc, char *argv[])
 	if (port == 0)
 		return -1;
 
-	nsess = ncld_sess_open(TEST_HOST, port, &error, NULL, NULL,
+	nsess = ncld_sess_open(TEST_HOST, port, &error, sess_event, NULL,
 			     TEST_USER, TEST_USER_KEY, NULL);
 	if (!nsess) {
 		fprintf(stderr, "ncld_sess_open(host %s port %u) failed: %d\n",