1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2019 Facebook */ 3 4 #include <test_progs.h> 5 6 struct s { 7 int a; 8 long long b; 9 } __attribute__((packed)); 10 11 #include "test_skeleton.skel.h" 12 13 BPF_EMBED_OBJ(skeleton, "test_skeleton.o"); 14 15 void test_skeleton(void) 16 { 17 int duration = 0, err; 18 struct test_skeleton* skel; 19 struct test_skeleton__bss *bss; 20 21 skel = test_skeleton__open_and_load(&skeleton_embed); 22 if (CHECK(!skel, "skel_open", "failed to open skeleton\n")) 23 return; 24 25 bss = skel->bss; 26 bss->in1 = 1; 27 bss->in2 = 2; 28 bss->in3 = 3; 29 bss->in4 = 4; 30 bss->in5.a = 5; 31 bss->in5.b = 6; 32 33 err = test_skeleton__attach(skel); 34 if (CHECK(err, "skel_attach", "skeleton attach failed: %d\n", err)) 35 goto cleanup; 36 37 /* trigger tracepoint */ 38 usleep(1); 39 40 CHECK(bss->out1 != 1, "res1", "got %d != exp %d\n", bss->out1, 1); 41 CHECK(bss->out2 != 2, "res2", "got %lld != exp %d\n", bss->out2, 2); 42 CHECK(bss->out3 != 3, "res3", "got %d != exp %d\n", (int)bss->out3, 3); 43 CHECK(bss->out4 != 4, "res4", "got %lld != exp %d\n", bss->out4, 4); 44 CHECK(bss->handler_out5.a != 5, "res5", "got %d != exp %d\n", 45 bss->handler_out5.a, 5); 46 CHECK(bss->handler_out5.b != 6, "res6", "got %lld != exp %d\n", 47 bss->handler_out5.b, 6); 48 49 cleanup: 50 test_skeleton__destroy(skel); 51 } 52