treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / testing / selftests / bpf / prog_tests / spinlock.c
blob1ae00cd3174ef8723c98c88350b85ccad7466ac2
1 // SPDX-License-Identifier: GPL-2.0
2 #include <test_progs.h>
4 void test_spinlock(void)
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;
13 err = bpf_prog_load(file, BPF_PROG_TYPE_CGROUP_SKB, &obj, &prog_fd);
14 if (CHECK_FAIL(err)) {
15 printf("test_spin_lock:bpf_prog_load errno %d\n", errno);
16 goto close_prog;
18 for (i = 0; i < 4; i++)
19 if (CHECK_FAIL(pthread_create(&thread_id[i], NULL,
20 &spin_lock_thread, &prog_fd)))
21 goto close_prog;
23 for (i = 0; i < 4; i++)
24 if (CHECK_FAIL(pthread_join(thread_id[i], &ret) ||
25 ret != (void *)&prog_fd))
26 goto close_prog;
27 close_prog:
28 bpf_object__close(obj);