diff mbox series

[v1,bpf-next,9/9] bpftool: Add Makefile to facilitate bpftool_tests usage

Message ID 20231116194236.1345035-10-chantr4@gmail.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series bpftool: Add end-to-end testing | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 4 maintainers not CCed: yonghong.song@linux.dev linux-kselftest@vger.kernel.org mykolal@fb.com shuah@kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch warning WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-3 success Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-10 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-11 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / test (test_maps, false, 360) / test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / test (test_verifier, false, 360) / test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-15 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-16 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for x86_64-gcc / test (test_maps, false, 360) / test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-gcc / test (test_progs_no_alu32_parallel, true, 30) / test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for x86_64-gcc / test (test_verifier, false, 360) / test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-gcc / veristat / veristat on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-llvm-16 / build / build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-16 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-16 / veristat
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / test (test_progs, false, 360) / test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for x86_64-gcc / test (test_progs, false, 360) / test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-llvm-16 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-llvm-16 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-llvm-16 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-13 success Logs for s390x-gcc / test (test_verifier, false, 360) / test_verifier on s390x with gcc

Commit Message

Manu Bretelle Nov. 16, 2023, 7:42 p.m. UTC
Provide some Makefile targets to run the linter, build the tests, and
run them on the host or in a VM.

    $ make vmtest
    cargo test --no-run --offline
        Finished test [unoptimized + debuginfo] target(s) in 0.05s
      Executable unittests src/main.rs
    (target/debug/deps/bpftool_tests-afa5a7eef3cdeafb)
    vmtest -k /data/users/chantra/bpf-next/arch/x86/boot/bzImage
    "RUST_TEST_THREADS=1 BPFTOOL_PATH=../tools/build/bpftool/bpftool cargo
    test"
    => bzImage
    ===> Booting
    ===> Setting up VM
    ===> Running command
        Finished test [unoptimized + debuginfo] target(s) in 2.05s
         Running unittests src/main.rs
    (target/debug/deps/bpftool_tests-afa5a7eef3cdeafb)

    running 11 tests
    test bpftool_tests::run_bpftool ... ok
    test bpftool_tests::run_bpftool_map_dump_id ... ok
    test bpftool_tests::run_bpftool_map_list ... ok
    test bpftool_tests::run_bpftool_map_pids ... ok
    test bpftool_tests::run_bpftool_prog_list ... ok
    test bpftool_tests::run_bpftool_prog_pids ... ok
    test bpftool_tests::run_bpftool_prog_show_id ... ok
    test bpftool_tests::run_bpftool_struct_ops_can_unregister_id ... ok
    test bpftool_tests::run_bpftool_struct_ops_can_unregister_name ... ok
    test bpftool_tests::run_bpftool_struct_ops_dump_name ... ok
    test bpftool_tests::run_bpftool_struct_ops_list ... ok

    test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered
    out; finished in 2.88s

Signed-off-by: Manu Bretelle <chantr4@gmail.com>
---
 .../selftests/bpf/bpftool_tests/Makefile      | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/bpftool_tests/Makefile

Comments

