diff options
author | Ronny Chevalier <chevalier.ronny@gmail.com> | 2014-06-21 22:07:12 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-06-22 00:36:19 +0200 |
commit | 2de61bbebfe6a1a97709b3277b150cacc30a79cd (patch) | |
tree | e4a890f25d06ca75d2ace6df8828312ff7fc1825 /src/test | |
parent | e6b5c5d03cb28d2149dc1c124c2a315911b91f4f (diff) |
tests: add test_fdset_remove
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-fdset.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/test-fdset.c b/src/test/test-fdset.c index 7f52748ccb..3b77415c3a 100644 --- a/src/test/test-fdset.c +++ b/src/test/test-fdset.c @@ -106,11 +106,32 @@ static void test_fdset_close_others(void) { unlink(name); } +static void test_fdset_remove(void) { + _cleanup_close_ int fd = -1; + FDSet *fdset = NULL; + char name[] = "/tmp/test-fdset_remove.XXXXXX"; + + 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_remove(fdset, fd) >= 0); + assert_se(!fdset_contains(fdset, fd)); + fdset_free(fdset); + + assert_se(fcntl(fd, F_GETFD) >= 0); + + 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(); return 0; } |