xref: /openbmc/linux/tools/testing/selftests/bpf/prog_tests/tracing_struct.c (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
11642a394SYonghong Song // SPDX-License-Identifier: GPL-2.0
21642a394SYonghong Song /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
31642a394SYonghong Song 
41642a394SYonghong Song #include <test_progs.h>
51642a394SYonghong Song #include "tracing_struct.skel.h"
61642a394SYonghong Song 
test_fentry(void)71642a394SYonghong Song static void test_fentry(void)
81642a394SYonghong Song {
91642a394SYonghong Song 	struct tracing_struct *skel;
101642a394SYonghong Song 	int err;
111642a394SYonghong Song 
121642a394SYonghong Song 	skel = tracing_struct__open_and_load();
131642a394SYonghong Song 	if (!ASSERT_OK_PTR(skel, "tracing_struct__open_and_load"))
141642a394SYonghong Song 		return;
151642a394SYonghong Song 
161642a394SYonghong Song 	err = tracing_struct__attach(skel);
171642a394SYonghong Song 	if (!ASSERT_OK(err, "tracing_struct__attach"))
186e8280b9SXu Kuohai 		goto destroy_skel;
191642a394SYonghong Song 
201642a394SYonghong Song 	ASSERT_OK(trigger_module_test_read(256), "trigger_read");
211642a394SYonghong Song 
221642a394SYonghong Song 	ASSERT_EQ(skel->bss->t1_a_a, 2, "t1:a.a");
231642a394SYonghong Song 	ASSERT_EQ(skel->bss->t1_a_b, 3, "t1:a.b");
241642a394SYonghong Song 	ASSERT_EQ(skel->bss->t1_b, 1, "t1:b");
251642a394SYonghong Song 	ASSERT_EQ(skel->bss->t1_c, 4, "t1:c");
261642a394SYonghong Song 
271642a394SYonghong Song 	ASSERT_EQ(skel->bss->t1_nregs, 4, "t1 nregs");
281642a394SYonghong Song 	ASSERT_EQ(skel->bss->t1_reg0, 2, "t1 reg0");
291642a394SYonghong Song 	ASSERT_EQ(skel->bss->t1_reg1, 3, "t1 reg1");
301642a394SYonghong Song 	ASSERT_EQ(skel->bss->t1_reg2, 1, "t1 reg2");
311642a394SYonghong Song 	ASSERT_EQ(skel->bss->t1_reg3, 4, "t1 reg3");
321642a394SYonghong Song 	ASSERT_EQ(skel->bss->t1_ret, 10, "t1 ret");
331642a394SYonghong Song 
341642a394SYonghong Song 	ASSERT_EQ(skel->bss->t2_a, 1, "t2:a");
351642a394SYonghong Song 	ASSERT_EQ(skel->bss->t2_b_a, 2, "t2:b.a");
361642a394SYonghong Song 	ASSERT_EQ(skel->bss->t2_b_b, 3, "t2:b.b");
371642a394SYonghong Song 	ASSERT_EQ(skel->bss->t2_c, 4, "t2:c");
381642a394SYonghong Song 	ASSERT_EQ(skel->bss->t2_ret, 10, "t2 ret");
391642a394SYonghong Song 
401642a394SYonghong Song 	ASSERT_EQ(skel->bss->t3_a, 1, "t3:a");
411642a394SYonghong Song 	ASSERT_EQ(skel->bss->t3_b, 4, "t3:b");
421642a394SYonghong Song 	ASSERT_EQ(skel->bss->t3_c_a, 2, "t3:c.a");
431642a394SYonghong Song 	ASSERT_EQ(skel->bss->t3_c_b, 3, "t3:c.b");
441642a394SYonghong Song 	ASSERT_EQ(skel->bss->t3_ret, 10, "t3 ret");
451642a394SYonghong Song 
461642a394SYonghong Song 	ASSERT_EQ(skel->bss->t4_a_a, 10, "t4:a.a");
471642a394SYonghong Song 	ASSERT_EQ(skel->bss->t4_b, 1, "t4:b");
481642a394SYonghong Song 	ASSERT_EQ(skel->bss->t4_c, 2, "t4:c");
491642a394SYonghong Song 	ASSERT_EQ(skel->bss->t4_d, 3, "t4:d");
501642a394SYonghong Song 	ASSERT_EQ(skel->bss->t4_e_a, 2, "t4:e.a");
511642a394SYonghong Song 	ASSERT_EQ(skel->bss->t4_e_b, 3, "t4:e.b");
521642a394SYonghong Song 	ASSERT_EQ(skel->bss->t4_ret, 21, "t4 ret");
531642a394SYonghong Song 
541642a394SYonghong Song 	ASSERT_EQ(skel->bss->t5_ret, 1, "t5 ret");
551642a394SYonghong Song 
565ff54dedSFeng Zhou 	ASSERT_EQ(skel->bss->t6, 1, "t6 ret");
575ff54dedSFeng Zhou 
58*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t7_a, 16, "t7:a");
59*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t7_b, 17, "t7:b");
60*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t7_c, 18, "t7:c");
61*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t7_d, 19, "t7:d");
62*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t7_e, 20, "t7:e");
63*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t7_f_a, 21, "t7:f.a");
64*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t7_f_b, 22, "t7:f.b");
65*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t7_ret, 133, "t7 ret");
66*5e9cf77dSMenglong Dong 
67*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t8_a, 16, "t8:a");
68*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t8_b, 17, "t8:b");
69*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t8_c, 18, "t8:c");
70*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t8_d, 19, "t8:d");
71*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t8_e, 20, "t8:e");
72*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t8_f_a, 21, "t8:f.a");
73*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t8_f_b, 22, "t8:f.b");
74*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t8_g, 23, "t8:g");
75*5e9cf77dSMenglong Dong 	ASSERT_EQ(skel->bss->t8_ret, 156, "t8 ret");
76*5e9cf77dSMenglong Dong 
771642a394SYonghong Song 	tracing_struct__detach(skel);
786e8280b9SXu Kuohai destroy_skel:
791642a394SYonghong Song 	tracing_struct__destroy(skel);
801642a394SYonghong Song }
811642a394SYonghong Song 
test_tracing_struct(void)821642a394SYonghong Song void test_tracing_struct(void)
831642a394SYonghong Song {
841642a394SYonghong Song 	test_fentry();
851642a394SYonghong Song }
86