Re: [PATCH v1 bpf-next 1/9] bpftool: add testing skeleton

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2023-11-16 19:43 UTC+0000 ~ Manu Bretelle <chantr4@xxxxxxxxx>
> Add minimal cargo project to test bpftool.
> An environment variable `BPFTOOL_PATH` can be used to provide the path
> to bpftool, defaulting to /usr/sbin/bpftool
> 
>     $ cargo check --tests
>         Finished dev [unoptimized + debuginfo] target(s) in 0.00s
>     $ cargo clippy --tests
>         Finished dev [unoptimized + debuginfo] target(s) in 0.05s
>     $ BPFTOOL_PATH='../bpftool' cargo test -- --nocapture
>         Finished test [unoptimized + debuginfo] target(s) in 0.05s
>          Running unittests src/main.rs
>     (target/debug/deps/bpftool_tests-172b867215e9364e)
> 
>     running 1 test
>     Running command "../bpftool" "version"
>     test bpftool_tests::run_bpftool ... ok
> 
>     test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered
>     out; finished in 0.00s
> 
> Signed-off-by: Manu Bretelle <chantr4@xxxxxxxxx>
> ---
>  .../selftests/bpf/bpftool_tests/.gitignore    |  3 +++
>  .../selftests/bpf/bpftool_tests/Cargo.toml    |  4 ++++
>  .../bpf/bpftool_tests/src/bpftool_tests.rs    | 20 +++++++++++++++++++
>  .../selftests/bpf/bpftool_tests/src/main.rs   |  3 +++
>  4 files changed, 30 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/bpftool_tests/.gitignore
>  create mode 100644 tools/testing/selftests/bpf/bpftool_tests/Cargo.toml
>  create mode 100644 tools/testing/selftests/bpf/bpftool_tests/src/bpftool_tests.rs
>  create mode 100644 tools/testing/selftests/bpf/bpftool_tests/src/main.rs
> 
> diff --git a/tools/testing/selftests/bpf/bpftool_tests/.gitignore b/tools/testing/selftests/bpf/bpftool_tests/.gitignore
> new file mode 100644
> index 000000000000..cf8177c6aabd
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/bpftool_tests/.gitignore
> @@ -0,0 +1,3 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +/target/**
> +/Cargo.lock
> diff --git a/tools/testing/selftests/bpf/bpftool_tests/Cargo.toml b/tools/testing/selftests/bpf/bpftool_tests/Cargo.toml
> new file mode 100644
> index 000000000000..34df3002003f
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/bpftool_tests/Cargo.toml
> @@ -0,0 +1,4 @@
> +[package]
> +name = "bpftool_tests"
> +version = "0.1.0"
> +edition = "2021"
> diff --git a/tools/testing/selftests/bpf/bpftool_tests/src/bpftool_tests.rs b/tools/testing/selftests/bpf/bpftool_tests/src/bpftool_tests.rs
> new file mode 100644
> index 000000000000..251dbf3861fe
> --- /dev/null
> +++ 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

Any particular reason for this particular choice of license? If not,
could you please reconsider? All sources for bpftool use (GPL-2.0-only
OR BSD-2-Clause), as you use in the .gitignore above, so it would make
sense to have the related tests with the same licenses. It would
certainly make things easier if someone need to ship the tests along
with the sources in the future.

(Same comment for the other Rust files you add in this commit and the next.)

> +use std::process::Command;
> +
> +const BPFTOOL_PATH_ENV: &str = "BPFTOOL_PATH";
> +const BPFTOOL_PATH: &str = "/usr/sbin/bpftool";

This is a decent choice given that it's where the binary will likely end
up for most distributions, but I'd maybe use "/usr/local/sbin/bpftool"
instead to remain consistent with the prefix in bpftool's Makefile, and
default to where we install bpftool when we "make install" it.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux