summaryrefslogtreecommitdiff
path: root/src/test/test-fdset.c
diff options
context:
space:
mode:
authorRonny Chevalier <chevalier.ronny@gmail.com>2014-08-16 14:19:08 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-18 18:43:52 +0200
commitd7aeffea144c2c6bfee4e63131bb2b6c460de678 (patch)
tree38e9a95937d451e1f31a2aa9eb32dd90d247c59d /src/test/test-fdset.c
parent0709b743749c42f54ffc0d9aeacf7bff45d65af6 (diff)
tests: add test for fdset_iterate
Diffstat (limited to 'src/test/test-fdset.c')
-rw-r--r--src/test/test-fdset.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/test-fdset.c b/src/test/test-fdset.c
index 3b77415c3a..91df7eb663 100644
--- a/src/test/test-fdset.c
+++ b/src/test/test-fdset.c
@@ -126,12 +126,41 @@ static void test_fdset_remove(void) {
unlink(name);
}
+static void test_fdset_iterate(void) {
+ int fd = -1;
+ FDSet *fdset = NULL;
+ char name[] = "/tmp/test-fdset_iterate.XXXXXX";
+ Iterator i;
+ int c = 0;
+ int a;
+
+ fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
+ assert_se(fd >= 0);
+
+ fdset = fdset_new();
+ assert_se(fdset);
+ assert_se(fdset_put(fdset, fd) >= 0);
+ assert_se(fdset_put(fdset, fd) >= 0);
+ assert_se(fdset_put(fdset, fd) >= 0);
+
+ FDSET_FOREACH(a, fdset, i) {
+ c++;
+ assert_se(a == fd);
+ }
+ assert_se(c == 1);
+
+ fdset_free(fdset);
+
+ unlink(name);
+}
+
int main(int argc, char *argv[]) {
test_fdset_new_fill();
test_fdset_put_dup();
test_fdset_cloexec();
test_fdset_close_others();
test_fdset_remove();
+ test_fdset_iterate();
return 0;
}