perf test subcmd help: Add exclude disjoint subcmd names
Ian Rogers
reviewerPATCH 1/1 perf test subcmd help: Add exclude disjoint subcmd names
The test is based on an error/fix poseted to linux-perf-users.
--- tools/perf/tests/subcmd-help.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
tools/perf/tests/subcmd-help.c +26 -0
@@ -95,10 +95,36 @@ static int test__exclude_cmdnames(struct test_suite *test __maybe_unused,return TEST_OK ; } +static int test__exclude_cmdnames_no_overlap (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +struct cmdnames cmds1 = {}; +struct cmdnames cmds2 = {}; + +add_cmdname (&cmds1,"read-vdso32" ,11 ); +add_cmdname (&cmds2,"archive" ,7 ); + +TEST_ASSERT_VAL ("invalid original size" , cmds1.cnt ==1 ); +TEST_ASSERT_VAL ("invalid original size" , cmds2.cnt ==1 ); + +exclude_cmds (&cmds1, &cmds2); + +TEST_ASSERT_VAL ("invalid excluded size" , cmds1.cnt ==1 ); +TEST_ASSERT_VAL ("invalid excluded size" , cmds2.cnt ==1 ); + +TEST_ASSERT_VAL ("cannot find cmd" ,is_in_cmdlist (&cmds1,"read-vdso32" ) ==1 ); +TEST_ASSERT_VAL ("wrong cmd" ,is_in_cmdlist (&cmds1,"archive" ) ==0 ); + +clean_cmdnames (&cmds1); +clean_cmdnames (&cmds2); +return TEST_OK ; +} +static struct test_case tests__subcmd_help[] = {TEST_CASE ("Load subcmd names" , load_cmdnames),TEST_CASE ("Uniquify subcmd names" , uniq_cmdnames),TEST_CASE ("Exclude duplicate subcmd names" , exclude_cmdnames), +TEST_CASE ("Exclude disjoint subcmd names" , exclude_cmdnames_no_overlap), { .name =NULL , } };
Signature · 1 line
2.52.0.223.gf5cc29aaa4-goog
________________________________________
From: Ian Rogers <[email protected]>
Sent: Monday, December 8, 2025 9:23 AM
To: Jayaramappa, Srilakshmi; Guilherme Amadio; Peter Zijlstra; Ingo Molnar; Arnaldo Carvalho de Melo; Namhyung Kim; Alexander Shishkin; Jiri Olsa; Ian Rogers; Adrian Hunter; [email protected]; [email protected]
Subject: [PATCH v1] perf test subcmd help: Add exclude disjoint subcmd names
!-------------------------------------------------------------------|
This Message Is From an External Sender
This message came from outside your organization.
|-------------------------------------------------------------------!
The test is based on an error/fix poseted to linux-perf-users.
--- tools/perf/tests/subcmd-help.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
tools/perf/tests/subcmd-help.c +26 -0
@@ -95,10 +95,36 @@ static int test__exclude_cmdnames(struct test_suite *test __maybe_unused,return TEST_OK ; } +static int test__exclude_cmdnames_no_overlap (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +struct cmdnames cmds1 = {}; +struct cmdnames cmds2 = {}; + +add_cmdname (&cmds1,"read-vdso32" ,11 ); +add_cmdname (&cmds2,"archive" ,7 ); + +TEST_ASSERT_VAL ("invalid original size" , cmds1.cnt ==1 ); +TEST_ASSERT_VAL ("invalid original size" , cmds2.cnt ==1 ); + +exclude_cmds (&cmds1, &cmds2); + +TEST_ASSERT_VAL ("invalid excluded size" , cmds1.cnt ==1 ); +TEST_ASSERT_VAL ("invalid excluded size" , cmds2.cnt ==1 ); + +TEST_ASSERT_VAL ("cannot find cmd" ,is_in_cmdlist (&cmds1,"read-vdso32" ) ==1 ); +TEST_ASSERT_VAL ("wrong cmd" ,is_in_cmdlist (&cmds1,"archive" ) ==0 ); + +clean_cmdnames (&cmds1); +clean_cmdnames (&cmds2); +return TEST_OK ; +} +static struct test_case tests__subcmd_help[] = {TEST_CASE ("Load subcmd names" , load_cmdnames),TEST_CASE ("Uniquify subcmd names" , uniq_cmdnames),TEST_CASE ("Exclude duplicate subcmd names" , exclude_cmdnames), +TEST_CASE ("Exclude disjoint subcmd names" , exclude_cmdnames_no_overlap), { .name =NULL , } };
--
2.52.0.223.gf5cc29aaa4-goog
Looks good, thank you !
Ian Rogers
reviewerQuoted 67 lines · Srilakshmi
________________________________________
From: Ian Rogers <[email protected]>
Sent: Monday, December 8, 2025 9:23 AM
To: Jayaramappa, Srilakshmi; Guilherme Amadio; Peter Zijlstra; Ingo Molnar; Arnaldo Carvalho de Melo; Namhyung Kim; Alexander Shishkin; Jiri Olsa; Ian Rogers; Adrian Hunter; [email protected]; [email protected]
Subject: [PATCH v1] perf test subcmd help: Add exclude disjoint subcmd names!-------------------------------------------------------------------|
This Message Is From an External Sender
This message came from outside your organization.
|-------------------------------------------------------------------!The test is based on an error/fix poseted to linux-perf-users.
Reported-by Sri Jayaramappa <[email protected]>Signed-off-by Ian Rogers <[email protected]>--- tools/perf/tests/subcmd-help.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)tools/perf/tests/subcmd-help.c +26
-1@@ -95,10 +95,36 @@ static int test__exclude_cmdnames(struct test_suite *test __maybe_unused,return TEST_OK ; } +static int test__exclude_cmdnames_no_overlap (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +struct cmdnames cmds1 = {}; +struct cmdnames cmds2 = {}; + +add_cmdname (&cmds1,"read-vdso32" ,11 ); +add_cmdname (&cmds2,"archive" ,7 ); + +TEST_ASSERT_VAL ("invalid original size" , cmds1.cnt ==1 ); +TEST_ASSERT_VAL ("invalid original size" , cmds2.cnt ==1 ); + +exclude_cmds (&cmds1, &cmds2); + +TEST_ASSERT_VAL ("invalid excluded size" , cmds1.cnt ==1 ); +TEST_ASSERT_VAL ("invalid excluded size" , cmds2.cnt ==1 ); + +TEST_ASSERT_VAL ("cannot find cmd" ,is_in_cmdlist (&cmds1,"read-vdso32" ) ==1 ); +TEST_ASSERT_VAL ("wrong cmd" ,is_in_cmdlist (&cmds1,"archive" ) ==0 ); + +clean_cmdnames (&cmds1); +clean_cmdnames (&cmds2); +return TEST_OK ; +} +static struct test_case tests__subcmd_help[] = {TEST_CASE ("Load subcmd names" , load_cmdnames),TEST_CASE ("Uniquify subcmd names" , uniq_cmdnames),TEST_CASE ("Exclude duplicate subcmd names" , exclude_cmdnames), +TEST_CASE ("Exclude disjoint subcmd names" , exclude_cmdnames_no_overlap), { .name =NULL , } }; --2.52.0.223.gf5cc29aaa4-goog
Quoted 1 line
Reviewed-by Sri Jayaramappa <[email protected]>
Ping.
Thanks,
Ian
Quoted 1 line
Looks good, thank you !
Dear Ian,
Quoted 65 lines · Ian Rogers
Quoted 63 lines · Srilakshmi
________________________________________
From: Ian Rogers <[email protected]>
Sent: Monday, December 8, 2025 9:23 AM
To: Jayaramappa, Srilakshmi; Guilherme Amadio; Peter Zijlstra; Ingo Molnar; Arnaldo Carvalho de Melo; Namhyung Kim; Alexander Shishkin; Jiri Olsa; Ian Rogers; Adrian Hunter; [email protected]; [email protected]
Subject: [PATCH v1] perf test subcmd help: Add exclude disjoint subcmd names!-------------------------------------------------------------------|
This Message Is From an External Sender
This message came from outside your organization.
|-------------------------------------------------------------------!The test is based on an error/fix poseted to linux-perf-users.
Reported-by Sri Jayaramappa <[email protected]>Signed-off-by Ian Rogers <[email protected]>--- tools/perf/tests/subcmd-help.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)tools/perf/tests/subcmd-help.c +26
-0@@ -95,10 +95,36 @@ static int test__exclude_cmdnames(struct test_suite *test __maybe_unused,return TEST_OK ; } +static int test__exclude_cmdnames_no_overlap (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +struct cmdnames cmds1 = {}; +struct cmdnames cmds2 = {}; + +add_cmdname (&cmds1,"read-vdso32" ,11 ); +add_cmdname (&cmds2,"archive" ,7 ); + +TEST_ASSERT_VAL ("invalid original size" , cmds1.cnt ==1 ); +TEST_ASSERT_VAL ("invalid original size" , cmds2.cnt ==1 ); + +exclude_cmds (&cmds1, &cmds2); + +TEST_ASSERT_VAL ("invalid excluded size" , cmds1.cnt ==1 ); +TEST_ASSERT_VAL ("invalid excluded size" , cmds2.cnt ==1 ); + +TEST_ASSERT_VAL ("cannot find cmd" ,is_in_cmdlist (&cmds1,"read-vdso32" ) ==1 ); +TEST_ASSERT_VAL ("wrong cmd" ,is_in_cmdlist (&cmds1,"archive" ) ==0 ); + +clean_cmdnames (&cmds1); +clean_cmdnames (&cmds2); +return TEST_OK ; +} +static struct test_case tests__subcmd_help[] = {TEST_CASE ("Load subcmd names" , load_cmdnames),TEST_CASE ("Uniquify subcmd names" , uniq_cmdnames),TEST_CASE ("Exclude duplicate subcmd names" , exclude_cmdnames), +TEST_CASE ("Exclude disjoint subcmd names" , exclude_cmdnames_no_overlap), { .name =NULL , } };
Quoted 7 lines
Quoted 5 lines
--
2.52.0.223.gf5cc29aaa4-googReviewed-by Sri Jayaramappa <[email protected]>Ping.
Assuming this is for me, I just tried the test and it correctly fails for me on perf-tools-next (I applied the diff by hand, as it didn't apply cleanly onto the commit below):
gentoo linux $ git log -1 --format=short
commit 75326c67aa8c43000819a2ac29f22eb27846d545 (HEAD -> perf-tools-next, perf-tools-next/tmp.perf-tools-next, perf-tools-next/perf-tools-next)
Author: Derek Foreman <[email protected]>
perf data: Fix coding style
gentoo linux $ tools/perf/perf version
perf version 6.19.rc4.g75326c67aa8c
gentoo linux $ git diff --stat
tools/perf/tests/subcmd-help.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
gentoo linux $ sudo ./tools/perf/perf test -vF disjoint
--- start ---
perf: help.c:107: exclude_cmds: Assertion `cmds->names[ci] == NULL' failed.
Aborted (core dumped) tools/perf/perf test -vF disjoint
Then I applied the patch by Sri Jayaramappa with the fix, and the test now works:
gentoo linux $ sudo tools/perf/perf test -vF disjoint --- start ---
---- end ----
68.4: Exclude disjoint subcmd names : Ok
So you can add a Reviewed-by: Guilherme Amadio <[email protected]> and/or Tested-by: Guilherme Amadio <[email protected]> for both this and the patch at the link below:
https://lore.kernel.org/lkml/[email protected]/
Cheers,
-Guilherme