Code

t/utils/channel_test: Added a test-case for sdb_channel_select().
authorSebastian Harl <sh@tokkee.org>
Sun, 20 Oct 2013 13:37:03 +0000 (15:37 +0200)
committerSebastian Harl <sh@tokkee.org>
Sun, 20 Oct 2013 13:37:03 +0000 (15:37 +0200)
t/utils/channel_test.c

index 30fc263a263a33b6edfc655bfcb8682174d98e7c..20fd4543c4360fdbb2b1f473ce2a7ac517f448eb 100644 (file)
@@ -29,6 +29,7 @@
 #include "libsysdb_test.h"
 
 #include <check.h>
+#include <errno.h>
 #include <limits.h>
 
 #include <stdint.h>
@@ -146,6 +147,28 @@ START_TEST(test_write_read)
 }
 END_TEST
 
+START_TEST(test_select)
+{
+       struct timespec ts = { 0, 10 };
+       int check;
+       int data;
+
+       chan = sdb_channel_create(0, 1);
+
+       check = sdb_channel_select(chan, &data, NULL, NULL, NULL, &ts);
+       fail_unless(check == ETIMEDOUT,
+                       "sdb_channel_select() = %i; expected: %i (ETIMEDOUT)",
+                       check, ETIMEDOUT);
+
+       check = sdb_channel_select(chan, NULL, NULL, &data, NULL, NULL);
+       fail_unless(! check, "sdb_channel_select() = %i; expected: 0", check);
+       check = sdb_channel_select(chan, NULL, NULL, &data, NULL, &ts);
+       fail_unless(! check, "sdb_channel_select() = %i; expected: 0", check);
+
+       sdb_channel_destroy(chan);
+}
+END_TEST
+
 START_TEST(test_write_int)
 {
        size_t i;
@@ -320,6 +343,7 @@ util_channel_suite(void)
        tc = tcase_create("core");
        tcase_add_test(tc, test_create);
        tcase_add_test(tc, test_write_read);
+       tcase_add_test(tc, test_select);
        suite_add_tcase(s, tc);
 
        tc = tcase_create("integer");