summaryrefslogtreecommitdiffstats
path: root/lib/libxdp/tests/test_utils.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/libxdp/tests/test_utils.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/libxdp/tests/test_utils.h b/lib/libxdp/tests/test_utils.h
new file mode 100644
index 0000000..1642c12
--- /dev/null
+++ b/lib/libxdp/tests/test_utils.h
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __TEST_UTILS_H
+#define __TEST_UTILS_H
+
+#include <bpf/libbpf.h>
+#include <xdp/libxdp.h>
+
+#define __unused __attribute__((unused))
+
+static int libbpf_silent_func(__unused enum libbpf_print_level level,
+ __unused const char *format,
+ __unused va_list args)
+{
+ return 0;
+}
+
+static inline void silence_libbpf_logging(void)
+{
+ libbpf_set_print(libbpf_silent_func);
+}
+
+static int libxdp_silent_func(__unused enum libxdp_print_level level,
+ __unused const char *format,
+ __unused va_list args)
+{
+ return 0;
+}
+
+static int libxdp_verbose_func(__unused enum libxdp_print_level level,
+ __unused const char *format,
+ __unused va_list args)
+{
+ fprintf(stderr, " ");
+ vfprintf(stderr, format, args);
+ return 0;
+}
+
+static inline void silence_libxdp_logging(void)
+{
+ libxdp_set_print(libxdp_silent_func);
+}
+
+static inline void verbose_libxdp_logging(void)
+{
+ libxdp_set_print(libxdp_verbose_func);
+}
+
+#endif