]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd/sd-device/test-sd-device-thread.c
Merge pull request #16603 from benzea/benzea/special-app-slice
[thirdparty/systemd.git] / src / libsystemd / sd-device / test-sd-device-thread.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
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 static void* thread(void *p) {
14 sd_device **d = p;
15
16 assert_se(!(*d = sd_device_unref(*d)));
17
18 return NULL;
19 }
20
21 int main(int argc, char *argv[]) {
22 sd_device *loopback;
23 pthread_t t;
24 const char *key, *value;
25
26 assert_se(unsetenv("SYSTEMD_MEMPOOL") == 0);
27
28 assert_se(sd_device_new_from_syspath(&loopback, "/sys/class/net/lo") >= 0);
29
30 FOREACH_DEVICE_PROPERTY(loopback, key, value)
31 printf("%s=%s\n", key, value);
32
33 assert_se(pthread_create(&t, NULL, thread, &loopback) == 0);
34 assert_se(pthread_join(t, NULL) == 0);
35
36 assert_se(!loopback);
37
38 return 0;
39 }