Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 54 lines 1.3 kB view raw
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 10static void trace_pipe_cb(const char *str, void *data) 11{ 12 if (strstr(str, SEARCHMSG) != NULL) 13 (*(int *)data)++; 14} 15 16void 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 52cleanup: 53 trace_vprintk_lskel__destroy(skel); 54}