]> Git Repo - J-linux.git/blob - tools/testing/selftests/bpf/prog_tests/trace_vprintk.c
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / tools / testing / selftests / bpf / prog_tests / trace_vprintk.c
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2021 Facebook */
3
4 #include <test_progs.h>
5
6 #include "trace_vprintk.lskel.h"
7
8 #define SEARCHMSG       "1,2,3,4,5,6,7,8,9,10"
9
10 static void trace_pipe_cb(const char *str, void *data)
11 {
12         if (strstr(str, SEARCHMSG) != NULL)
13                 (*(int *)data)++;
14 }
15
16 void serial_test_trace_vprintk(void)
17 {
18         struct trace_vprintk_lskel__bss *bss;
19         struct trace_vprintk_lskel *skel;
20         int err = 0, found = 0;
21
22         skel = trace_vprintk_lskel__open_and_load();
23         if (!ASSERT_OK_PTR(skel, "trace_vprintk__open_and_load"))
24                 goto cleanup;
25
26         bss = skel->bss;
27
28         err = trace_vprintk_lskel__attach(skel);
29         if (!ASSERT_OK(err, "trace_vprintk__attach"))
30                 goto cleanup;
31
32         /* wait for tracepoint to trigger */
33         usleep(1);
34         trace_vprintk_lskel__detach(skel);
35
36         if (!ASSERT_GT(bss->trace_vprintk_ran, 0, "bss->trace_vprintk_ran"))
37                 goto cleanup;
38
39         if (!ASSERT_GT(bss->trace_vprintk_ret, 0, "bss->trace_vprintk_ret"))
40                 goto cleanup;
41
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");
45
46         if (!ASSERT_EQ(found, bss->trace_vprintk_ran, "found"))
47                 goto cleanup;
48
49         if (!ASSERT_LT(bss->null_data_vprintk_ret, 0, "bss->null_data_vprintk_ret"))
50                 goto cleanup;
51
52 cleanup:
53         trace_vprintk_lskel__destroy(skel);
54 }
This page took 0.030166 seconds and 4 git commands to generate.