selftests/bpf: test_sockmap, join cgroup in selftest mode
authorPrashant Bhole <[email protected]>
Thu, 31 May 2018 04:42:37 +0000 (13:42 +0900)
committerDaniel Borkmann <[email protected]>
Sat, 2 Jun 2018 04:13:56 +0000 (06:13 +0200)
In case of selftest mode, temporary cgroup environment is created but
cgroup is not joined. It causes test failures. Fixed by joining the
cgroup

Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
Acked-by: John Fastabend <[email protected]>
Signed-off-by: Prashant Bhole <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
tools/testing/selftests/bpf/test_sockmap.c

index 7b2008a144cb38d41919934e143e885a4f38da5a..7f9ca79aadbccb7204be80f7f2192828fedf9c4b 100644 (file)
@@ -1344,6 +1344,11 @@ static int __test_suite(char *bpf_file)
                return cg_fd;
        }
 
+       if (join_cgroup(CG_PATH)) {
+               fprintf(stderr, "ERROR: failed to join cgroup\n");
+               return -EINVAL;
+       }
+
        /* Tests basic commands and APIs with range of iov values */
        txmsg_start = txmsg_end = 0;
        err = test_txmsg(cg_fd);