Quentin Monnet Nov. 21, 2023, 4:26 p.m. UTC | #1
2023-11-16 19:43 UTC+0000 ~ Manu Bretelle <chantr4@gmail.com>
> Provide some Makefile targets to run the linter, build the tests, and
> run them on the host or in a VM.
> 
>     $ make vmtest
>     cargo test --no-run --offline
>         Finished test [unoptimized + debuginfo] target(s) in 0.05s
>       Executable unittests src/main.rs
>     (target/debug/deps/bpftool_tests-afa5a7eef3cdeafb)
>     vmtest -k /data/users/chantra/bpf-next/arch/x86/boot/bzImage
>     "RUST_TEST_THREADS=1 BPFTOOL_PATH=../tools/build/bpftool/bpftool cargo
>     test"
>     => bzImage
>     ===> Booting
>     ===> Setting up VM
>     ===> Running command
>         Finished test [unoptimized + debuginfo] target(s) in 2.05s
>          Running unittests src/main.rs
>     (target/debug/deps/bpftool_tests-afa5a7eef3cdeafb)
> 
>     running 11 tests
>     test bpftool_tests::run_bpftool ... ok
>     test bpftool_tests::run_bpftool_map_dump_id ... ok
>     test bpftool_tests::run_bpftool_map_list ... ok
>     test bpftool_tests::run_bpftool_map_pids ... ok
>     test bpftool_tests::run_bpftool_prog_list ... ok
>     test bpftool_tests::run_bpftool_prog_pids ... ok
>     test bpftool_tests::run_bpftool_prog_show_id ... ok
>     test bpftool_tests::run_bpftool_struct_ops_can_unregister_id ... ok
>     test bpftool_tests::run_bpftool_struct_ops_can_unregister_name ... ok
>     test bpftool_tests::run_bpftool_struct_ops_dump_name ... ok
>     test bpftool_tests::run_bpftool_struct_ops_list ... ok
> 
>     test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered
>     out; finished in 2.88s
> 
> Signed-off-by: Manu Bretelle <chantr4@gmail.com>
> ---
>  .../selftests/bpf/bpftool_tests/Makefile      | 22 +++++++++++++++++++
>  1 file changed, 22 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/bpftool_tests/Makefile
> 
> diff --git a/tools/testing/selftests/bpf/bpftool_tests/Makefile b/tools/testing/selftests/bpf/bpftool_tests/Makefile
> new file mode 100644
> index 000000000000..0b5633cda8b4
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/bpftool_tests/Makefile
> @@ -0,0 +1,22 @@

I'd recommend adding a SPDX tag. I don't know how relevant this is for a
Makefile, but this would prevent to fall it under the default GPL-only
license, and keep it consistent with the rest of the test framework
you're introducing.

> +BPFTOOL := ../tools/build/bpftool/bpftool
> +
> +lint:
> +	cargo clippy --tests
> +	cargo check --tests
> +
> +# Build the tests but do not run them.
> +build-test:
> +	cargo test --no-run --offline
> +
> +# Run the tests on the host using sudo
> +test: build-test
> +	RUST_TEST_THREADS=1 BPFTOOL_PATH=$(BPFTOOL) sudo -E $(shell which cargo) test --offline
> +
> +# Run the tests in a vm. Requires danobi/vmtest.

Please provide the full URL to the repository. I'd also add a comment to
make it explicit that this is distinct from the vmtest.sh from the
selftests.

> +vmtest: build-test
> +	$(eval repo_root := $(shell git rev-parse --show-toplevel))
> +	$(eval kernel_img := $(shell make -s -C $(repo_root) image_name))
> +	vmtest -k $(repo_root)/$(kernel_img) "RUST_TEST_THREADS=1 BPFTOOL_PATH=$(BPFTOOL) cargo test"
> +
> +clean:
> +	cargo clean
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/bpftool_tests/Makefile b/tools/testing/selftests/bpf/bpftool_tests/Makefile
new file mode 100644
index 000000000000..0b5633cda8b4
--- /dev/null
+++ b/tools/testing/selftests/bpf/bpftool_tests/Makefile
@@ -0,0 +1,22 @@ 
+BPFTOOL := ../tools/build/bpftool/bpftool
+
+lint:
+	cargo clippy --tests
+	cargo check --tests
+
+# Build the tests but do not run them.
+build-test:
+	cargo test --no-run --offline
+
+# Run the tests on the host using sudo
+test: build-test
+	RUST_TEST_THREADS=1 BPFTOOL_PATH=$(BPFTOOL) sudo -E $(shell which cargo) test --offline
+
+# Run the tests in a vm. Requires danobi/vmtest.
+vmtest: build-test
+	$(eval repo_root := $(shell git rev-parse --show-toplevel))
+	$(eval kernel_img := $(shell make -s -C $(repo_root) image_name))
+	vmtest -k $(repo_root)/$(kernel_img) "RUST_TEST_THREADS=1 BPFTOOL_PATH=$(BPFTOOL) cargo test"
+
+clean:
+	cargo clean