]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add unit test for event duration
authorAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 7 Nov 2018 07:51:50 +0000 (09:51 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Wed, 14 Nov 2018 12:14:56 +0000 (14:14 +0200)
Make sure event duration is non-zero when used without
ioloop.

src/lib/test-event-log.c

index 330fb23ed3f0692b2afb7e69ce2784ad107558ed..622bf519df386d4bd56b3eeeeadb07fa8e504e28 100644 (file)
@@ -5,6 +5,8 @@
 #include "str.h"
 #include "failures-private.h"
 
+#include <unistd.h>
+
 enum test_log_prefix_type {
        TYPE_END,
        TYPE_APPEND,
@@ -181,7 +183,21 @@ static void test_event_log_prefix(void)
        test_end();
 }
 
+static void test_event_duration()
+{
+       intmax_t duration;
+       test_begin("event duration");
+       struct event *e = event_create(NULL);
+       usleep(10);
+       e_info(e, "Submit event");
+       event_get_last_duration(e, &duration);
+       test_assert(duration > 0);
+       event_unref(&e);
+       test_end();
+}
+
 void test_event_log(void)
 {
        test_event_log_prefix();
+       test_event_duration();
 }