selftests/bpf: test_progs: remove global fail/success counts
[muen/linux.git] / tools / testing / selftests / bpf / prog_tests / map_lock.c
index ee99368..15993b6 100644 (file)
@@ -8,14 +8,12 @@ static void *parallel_map_access(void *arg)
 
        for (i = 0; i < 10000; i++) {
                err = bpf_map_lookup_elem_flags(map_fd, &key, vars, BPF_F_LOCK);
-               if (err) {
+               if (CHECK_FAIL(err)) {
                        printf("lookup failed\n");
-                       error_cnt++;
                        goto out;
                }
-               if (vars[0] != 0) {
+               if (CHECK_FAIL(vars[0] != 0)) {
                        printf("lookup #%d var[0]=%d\n", i, vars[0]);
-                       error_cnt++;
                        goto out;
                }
                rnd = vars[1];
@@ -24,7 +22,7 @@ static void *parallel_map_access(void *arg)
                                continue;
                        printf("lookup #%d var[1]=%d var[%d]=%d\n",
                               i, rnd, j, vars[j]);
-                       error_cnt++;
+                       CHECK_FAIL(vars[j] != rnd);
                        goto out;
                }
        }
@@ -42,15 +40,15 @@ void test_map_lock(void)
        void *ret;
 
        err = bpf_prog_load(file, BPF_PROG_TYPE_CGROUP_SKB, &obj, &prog_fd);
-       if (err) {
+       if (CHECK_FAIL(err)) {
                printf("test_map_lock:bpf_prog_load errno %d\n", errno);
                goto close_prog;
        }
        map_fd[0] = bpf_find_map(__func__, obj, "hash_map");
-       if (map_fd[0] < 0)
+       if (CHECK_FAIL(map_fd[0] < 0))
                goto close_prog;
        map_fd[1] = bpf_find_map(__func__, obj, "array_map");
-       if (map_fd[1] < 0)
+       if (CHECK_FAIL(map_fd[1] < 0))
                goto close_prog;
 
        bpf_map_update_elem(map_fd[0], &key, vars, BPF_F_LOCK);
@@ -67,9 +65,6 @@ void test_map_lock(void)
        for (i = 4; i < 6; i++)
                assert(pthread_join(thread_id[i], &ret) == 0 &&
                       ret == (void *)&map_fd[i - 4]);
-       goto close_prog_noerr;
 close_prog:
-       error_cnt++;
-close_prog_noerr:
        bpf_object__close(obj);
 }