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_ip_test.c (1531B)


      1// SPDX-License-Identifier: GPL-2.0
      2#include <test_progs.h>
      3#include "get_func_ip_test.skel.h"
      4
      5void test_get_func_ip_test(void)
      6{
      7	struct get_func_ip_test *skel = NULL;
      8	int err, prog_fd;
      9	LIBBPF_OPTS(bpf_test_run_opts, topts);
     10
     11	skel = get_func_ip_test__open();
     12	if (!ASSERT_OK_PTR(skel, "get_func_ip_test__open"))
     13		return;
     14
     15	/* test6 is x86_64 specifc because of the instruction
     16	 * offset, disabling it for all other archs
     17	 */
     18#ifndef __x86_64__
     19	bpf_program__set_autoload(skel->progs.test6, false);
     20	bpf_program__set_autoload(skel->progs.test7, false);
     21#endif
     22
     23	err = get_func_ip_test__load(skel);
     24	if (!ASSERT_OK(err, "get_func_ip_test__load"))
     25		goto cleanup;
     26
     27	err = get_func_ip_test__attach(skel);
     28	if (!ASSERT_OK(err, "get_func_ip_test__attach"))
     29		goto cleanup;
     30
     31	prog_fd = bpf_program__fd(skel->progs.test1);
     32	err = bpf_prog_test_run_opts(prog_fd, &topts);
     33	ASSERT_OK(err, "test_run");
     34	ASSERT_EQ(topts.retval, 0, "test_run");
     35
     36	prog_fd = bpf_program__fd(skel->progs.test5);
     37	err = bpf_prog_test_run_opts(prog_fd, &topts);
     38
     39	ASSERT_OK(err, "test_run");
     40
     41	ASSERT_EQ(skel->bss->test1_result, 1, "test1_result");
     42	ASSERT_EQ(skel->bss->test2_result, 1, "test2_result");
     43	ASSERT_EQ(skel->bss->test3_result, 1, "test3_result");
     44	ASSERT_EQ(skel->bss->test4_result, 1, "test4_result");
     45	ASSERT_EQ(skel->bss->test5_result, 1, "test5_result");
     46#ifdef __x86_64__
     47	ASSERT_EQ(skel->bss->test6_result, 1, "test6_result");
     48	ASSERT_EQ(skel->bss->test7_result, 1, "test7_result");
     49#endif
     50
     51cleanup:
     52	get_func_ip_test__destroy(skel);
     53}