2025-10-30 14:06 UTC-0700 ~ Harshit Mogalapalli harshit.m.mogalapalli@oracle.com
Add selftest to check if Map ID is printed on successful creation in both plain text and json formats.
Signed-off-by: Harshit Mogalapalli harshit.m.mogalapalli@oracle.com
.../testing/selftests/bpf/test_bpftool_map.sh | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+)
diff --git a/tools/testing/selftests/bpf/test_bpftool_map.sh b/tools/testing/selftests/bpf/test_bpftool_map.sh index 515b1df0501e..013a64e96cbf 100755 --- a/tools/testing/selftests/bpf/test_bpftool_map.sh +++ b/tools/testing/selftests/bpf/test_bpftool_map.sh @@ -361,6 +361,40 @@ test_map_access_with_btf_list() { fi } +# Function to test map ID printing +# Parameters: +# $1: bpftool path +# $2: BPF_DIR +test_map_id_printing() {
- local bpftool_path="$1"
- local bpf_dir="$2"
- local test_map_name="test_map_id"
- local test_map_path="$bpf_dir/$test_map_name"
- local output
- output=$("$bpftool_path" map create "$test_map_path" type hash key 4 \
value 8 entries 128 name "$test_map_name")- if echo "$output" | grep -q "Map successfully created with ID:"; then
echo "PASS: Map ID printed in plain text output."- else
echo "FAIL: Map ID not printed in plain text output."exit 1
Other tests in the file print a message only on failure, without a "FAIL:" prefix. Could you do the same, for consistency and brevity? Same for the JSON test.
Thanks, Quentin