Skip to contentSkip to conversation

CLD: cleanup: add a event stub just to test

PATCH Applied Pete Zaitcev 1 participant 1 message Apr 14, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 6/8 CLD: cleanup: add a event stub just to test

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.

---
 test/lock-file.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
test/lock-file.c +10 -1
index 36cc62c..3bbe49b 100644
@@ -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",