cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

get_func_args_test.c (1274B)


      1// SPDX-License-Identifier: GPL-2.0
      2#include <test_progs.h>
      3#include "get_func_args_test.skel.h"
      4
      5void test_get_func_args_test(void)
      6{
      7	struct get_func_args_test *skel = NULL;
      8	int err, prog_fd;
      9	LIBBPF_OPTS(bpf_test_run_opts, topts);
     10
     11	skel = get_func_args_test__open_and_load();
     12	if (!ASSERT_OK_PTR(skel, "get_func_args_test__open_and_load"))
     13		return;
     14
     15	err = get_func_args_test__attach(skel);
     16	if (!ASSERT_OK(err, "get_func_args_test__attach"))
     17		goto cleanup;
     18
     19	/* This runs bpf_fentry_test* functions and triggers
     20	 * fentry/fexit programs.
     21	 */
     22	prog_fd = bpf_program__fd(skel->progs.test1);
     23	err = bpf_prog_test_run_opts(prog_fd, &topts);
     24	ASSERT_OK(err, "test_run");
     25	ASSERT_EQ(topts.retval, 0, "test_run");
     26
     27	/* This runs bpf_modify_return_test function and triggers
     28	 * fmod_ret_test and fexit_test programs.
     29	 */
     30	prog_fd = bpf_program__fd(skel->progs.fmod_ret_test);
     31	err = bpf_prog_test_run_opts(prog_fd, &topts);
     32	ASSERT_OK(err, "test_run");
     33	ASSERT_EQ(topts.retval, 1234, "test_run");
     34
     35	ASSERT_EQ(skel->bss->test1_result, 1, "test1_result");
     36	ASSERT_EQ(skel->bss->test2_result, 1, "test2_result");
     37	ASSERT_EQ(skel->bss->test3_result, 1, "test3_result");
     38	ASSERT_EQ(skel->bss->test4_result, 1, "test4_result");
     39
     40cleanup:
     41	get_func_args_test__destroy(skel);
     42}