// SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ #include <test_progs.h> #include"arena_atomics.skel.h"
staticvoid test_add(struct arena_atomics *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts); int err, prog_fd;
/* No need to attach it, just run it directly */
prog_fd = bpf_program__fd(skel->progs.add);
err = bpf_prog_test_run_opts(prog_fd, &topts); if (!ASSERT_OK(err, "test_run_opts err")) return; if (!ASSERT_OK(topts.retval, "test_run_opts retval")) return;
staticvoid test_sub(struct arena_atomics *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts); int err, prog_fd;
/* No need to attach it, just run it directly */
prog_fd = bpf_program__fd(skel->progs.sub);
err = bpf_prog_test_run_opts(prog_fd, &topts); if (!ASSERT_OK(err, "test_run_opts err")) return; if (!ASSERT_OK(topts.retval, "test_run_opts retval")) return;
staticvoid test_and(struct arena_atomics *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts); int err, prog_fd;
/* No need to attach it, just run it directly */
prog_fd = bpf_program__fd(skel->progs.and);
err = bpf_prog_test_run_opts(prog_fd, &topts); if (!ASSERT_OK(err, "test_run_opts err")) return; if (!ASSERT_OK(topts.retval, "test_run_opts retval")) return;
staticvoid test_or(struct arena_atomics *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts); int err, prog_fd;
/* No need to attach it, just run it directly */
prog_fd = bpf_program__fd(skel->progs.or);
err = bpf_prog_test_run_opts(prog_fd, &topts); if (!ASSERT_OK(err, "test_run_opts err")) return; if (!ASSERT_OK(topts.retval, "test_run_opts retval")) return;
staticvoid test_xor(struct arena_atomics *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts); int err, prog_fd;
/* No need to attach it, just run it directly */
prog_fd = bpf_program__fd(skel->progs.xor);
err = bpf_prog_test_run_opts(prog_fd, &topts); if (!ASSERT_OK(err, "test_run_opts err")) return; if (!ASSERT_OK(topts.retval, "test_run_opts retval")) return;
staticvoid test_cmpxchg(struct arena_atomics *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts); int err, prog_fd;
/* No need to attach it, just run it directly */
prog_fd = bpf_program__fd(skel->progs.cmpxchg);
err = bpf_prog_test_run_opts(prog_fd, &topts); if (!ASSERT_OK(err, "test_run_opts err")) return; if (!ASSERT_OK(topts.retval, "test_run_opts retval")) return;
staticvoid test_xchg(struct arena_atomics *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts); int err, prog_fd;
/* No need to attach it, just run it directly */
prog_fd = bpf_program__fd(skel->progs.xchg);
err = bpf_prog_test_run_opts(prog_fd, &topts); if (!ASSERT_OK(err, "test_run_opts err")) return; if (!ASSERT_OK(topts.retval, "test_run_opts retval")) return;
staticvoid test_uaf(struct arena_atomics *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts); int err, prog_fd;
/* No need to attach it, just run it directly */
prog_fd = bpf_program__fd(skel->progs.uaf);
err = bpf_prog_test_run_opts(prog_fd, &topts); if (!ASSERT_OK(err, "test_run_opts err")) return; if (!ASSERT_OK(topts.retval, "test_run_opts retval")) return;
staticvoid test_load_acquire(struct arena_atomics *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts); int err, prog_fd;
if (skel->data->skip_lacq_srel_tests) {
printf("%s:SKIP: ENABLE_ATOMICS_TESTS not defined, Clang doesn't support addr_space_cast, and/or JIT doesn't support load-acquire\n",
__func__);
test__skip(); return;
}
/* No need to attach it, just run it directly */
prog_fd = bpf_program__fd(skel->progs.load_acquire);
err = bpf_prog_test_run_opts(prog_fd, &topts); if (!ASSERT_OK(err, "test_run_opts err")) return; if (!ASSERT_OK(topts.retval, "test_run_opts retval")) return;
staticvoid test_store_release(struct arena_atomics *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts); int err, prog_fd;
if (skel->data->skip_lacq_srel_tests) {
printf("%s:SKIP: ENABLE_ATOMICS_TESTS not defined, Clang doesn't support addr_space_cast, and/or JIT doesn't support store-release\n",
__func__);
test__skip(); return;
}
/* No need to attach it, just run it directly */
prog_fd = bpf_program__fd(skel->progs.store_release);
err = bpf_prog_test_run_opts(prog_fd, &topts); if (!ASSERT_OK(err, "test_run_opts err")) return; if (!ASSERT_OK(topts.retval, "test_run_opts retval")) return;
void test_arena_atomics(void)
{ struct arena_atomics *skel; int err;
skel = arena_atomics__open(); if (!ASSERT_OK_PTR(skel, "arena atomics skeleton open")) return;
if (skel->data->skip_all_tests) {
printf("%s:SKIP:no ENABLE_ATOMICS_TESTS or no addr_space_cast support in clang",
__func__);
test__skip(); goto cleanup;
}
err = arena_atomics__load(skel); if (!ASSERT_OK(err, "arena atomics skeleton load")) return;
skel->bss->pid = getpid();
if (test__start_subtest("add"))
test_add(skel); if (test__start_subtest("sub"))
test_sub(skel); if (test__start_subtest("and"))
test_and(skel); if (test__start_subtest("or"))
test_or(skel); if (test__start_subtest("xor"))
test_xor(skel); if (test__start_subtest("cmpxchg"))
test_cmpxchg(skel); if (test__start_subtest("xchg"))
test_xchg(skel); if (test__start_subtest("uaf"))
test_uaf(skel); if (test__start_subtest("load_acquire"))
test_load_acquire(skel); if (test__start_subtest("store_release"))
test_store_release(skel);
cleanup:
arena_atomics__destroy(skel);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.