]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - tools/testing/selftests/bpf/test_maps.c
selftests/bpf: skip sockmap in test_maps if kernel doesn't have support
[linux.git] / tools / testing / selftests / bpf / test_maps.c
index 9c79ee017df3bf15ac704e765188a4c2a56bf862..e7798dd97f4b9861c841679f051cd4b00205756f 100644 (file)
@@ -32,6 +32,8 @@
 #define ENOTSUPP 524
 #endif
 
+static int skips;
+
 static int map_flags;
 
 #define CHECK(condition, tag, format...) ({                            \
@@ -510,7 +512,7 @@ static void test_devmap(int task, void *data)
        fd = bpf_create_map(BPF_MAP_TYPE_DEVMAP, sizeof(key), sizeof(value),
                            2, 0);
        if (fd < 0) {
-               printf("Failed to create arraymap '%s'!\n", strerror(errno));
+               printf("Failed to create devmap '%s'!\n", strerror(errno));
                exit(1);
        }
 
@@ -633,7 +635,6 @@ static void test_stackmap(int task, void *data)
        close(fd);
 }
 
-#include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <arpa/inet.h>
 #include <sys/select.h>
@@ -725,6 +726,15 @@ static void test_sockmap(int tasks, void *data)
                            sizeof(key), sizeof(value),
                            6, 0);
        if (fd < 0) {
+               if (!bpf_probe_map_type(BPF_MAP_TYPE_SOCKMAP, 0)) {
+                       printf("%s SKIP (unsupported map type BPF_MAP_TYPE_SOCKMAP)\n",
+                              __func__);
+                       skips++;
+                       for (i = 0; i < 6; i++)
+                               close(sfd[i]);
+                       return;
+               }
+
                printf("Failed to create sockmap %i\n", fd);
                goto out_sockmap;
        }
@@ -1702,6 +1712,6 @@ int main(void)
        map_flags = BPF_F_NO_PREALLOC;
        run_all_tests();
 
-       printf("test_maps: OK\n");
+       printf("test_maps: OK, %d SKIPPED\n", skips);
        return 0;
 }