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
test_fentry(void)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 ASSERT_EQ(skel->bss->t7_a, 16, "t7:a");
59 ASSERT_EQ(skel->bss->t7_b, 17, "t7:b");
60 ASSERT_EQ(skel->bss->t7_c, 18, "t7:c");
61 ASSERT_EQ(skel->bss->t7_d, 19, "t7:d");
62 ASSERT_EQ(skel->bss->t7_e, 20, "t7:e");
63 ASSERT_EQ(skel->bss->t7_f_a, 21, "t7:f.a");
64 ASSERT_EQ(skel->bss->t7_f_b, 22, "t7:f.b");
65 ASSERT_EQ(skel->bss->t7_ret, 133, "t7 ret");
66
67 ASSERT_EQ(skel->bss->t8_a, 16, "t8:a");
68 ASSERT_EQ(skel->bss->t8_b, 17, "t8:b");
69 ASSERT_EQ(skel->bss->t8_c, 18, "t8:c");
70 ASSERT_EQ(skel->bss->t8_d, 19, "t8:d");
71 ASSERT_EQ(skel->bss->t8_e, 20, "t8:e");
72 ASSERT_EQ(skel->bss->t8_f_a, 21, "t8:f.a");
73 ASSERT_EQ(skel->bss->t8_f_b, 22, "t8:f.b");
74 ASSERT_EQ(skel->bss->t8_g, 23, "t8:g");
75 ASSERT_EQ(skel->bss->t8_ret, 156, "t8 ret");
76
77 tracing_struct__detach(skel);
78 destroy_skel:
79 tracing_struct__destroy(skel);
80 }
81
test_tracing_struct(void)82 void test_tracing_struct(void)
83 {
84 test_fentry();
85 }
86