Include "autoconf.h" header in the test_maps.c and selectively
disable test_sockmap if CONFIG_BPF_STREAM_PARSER is not specified
in the kernel config.
When building out of tree/without autoconf.h, fall back to 'enabled'.

Signed-off-by: Stanislav Fomichev <s...@google.com>
---
 tools/testing/selftests/bpf/test_maps.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_maps.c 
b/tools/testing/selftests/bpf/test_maps.c
index 4db2116e52be..3548de8a78ac 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -32,6 +32,13 @@
 #define ENOTSUPP 524
 #endif
 
+#ifdef HAVE_GENHDR
+# include "autoconf.h"
+#else
+/* fallback to all features enabled */
+# define CONFIG_BPF_STREAM_PARSER 1
+#endif
+
 static int map_flags;
 
 #define CHECK(condition, tag, format...) ({                            \
@@ -588,6 +595,7 @@ static void test_stackmap(int task, void *data)
        close(fd);
 }
 
+#ifdef CONFIG_BPF_STREAM_PARSER
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <arpa/inet.h>
@@ -1079,6 +1087,7 @@ static void test_sockmap(int tasks, void *data)
        close(fd);
        exit(1);
 }
+#endif
 
 #define MAP_SIZE (32 * 1024)
 
@@ -1541,7 +1550,9 @@ static void run_all_tests(void)
        test_arraymap_percpu_many_keys();
 
        test_devmap(0, NULL);
+#ifdef CONFIG_BPF_STREAM_PARSER
        test_sockmap(0, NULL);
+#endif
 
        test_map_large();
        test_map_parallel();
-- 
2.20.0.rc2.403.gdbc3b29805-goog

Reply via email to