LCOV - code coverage report
Current view: top level - test - test-async.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 12 15 80.0 %
Date: 2019-08-22 15:41:25 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #include <fcntl.h>
       4             : #include <unistd.h>
       5             : 
       6             : #include "async.h"
       7             : #include "macro.h"
       8             : #include "tmpfile-util.h"
       9             : #include "util.h"
      10             : 
      11             : static bool test_async = false;
      12             : 
      13           0 : static void *async_func(void *arg) {
      14           0 :         test_async = true;
      15             : 
      16           0 :         return NULL;
      17             : }
      18             : 
      19           1 : int main(int argc, char *argv[]) {
      20             :         int fd;
      21           1 :         char name[] = "/tmp/test-asynchronous_close.XXXXXX";
      22             : 
      23           1 :         fd = mkostemp_safe(name);
      24           1 :         assert_se(fd >= 0);
      25           1 :         asynchronous_close(fd);
      26             : 
      27           1 :         assert_se(asynchronous_job(async_func, NULL) >= 0);
      28             : 
      29           1 :         assert_se(asynchronous_sync(NULL) >= 0);
      30             : 
      31           1 :         sleep(1);
      32             : 
      33           1 :         assert_se(fcntl(fd, F_GETFD) == -1);
      34           1 :         assert_se(test_async);
      35             : 
      36           1 :         (void) unlink(name);
      37             : 
      38           1 :         return 0;
      39             : }

Generated by: LCOV version 1.14