This commit adds tests for perf list tool.

Signed-off-by: Michael Petlan <mpet...@redhat.com>
---
 tools/perf/testsuite/base_list/cleanup.sh    | 19 ++++++
 tools/perf/testsuite/base_list/settings.sh   | 15 +++++
 tools/perf/testsuite/base_list/setup.sh      | 20 +++++++
 tools/perf/testsuite/base_list/test_basic.sh | 88 ++++++++++++++++++++++++++++
 4 files changed, 142 insertions(+)
 create mode 100755 tools/perf/testsuite/base_list/cleanup.sh
 create mode 100644 tools/perf/testsuite/base_list/settings.sh
 create mode 100755 tools/perf/testsuite/base_list/setup.sh
 create mode 100755 tools/perf/testsuite/base_list/test_basic.sh

diff --git a/tools/perf/testsuite/base_list/cleanup.sh 
b/tools/perf/testsuite/base_list/cleanup.sh
new file mode 100755
index 0000000..0b1f8f2
--- /dev/null
+++ b/tools/perf/testsuite/base_list/cleanup.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+#
+#      cleanup.sh of perf list test
+#      Author: Michael Petlan <mpet...@redhat.com>
+#
+#
+
+# include working environment
+. ../common/init.sh
+. ./settings.sh
+
+THIS_TEST_NAME=`basename $0 .sh`
+
+find . -name \*.log | xargs -r rm
+find . -name \*.err | xargs -r rm
+
+print_results 0 0 "clean-up logs"
+exit $?
diff --git a/tools/perf/testsuite/base_list/settings.sh 
b/tools/perf/testsuite/base_list/settings.sh
new file mode 100644
index 0000000..f3635e7
--- /dev/null
+++ b/tools/perf/testsuite/base_list/settings.sh
@@ -0,0 +1,15 @@
+#
+#      settings.sh of perf_list test
+#      Author: Michael Petlan <mpet...@redhat.com>
+#
+#      Description:
+#              FIXME
+#
+#
+
+export TEST_NAME="perf_list"
+export MY_ARCH=`arch`
+export MY_HOSTNAME=`hostname`
+export MY_KERNEL_VERSION=`uname -r`
+export MY_CPUS_ONLINE=`nproc`
+export MY_CPUS_AVAILABLE=`cat /proc/cpuinfo | grep processor | wc -l`
diff --git a/tools/perf/testsuite/base_list/setup.sh 
b/tools/perf/testsuite/base_list/setup.sh
new file mode 100755
index 0000000..e254d05
--- /dev/null
+++ b/tools/perf/testsuite/base_list/setup.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+#
+#      setup.sh of perf list test
+#      Author: Michael Petlan <mpet...@redhat.com>
+#
+#      Description:
+#
+#              FIXME - maybe the setup is not necessary
+#
+#
+
+# include working environment
+. ../common/init.sh
+. ./settings.sh
+
+THIS_TEST_NAME=`basename $0 .sh`
+
+print_overall_results 0
+exit $?
diff --git a/tools/perf/testsuite/base_list/test_basic.sh 
b/tools/perf/testsuite/base_list/test_basic.sh
new file mode 100755
index 0000000..1a80872
--- /dev/null
+++ b/tools/perf/testsuite/base_list/test_basic.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+#
+#      test_basic of perf_list test
+#      Author: Michael Petlan <mpet...@redhat.com>
+#
+#      Description:
+#
+#              This test tests basic functionality of perf list command.
+#
+#
+
+# include working environment
+. ../common/init.sh
+. ./settings.sh
+
+THIS_TEST_NAME=`basename $0 .sh`
+TEST_RESULT=0
+
+
+### help message
+
+if [ "$PARAM_GENERAL_HELP_TEXT_CHECK" = "y" ]; then
+       # test that a help message is shown and looks reasonable
+       $CMD_PERF list --help > basic_helpmsg.log
+       PERF_EXIT_CODE=$?
+
+       ../common/check_all_patterns_found.pl "PERF-LIST" "NAME" "SYNOPSIS" 
"DESCRIPTION" "EVENT MODIFIERS" "RAW HARDWARE" "PARAMETERIZED EVENTS" "OPTIONS" 
"SEE ALSO" "NOTES" < basic_helpmsg.log
+       CHECK_EXIT_CODE=$?
+       ../common/check_all_patterns_found.pl "perf\-list \- List all symbolic 
event types" < basic_helpmsg.log
+       (( CHECK_EXIT_CODE += $? ))
+
+       print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "help message"
+       (( TEST_RESULT += $? ))
+else
+       print_testcase_skipped "help message"
+fi
+
+
+### basic execution
+
+# test that perf list is even working
+$CMD_PERF list > basic_basic.log 2> basic_basic.err
+PERF_EXIT_CODE=$?
+
+REGEX_LINE_HEADER="List of pre-defined events"
+REGEX_LINE_BASIC="\s*$RE_EVENT_ANY\s+(?:OR\s+$RE_EVENT_ANY\s+)?\[.*event.*\]"
+REGEX_LINE_BREAKPOINT="\s*mem:<addr>.*\s+\[Hardware breakpoint\]"
+REGEX_LINE_RAW="\[Raw hardware event descriptor\]"
+REGEX_LINE_AUX="see \'man perf\-list\' on how to encode it"
+../common/check_all_lines_matched.pl "$RE_LINE_EMPTY" "$REGEX_LINE_HEADER" 
"$REGEX_LINE_BASIC" "$REGEX_LINE_BREAKPOINT" "$REGEX_LINE_RAW" 
"$REGEX_LINE_AUX" < basic_basic.log
+CHECK_EXIT_CODE=$?
+test ! -s basic_basic.err
+(( CHECK_EXIT_CODE += $? ))
+
+print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "basic execution"
+(( TEST_RESULT += $? ))
+
+
+### listing event groups
+
+# perf list can filter the list by keywords or group globals
+declare -A outputs
+outputs["hw"]="Hardware event"
+outputs["sw"]="Software event"
+outputs["cache"]="Hardware cache event"
+outputs["tracepoint"]="Tracepoint event"
+outputs["pmu"]="Kernel PMU event"
+outputs["xfs:\*"]="^\s*xfs:"
+outputs["kmem:\*"]="^\s*kmem:"
+outputs["syscalls:\*"]="^\s*syscalls:sys"
+
+for i in ${!outputs[@]}; do
+       j=`echo $i | tr -d '\\\*:'`
+       $CMD_PERF list $i > basic_$j.log
+       PERF_EXIT_CODE=$?
+
+       ../common/check_all_lines_matched.pl "$REGEX_LINE_HEADER" 
"$RE_LINE_EMPTY" "${outputs[$i]}" < basic_$j.log
+       CHECK_EXIT_CODE=$?
+
+       print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "list $i"
+       (( TEST_RESULT += $? ))
+done
+
+
+# print overall resutls
+print_overall_results "$TEST_RESULT"
+exit $?


--
To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to