OSDN Git Service

Merge tag 'ceph-for-5.1-rc3' of git://github.com/ceph/ceph-client
[uclinux-h8/linux.git] / tools / testing / selftests / bpf / prog_tests / spinlock.c
1 // SPDX-License-Identifier: GPL-2.0
2 #include <test_progs.h>
3
4 void test_spinlock(void)
5 {
6         const char *file = "./test_spin_lock.o";
7         pthread_t thread_id[4];
8         struct bpf_object *obj = NULL;
9         int prog_fd;
10         int err = 0, i;
11         void *ret;
12
13         err = bpf_prog_load(file, BPF_PROG_TYPE_CGROUP_SKB, &obj, &prog_fd);
14         if (err) {
15                 printf("test_spin_lock:bpf_prog_load errno %d\n", errno);
16                 goto close_prog;
17         }
18         for (i = 0; i < 4; i++)
19                 assert(pthread_create(&thread_id[i], NULL,
20                                       &spin_lock_thread, &prog_fd) == 0);
21         for (i = 0; i < 4; i++)
22                 assert(pthread_join(thread_id[i], &ret) == 0 &&
23                        ret == (void *)&prog_fd);
24         goto close_prog_noerr;
25 close_prog:
26         error_cnt++;
27 close_prog_noerr:
28         bpf_object__close(obj);
29 }