Patchwork [bpf] selftests/bpf: skip sockmap tests on kernels without support

login
register
mail settings
Submitter Stanislav Fomichev
Date Dec. 7, 2018, 3:39 a.m.
Message ID <f215ba8356288b442e18f01050e0599886dad3e5.1544153769.git.sdf@google.com>
Download mbox | patch
Permalink /patch/674883/
State New
Headers show

Comments

Stanislav Fomichev - Dec. 7, 2018, 3:39 a.m.
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 <sdf@google.com>
---
 tools/testing/selftests/bpf/test_maps.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Patch

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();