1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2019 Facebook */ 3 4 #include <test_progs.h> 5 #include "test_static_linked.skel.h" 6 7 void test_static_linked(void) 8 { 9 int err; 10 struct test_static_linked* skel; 11 12 skel = test_static_linked__open(); 13 if (!ASSERT_OK_PTR(skel, "skel_open")) 14 return; 15 16 skel->rodata->rovar1 = 1; 17 skel->bss->static_var1 = 2; 18 skel->bss->static_var11 = 3; 19 20 skel->rodata->rovar2 = 4; 21 skel->bss->static_var2 = 5; 22 skel->bss->static_var22 = 6; 23 24 err = test_static_linked__load(skel); 25 if (!ASSERT_OK(err, "skel_load")) 26 goto cleanup; 27 28 err = test_static_linked__attach(skel); 29 if (!ASSERT_OK(err, "skel_attach")) 30 goto cleanup; 31 32 /* trigger */ 33 usleep(1); 34 35 ASSERT_EQ(skel->bss->var1, 1 * 2 + 2 + 3, "var1"); 36 ASSERT_EQ(skel->bss->var2, 4 * 3 + 5 + 6, "var2"); 37 38 cleanup: 39 test_static_linked__destroy(skel); 40 } 41