Skip to content

Commit a005425

Browse files
committed
Adjust Program::test_run to work on shared receiver
The Program::test_run method also does not seem to really require exclusive access to the bpf_program object. As such, this change switches it over to work on a shared receiver (&self). Signed-off-by: Daniel Müller <[email protected]>
1 parent d035e43 commit a005425

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

libbpf-rs/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Unreleased
44
- Deprecated `Program::get_id_by_fd`
55
- Renamed `Program::get_fd_by_id` to `fd_from_id`
66
- Deprecated `Program::get_fd_by_id`
7-
- Adjusted various `Program::attach_*` methods to work on shared
7+
- Adjusted `Program::{attach_*, test_run}` methods to work on shared
88
receivers
99
- Adjusted `PerfBufferBuilder` to work with `MapCore` objects
1010

libbpf-rs/src/program.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ impl<'obj> ProgramMut<'obj> {
11011101
/// This function uses the
11021102
/// [BPF_PROG_RUN](https://www.kernel.org/doc/html/latest/bpf/bpf_prog_run.html)
11031103
/// facility.
1104-
pub fn test_run<'dat>(&mut self, input: Input<'dat>) -> Result<Output<'dat>> {
1104+
pub fn test_run<'dat>(&self, input: Input<'dat>) -> Result<Output<'dat>> {
11051105
unsafe fn slice_from_array<'t, T>(items: *mut T, num_items: usize) -> Option<&'t mut [T]> {
11061106
if items.is_null() {
11071107
None

libbpf-rs/tests/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ fn test_run_prog_success() {
20272027
bump_rlimit_mlock();
20282028

20292029
let mut obj = get_test_object("run_prog.bpf.o");
2030-
let mut prog = get_prog_mut(&mut obj, "test_1");
2030+
let prog = get_prog_mut(&mut obj, "test_1");
20312031

20322032
#[repr(C)]
20332033
struct bpf_dummy_ops_state {
@@ -2054,7 +2054,7 @@ fn test_run_prog_fail() {
20542054
bump_rlimit_mlock();
20552055

20562056
let mut obj = get_test_object("run_prog.bpf.o");
2057-
let mut prog = get_prog_mut(&mut obj, "test_2");
2057+
let prog = get_prog_mut(&mut obj, "test_2");
20582058

20592059
let input = ProgramInput::default();
20602060
let _err = prog.test_run(input).unwrap_err();

0 commit comments

Comments
 (0)