diff options
| author | Stanislav Fomichev <[email protected]> | 2019-03-02 03:42:14 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2019-03-02 19:10:40 +0000 |
| commit | 7395724b404db76fc093fb99b5c957baa409d8ae (patch) | |
| tree | 31f3ade3794186ea1cb799647c18bf38951bf31e /tools/testing/selftests/bpf/prog_tests/pkt_access.c | |
| parent | selftests: bpf: break up test_progs - preparations (diff) | |
| download | kernel-7395724b404db76fc093fb99b5c957baa409d8ae.tar.gz kernel-7395724b404db76fc093fb99b5c957baa409d8ae.zip | |
selftests: bpf: break up test_progs - pkt access
Move pkt access prog tests into separate files.
Signed-off-by: Stanislav Fomichev <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/pkt_access.c')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/pkt_access.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/pkt_access.c b/tools/testing/selftests/bpf/prog_tests/pkt_access.c new file mode 100644 index 000000000000..4ecfd721a044 --- /dev/null +++ b/tools/testing/selftests/bpf/prog_tests/pkt_access.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <test_progs.h> + +void test_pkt_access(void) +{ + const char *file = "./test_pkt_access.o"; + struct bpf_object *obj; + __u32 duration, retval; + int err, prog_fd; + + err = bpf_prog_load(file, BPF_PROG_TYPE_SCHED_CLS, &obj, &prog_fd); + if (err) { + error_cnt++; + return; + } + + err = bpf_prog_test_run(prog_fd, 100000, &pkt_v4, sizeof(pkt_v4), + NULL, NULL, &retval, &duration); + CHECK(err || retval, "ipv4", + "err %d errno %d retval %d duration %d\n", + err, errno, retval, duration); + + err = bpf_prog_test_run(prog_fd, 100000, &pkt_v6, sizeof(pkt_v6), + NULL, NULL, &retval, &duration); + CHECK(err || retval, "ipv6", + "err %d errno %d retval %d duration %d\n", + err, errno, retval, duration); + bpf_object__close(obj); +} |
