Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Add the bash completion for listing subsubcommands of perf test

The bash completion does not support listing subsubcommands for 'perf
test <TAB>', so fix it.

Example:

Before this patch:

$ perf test <TAB>
$

As shown above, the subsubcommands of perf test does not come out.

After this patch:

$ perf test <TAB>
list

As shown above, the subsubcommands of perf test can come out now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1426685758-25488-11-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Yunlong Song and committed by
Arnaldo Carvalho de Melo
1f9975f1 40cae2b7

+4 -3
+1 -1
tools/perf/perf-completion.sh
··· 143 143 __perfcomp_colon "$evts" "$cur" 144 144 else 145 145 # List subcommands for perf commands 146 - if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script) ]]; then 146 + if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script|test) ]]; then 147 147 subcmds=$($cmd $prev_skip_opts --list-cmds) 148 148 __perfcomp_colon "$subcmds" "$cur" 149 149 fi
+3 -2
tools/perf/tests/builtin-test.c
··· 291 291 292 292 int cmd_test(int argc, const char **argv, const char *prefix __maybe_unused) 293 293 { 294 - const char * const test_usage[] = { 294 + const char *test_usage[] = { 295 295 "perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]", 296 296 NULL, 297 297 }; ··· 302 302 "be more verbose (show symbol address, etc)"), 303 303 OPT_END() 304 304 }; 305 + const char * const test_subcommands[] = { "list", NULL }; 305 306 struct intlist *skiplist = NULL; 306 307 int ret = hists__init(); 307 308 308 309 if (ret < 0) 309 310 return ret; 310 311 311 - argc = parse_options(argc, argv, test_options, test_usage, 0); 312 + argc = parse_options_subcommand(argc, argv, test_options, test_subcommands, test_usage, 0); 312 313 if (argc >= 1 && !strcmp(argv[0], "list")) 313 314 return perf_test__list(argc, argv); 314 315