1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2021 Facebook */
4 #include <test_progs.h>
6 #include "trace_vprintk.lskel.h"
8 #define SEARCHMSG "1,2,3,4,5,6,7,8,9,10"
10 static void trace_pipe_cb(const char *str, void *data)
12 if (strstr(str, SEARCHMSG) != NULL)
16 void serial_test_trace_vprintk(void)
18 struct trace_vprintk_lskel__bss *bss;
19 struct trace_vprintk_lskel *skel;
20 int err = 0, found = 0;
22 skel = trace_vprintk_lskel__open_and_load();
23 if (!ASSERT_OK_PTR(skel, "trace_vprintk__open_and_load"))
28 err = trace_vprintk_lskel__attach(skel);
29 if (!ASSERT_OK(err, "trace_vprintk__attach"))
32 /* wait for tracepoint to trigger */
34 trace_vprintk_lskel__detach(skel);
36 if (!ASSERT_GT(bss->trace_vprintk_ran, 0, "bss->trace_vprintk_ran"))
39 if (!ASSERT_GT(bss->trace_vprintk_ret, 0, "bss->trace_vprintk_ret"))
42 /* verify our search string is in the trace buffer */
43 ASSERT_OK(read_trace_pipe_iter(trace_pipe_cb, &found, 1000),
44 "read_trace_pipe_iter");
46 if (!ASSERT_EQ(found, bss->trace_vprintk_ran, "found"))
49 if (!ASSERT_LT(bss->null_data_vprintk_ret, 0, "bss->null_data_vprintk_ret"))
53 trace_vprintk_lskel__destroy(skel);