On Thu, Nov 16, 2023 at 11:43 AM Manu Bretelle <chantr4@xxxxxxxxx> wrote: > > +++ b/tools/testing/selftests/bpf/bpftool_tests/src/bpftool_tests.rs > @@ -0,0 +1,20 @@ > +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause > +use std::process::Command; > + > +const BPFTOOL_PATH_ENV: &str = "BPFTOOL_PATH"; > +const BPFTOOL_PATH: &str = "/usr/sbin/bpftool"; > + > +/// Run a bpftool command and returns the output > +fn run_bpftool_command(args: &[&str]) -> std::process::Output { > + let mut cmd = Command::new(std::env::var(BPFTOOL_PATH_ENV).unwrap_or(BPFTOOL_PATH.to_string())); > + cmd.args(args); > + println!("Running command {:?}", cmd); > + cmd.output().expect("failed to execute process") > +} > + > +/// Simple test to make sure we can run bpftool > +#[test] > +fn run_bpftool() { > + let output = run_bpftool_command(&["version"]); > + assert!(output.status.success()); > +} > diff --git a/tools/testing/selftests/bpf/bpftool_tests/src/main.rs b/tools/testing/selftests/bpf/bpftool_tests/src/main.rs > new file mode 100644 > index 000000000000..6b4ffcde7406 > --- /dev/null > +++ b/tools/testing/selftests/bpf/bpftool_tests/src/main.rs > @@ -0,0 +1,3 @@ > +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause > +#[cfg(test)] > +mod bpftool_tests; There is rust in the kernel tree already. Most of it is #![no_std] and the rest depend on rust_is_available.sh and the kernel build system. This rust usage doesn't fit into two existing rust categories afaics. Does it have to leave in the kernel tree? We have bpftool on github, maybe it can be there? Do you want to run bpftool tester as part of BPF CI and that's why you want it to be in the kernel tree?