Merge branch 'topic/mm-fixes' of git://208.110.73.182/silc into silc.1.1.branch
[silc.git] / lib / silcutil / tests / test_silcasync.c
index 836daecbee1d8ec840f8d53b85227148dc9f47c7..ca68c7d01f6703a272f1742f68f264e9762d19d1 100644 (file)
@@ -1,6 +1,6 @@
 /* SilcAsyncOperation tests */
 
-#include "silcincludes.h"
+#include "silc.h"
 #include "silcfsm.h"
 #include "silcasync.h"
 
@@ -10,11 +10,11 @@ SilcSchedule schedule;
 
 typedef struct {
   SilcFSM fsm;
-  SilcFSMSemaStruct sema;
+  SilcFSMEventStruct sema;
   SilcAsyncOperation op;
   Callback cb;
   void *cb_context;
-  bool aborted;
+  SilcBool aborted;
 } *Foo;
 
 SILC_FSM_STATE(test_st_start);
@@ -59,7 +59,7 @@ static void async_call_cb(void *context)
   Foo f = context;
   SILC_LOG_DEBUG(("*******Callback, signal and continue to next state"));
   f->op = NULL;
-  SILC_FSM_SEMA_POST(&f->sema);
+  SILC_FSM_EVENT_SIGNAL(&f->sema);
   SILC_FSM_CALL_CONTINUE(f->fsm);
 }
 
@@ -69,7 +69,7 @@ SILC_FSM_STATE(test_st_start)
 
   SILC_LOG_DEBUG(("test_st_start"));
 
-  silc_fsm_sema_init(&f->sema, fsm, 0);
+  silc_fsm_event_init(&f->sema, fsm);
 
   /** Wait async callback */
   SILC_LOG_DEBUG(("Call async call"));
@@ -80,14 +80,17 @@ SILC_FSM_STATE(test_st_start)
 SILC_FSM_STATE(test_st_second)
 {
   Foo f = fsm_context;
+  SilcBool timedout;
 
   SILC_LOG_DEBUG(("test_st_second"));
 
-  SILC_FSM_SEMA_TIMEDWAIT(&f->sema, 0, 1);
+  SILC_FSM_EVENT_TIMEDWAIT(&f->sema, 0, 1, &timedout);
 
-  SILC_LOG_DEBUG(("Sema timedout, aborting async operation"));
-  if (f->op)
-    silc_async_abort(f->op, NULL, NULL);
+  if (timedout == TRUE) {
+    SILC_LOG_DEBUG(("Sema timedout, aborting async operation"));
+    if (f->op)
+      silc_async_abort(f->op, NULL, NULL);
+  }
 
   /** Finish */
   silc_fsm_next_later(fsm, test_st_finish, 2, 0);
@@ -112,7 +115,7 @@ static void destructor(SilcFSM fsm, void *fsm_context,
 
 int main(int argc, char **argv)
 {
-  bool success = FALSE;
+  SilcBool success = FALSE;
   SilcFSM fsm;
   Foo f;