1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
3 
4 #include <test_progs.h>
5 #include "tracing_struct.skel.h"
6 
7 static void test_fentry(void)
8 {
9 	struct tracing_struct *skel;
10 	int err;
11 
12 	skel = tracing_struct__open_and_load();
13 	if (!ASSERT_OK_PTR(skel, "tracing_struct__open_and_load"))
14 		return;
15 
16 	err = tracing_struct__attach(skel);
17 	if (!ASSERT_OK(err, "tracing_struct__attach"))
18 		goto destroy_skel;
19 
20 	ASSERT_OK(trigger_module_test_read(256), "trigger_read");
21 
22 	ASSERT_EQ(skel->bss->t1_a_a, 2, "t1:a.a");
23 	ASSERT_EQ(skel->bss->t1_a_b, 3, "t1:a.b");
24 	ASSERT_EQ(skel->bss->t1_b, 1, "t1:b");
25 	ASSERT_EQ(skel->bss->t1_c, 4, "t1:c");
26 
27 	ASSERT_EQ(skel->bss->t1_nregs, 4, "t1 nregs");
28 	ASSERT_EQ(skel->bss->t1_reg0, 2, "t1 reg0");
29 	ASSERT_EQ(skel->bss->t1_reg1, 3, "t1 reg1");
30 	ASSERT_EQ(skel->bss->t1_reg2, 1, "t1 reg2");
31 	ASSERT_EQ(skel->bss->t1_reg3, 4, "t1 reg3");
32 	ASSERT_EQ(skel->bss->t1_ret, 10, "t1 ret");
33 
34 	ASSERT_EQ(skel->bss->t2_a, 1, "t2:a");
35 	ASSERT_EQ(skel->bss->t2_b_a, 2, "t2:b.a");
36 	ASSERT_EQ(skel->bss->t2_b_b, 3, "t2:b.b");
37 	ASSERT_EQ(skel->bss->t2_c, 4, "t2:c");
38 	ASSERT_EQ(skel->bss->t2_ret, 10, "t2 ret");
39 
40 	ASSERT_EQ(skel->bss->t3_a, 1, "t3:a");
41 	ASSERT_EQ(skel->bss->t3_b, 4, "t3:b");
42 	ASSERT_EQ(skel->bss->t3_c_a, 2, "t3:c.a");
43 	ASSERT_EQ(skel->bss->t3_c_b, 3, "t3:c.b");
44 	ASSERT_EQ(skel->bss->t3_ret, 10, "t3 ret");
45 
46 	ASSERT_EQ(skel->bss->t4_a_a, 10, "t4:a.a");
47 	ASSERT_EQ(skel->bss->t4_b, 1, "t4:b");
48 	ASSERT_EQ(skel->bss->t4_c, 2, "t4:c");
49 	ASSERT_EQ(skel->bss->t4_d, 3, "t4:d");
50 	ASSERT_EQ(skel->bss->t4_e_a, 2, "t4:e.a");
51 	ASSERT_EQ(skel->bss->t4_e_b, 3, "t4:e.b");
52 	ASSERT_EQ(skel->bss->t4_ret, 21, "t4 ret");
53 
54 	ASSERT_EQ(skel->bss->t5_ret, 1, "t5 ret");
55 
56 	ASSERT_EQ(skel->bss->t6, 1, "t6 ret");
57 
58 	tracing_struct__detach(skel);
59 destroy_skel:
60 	tracing_struct__destroy(skel);
61 }
62 
63 void test_tracing_struct(void)
64 {
65 	test_fentry();
66 }
67