1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2020 Facebook */
3 #include <test_progs.h>
4 #include <time.h>
5 #include "test_subprogs.skel.h"
6 #include "test_subprogs_unused.skel.h"
7 
8 static int duration;
9 
10 void test_subprogs(void)
11 {
12 	struct test_subprogs *skel;
13 	struct test_subprogs_unused *skel2;
14 	int err;
15 
16 	skel = test_subprogs__open_and_load();
17 	if (CHECK(!skel, "skel_open", "failed to open skeleton\n"))
18 		return;
19 
20 	err = test_subprogs__attach(skel);
21 	if (CHECK(err, "skel_attach", "failed to attach skeleton: %d\n", err))
22 		goto cleanup;
23 
24 	usleep(1);
25 
26 	CHECK(skel->bss->res1 != 12, "res1", "got %d, exp %d\n", skel->bss->res1, 12);
27 	CHECK(skel->bss->res2 != 17, "res2", "got %d, exp %d\n", skel->bss->res2, 17);
28 	CHECK(skel->bss->res3 != 19, "res3", "got %d, exp %d\n", skel->bss->res3, 19);
29 	CHECK(skel->bss->res4 != 36, "res4", "got %d, exp %d\n", skel->bss->res4, 36);
30 
31 	skel2 = test_subprogs_unused__open_and_load();
32 	ASSERT_OK_PTR(skel2, "unused_progs_skel");
33 	test_subprogs_unused__destroy(skel2);
34 
35 cleanup:
36 	test_subprogs__destroy(skel);
37 }
38