tools/testing/selftests/bpf/prog_tests/exceptions.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/exceptions.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/exceptions.c- Extension
.c- Size
- 16221 bytes
- Lines
- 418
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
test_progs.hnetwork_helpers.hexceptions.skel.hexceptions_ext.skel.hexceptions_fail.skel.hexceptions_assert.skel.h
Detected Declarations
function test_exceptions_failurefunction test_exceptions_successfunction test_exceptions_assertionsfunction test_exceptions
Annotated Snippet
if (load_ret != 0) { \
if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) { \
printf("%s\n", log_buf); \
goto done; \
} \
} \
if (!load_ret && attach_err) { \
if (!ASSERT_ERR_PTR(link = bpf_program__attach(prog), "attach err")) \
goto done; \
} else if (!load_ret) { \
if (!ASSERT_OK_PTR(link = bpf_program__attach(prog), "attach ok")) \
goto done; \
(void)(after_link); \
bpf_link__destroy(link); \
} \
}
if (test__start_subtest("non-throwing fentry -> exception_cb"))
RUN_EXT(-EINVAL, true, ({
prog = eskel->progs.pfentry;
bpf_program__set_autoload(prog, true);
if (!ASSERT_OK(bpf_program__set_attach_target(prog,
bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
"exception_cb_mod"), "set_attach_target"))
goto done;
}), "Tracing programs cannot attach to exception callback", 0);
if (test__start_subtest("throwing fentry -> exception_cb"))
RUN_EXT(-EINVAL, true, ({
prog = eskel->progs.throwing_fentry;
bpf_program__set_autoload(prog, true);
if (!ASSERT_OK(bpf_program__set_attach_target(prog,
bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
"exception_cb_mod"), "set_attach_target"))
goto done;
}), "Tracing programs cannot attach to exception callback", 0);
if (test__start_subtest("non-throwing fexit -> exception_cb"))
RUN_EXT(-EINVAL, true, ({
prog = eskel->progs.pfexit;
bpf_program__set_autoload(prog, true);
if (!ASSERT_OK(bpf_program__set_attach_target(prog,
bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
"exception_cb_mod"), "set_attach_target"))
goto done;
}), "Tracing programs cannot attach to exception callback", 0);
if (test__start_subtest("throwing fexit -> exception_cb"))
RUN_EXT(-EINVAL, true, ({
prog = eskel->progs.throwing_fexit;
bpf_program__set_autoload(prog, true);
if (!ASSERT_OK(bpf_program__set_attach_target(prog,
bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
"exception_cb_mod"), "set_attach_target"))
goto done;
}), "Tracing programs cannot attach to exception callback", 0);
if (test__start_subtest("throwing extension (with custom cb) -> exception_cb"))
RUN_EXT(-EINVAL, true, ({
prog = eskel->progs.throwing_exception_cb_extension;
bpf_program__set_autoload(prog, true);
if (!ASSERT_OK(bpf_program__set_attach_target(prog,
bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
"exception_cb_mod"), "set_attach_target"))
goto done;
}), "Extension programs cannot attach to exception callback", 0);
if (test__start_subtest("throwing extension -> global func in exception_cb"))
RUN_EXT(0, false, ({
prog = eskel->progs.throwing_exception_cb_extension;
bpf_program__set_autoload(prog, true);
if (!ASSERT_OK(bpf_program__set_attach_target(prog,
bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
"exception_cb_mod_global"), "set_attach_target"))
goto done;
}), "", ({ RUN_SUCCESS(exception_ext_mod_cb_runtime, 131); }));
if (test__start_subtest("throwing extension (with custom cb) -> global func in exception_cb"))
RUN_EXT(0, false, ({
prog = eskel->progs.throwing_extension;
bpf_program__set_autoload(prog, true);
if (!ASSERT_OK(bpf_program__set_attach_target(prog,
bpf_program__fd(skel->progs.exception_ext),
"exception_ext_global"), "set_attach_target"))
goto done;
}), "", ({ RUN_SUCCESS(exception_ext, 128); }));
if (test__start_subtest("non-throwing fentry -> non-throwing subprog"))
/* non-throwing fentry -> non-throwing subprog : OK */
RUN_EXT(0, false, ({
Annotation
- Immediate include surface: `test_progs.h`, `network_helpers.h`, `exceptions.skel.h`, `exceptions_ext.skel.h`, `exceptions_fail.skel.h`, `exceptions_assert.skel.h`.
- Detected declarations: `function test_exceptions_failure`, `function test_exceptions_success`, `function test_exceptions_assertions`, `function test_exceptions`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.