LCOV - code coverage report
Current view: top level - libsystemd/sd-device - test-sd-device-thread.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 13 13 100.0 %
Date: 2019-08-22 15:41:25 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #include <pthread.h>
       4             : #include <stdbool.h>
       5             : #include <stdio.h>
       6             : #include <stdlib.h>
       7             : 
       8             : #include "sd-device.h"
       9             : 
      10             : #include "device-util.h"
      11             : #include "macro.h"
      12             : 
      13           1 : static void* thread(void *p) {
      14           1 :         sd_device **d = p;
      15             : 
      16           1 :         assert_se(!(*d = sd_device_unref(*d)));
      17             : 
      18           1 :         return NULL;
      19             : }
      20             : 
      21           1 : int main(int argc, char *argv[]) {
      22             :         sd_device *loopback;
      23             :         pthread_t t;
      24             :         const char *key, *value;
      25             : 
      26           1 :         assert_se(unsetenv("SYSTEMD_MEMPOOL") == 0);
      27             : 
      28           1 :         assert_se(sd_device_new_from_syspath(&loopback, "/sys/class/net/lo") >= 0);
      29             : 
      30           8 :         FOREACH_DEVICE_PROPERTY(loopback, key, value)
      31           7 :                 printf("%s=%s\n", key, value);
      32             : 
      33           1 :         assert_se(pthread_create(&t, NULL, thread, &loopback) == 0);
      34           1 :         assert_se(pthread_join(t, NULL) == 0);
      35             : 
      36           1 :         assert_se(!loopback);
      37             : 
      38           1 :         return 0;
      39             : }

Generated by: LCOV version 1.14