perf test: new testsuite: perf annotate tests
PATCH 3/9 perf test: new testsuite: perf annotate tests
This commit adds tests for perf annotate tool.
The structure of the base_something dirs is the following:
base_something/
settings.sh
- a script mentioned to be sourced within the tests
setup.sh
- if present, necessary for setup of the subset
test_*.sh
- various tests of the subset
cleanup.sh
- a cleanup script that should remove logs, etc.
All the tests should be stand-alone. So if needed, it is enough to cd to the proper base_directory and run the test. Sometimes, setup is needed to be run first.
Example:
cd testsuite/base_annotate
./setup.sh
./test_basic.sh
--- tools/perf/testsuite/base_annotate/cleanup.sh | 22 +++ .../perf/testsuite/base_annotate/examples/Makefile | 13 ++ tools/perf/testsuite/base_annotate/examples/load.c | 24 +++ tools/perf/testsuite/base_annotate/settings.sh | 15 ++ tools/perf/testsuite/base_annotate/setup.sh | 35 +++++ tools/perf/testsuite/base_annotate/test_basic.sh | 169 +++++++++++++++++++++ 6 files changed, 278 insertions(+) create mode 100755 tools/perf/testsuite/base_annotate/cleanup.sh create mode 100644 tools/perf/testsuite/base_annotate/examples/Makefile create mode 100644 tools/perf/testsuite/base_annotate/examples/load.c create mode 100644 tools/perf/testsuite/base_annotate/settings.sh create mode 100755 tools/perf/testsuite/base_annotate/setup.sh create mode 100755 tools/perf/testsuite/base_annotate/test_basic.sh
tools/perf/testsuite/base_annotate/cleanup.sh new file +22 -0
@@ -0,0 +1,22 @@ +#!/bin/bash + +# +# cleanup.sh of perf annotate test +# Author: Michael Petlan <[email protected]> +# +# + +# include working environment +. ../common/init.sh +. ./settings.sh + +THIS_TEST_NAME=`basename $0 .sh` + +make -s -C examples clean + +find . -name \*.log | xargs -r rm +find . -name \*.err | xargs -r rm +rm -f perf.data + +print_results 0 0 "clean-up logs" +exit $?
tools/perf/testsuite/base_annotate/examples/Makefile new file +13 -0
@@ -0,0 +1,13 @@ +CC=gcc +CFLAGS=-g -O0 + +SRCS = $(wildcard *.c) +PROGS = $(patsubst %.c,%,$(SRCS)) + +all: $(PROGS) + +%: %.c + $(CC) $(CFLAGS) -o $@ $< + +clean: + rm -f $(PROGS)
tools/perf/testsuite/base_annotate/examples/load.c new file +24 -0
@@ -0,0 +1,24 @@ +#include <stdio.h> +#include <stdlib.h> + + +int main (int argc,char *argv[]) +{ +long from, i, j =20L ; + +if (argc >1 ) + from =atol (argv[1 ]); +else + from =20L ; + +for (i =1L ; j; ++i) + { +for (j = from; j >0L ; --j) +if (i % j) +break ; + } + +printf ("%ld\n" , --i); + +return 0 ; +}
tools/perf/testsuite/base_annotate/settings.sh new file +15 -0
@@ -0,0 +1,15 @@ +# +# settings.sh of perf_annotate test +# Author: Michael Petlan <[email protected]> +# +# Description: +# FIXME +# +# + +export TEST_NAME="perf_annotate" +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`
tools/perf/testsuite/base_annotate/setup.sh new file +35 -0
@@ -0,0 +1,35 @@ +#!/bin/bash + +# +# setup.sh of perf annotate test +# Author: Michael Petlan <[email protected]> +# +# Description: +# +# FIXME - build C program +# +# + +# include working environment +. ../common/init.sh +. ./settings.sh + +THIS_TEST_NAME=`basename $0 .sh` + +make -s -C examples +print_results $? 0 "building the example code" +TEST_RESULT=$? + +# record some data +$CMD_PERF record examples/load > /dev/null 2> setup_record.log +PERF_EXIT_CODE=$? + +# check the perf record output +../common/check_all_lines_matched.pl "$RE_LINE_RECORD1" "$RE_LINE_RECORD2" < setup_record.log +CHECK_EXIT_CODE=$? + +print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "record data" +(( TEST_RESULT += $? )) + +print_overall_results $TEST_RESULT +exit $?
tools/perf/testsuite/base_annotate/test_basic.sh new file +169 -0
169 lines not on this page · raw message
On Mon, Dec 07, 2015 at 07:53:14PM +0100, Michael Petlan wrote:
SNIP
Quoted 18 lines
tools/perf/testsuite/base_annotate/cleanup.sh new file +11
-0@@ -0,0 +1,22 @@ +#!/bin/bash + +# +# cleanup.sh of perf annotate test +# Author: Michael Petlan <[email protected]> +# +# + +# include working environment +. ../common/init.sh +. ./settings.sh
tools/perf/testsuite/base_annotate/cleanup.sh line 21
Quoted 10 lines
tools/perf/testsuite/base_annotate/cleanup.sh new file +10
-0+ +THIS_TEST_NAME=`basename $0 .sh` + +make -s -C examples clean + +find . -name \*.log | xargs -r rm +find . -name \*.err | xargs -r rm +rm -f perf.data + +print_results 0 0 "clean-up logs"
could the test work over some temporary directory, so it has its data stored in there?
it helps with paralel tests running and
is little bit cleaner solution
thanks,
jirka
Quoted 18 lines · Michael Petlan
This commit adds tests for perf annotate tool.
The structure of the
base_somethingdirs is the following:base_something/
settings.sh
- a script mentioned to be sourced within the tests
setup.sh
- if present, necessary for setup of the subset
test_*.sh
- various tests of the subset
cleanup.sh
- a cleanup script that should remove logs, etc.All the tests should be stand-alone. So if needed, it is enough to cd to the proper
base_directoryand run the test. Sometimes, setup is needed to be run first.
Quoted 5 lines
Example:
cd testsuite/base_annotate
./setup.sh
./test_basic.sh
hum, would it be better to allow running separate tests via perf test suite like:
$ perf test suite base_annotate
you'd need pass argv,argc into tests functions,
which shouldn't be big deal
jirka
On Mon, Dec 07, 2015 at 07:53:14PM +0100, Michael Petlan wrote:
SNIP
tools/perf/testsuite/base_annotate/test_basic.sh line 37
Quoted 11 lines
tools/perf/testsuite/base_annotate/test_basic.sh new file +11
-0+ + ../common/check_all_patterns_found.pl "PERF-ANNOTATE" "NAME" "SYNOPSIS" "DESCRIPTION" "OPTIONS" "SEE ALSO" < basic_helpmsg.log + CHECK_EXIT_CODE=$? + ../common/check_all_patterns_found.pl "perf\-annotate \- Read perf.data .* display annotated code" < basic_helpmsg.log + (( CHECK_EXIT_CODE += $? )) + ../common/check_all_patterns_found.pl "input" "dsos" "symbol" "force" "verbose" "dump-raw-trace" "vmlinux" "modules" < basic_helpmsg.log + (( CHECK_EXIT_CODE += $? )) + ../common/check_all_patterns_found.pl "print-line" "full-paths" "stdio" "tui" "cpu" "source" "symfs" "disassembler-style" < basic_helpmsg.log + (( CHECK_EXIT_CODE += $? )) + ../common/check_all_patterns_found.pl "objdump" "skip-missing" "group" < basic_helpmsg.log + (( CHECK_EXIT_CODE += $? ))
I know it's probably PITA, but would it make sense to preceed each line with the actuall line you are expecting? like:
###
# perf-annotate - Read perf.data (created by perf record) and display annotated code
#
../common/check_all_patterns_found.pl "perf\-annotate \- Read perf.data .* display annotated code" < basic_helpmsg.log
(( CHECK_EXIT_CODE += $? ))
###
# Disassembly of section load0:
# │ Disassembly of section load0:
# 16.67 │ xor %eax,%eax
#
../common/check_all_patterns_found.pl "$REGEX_HEADER load" "$REGEX_LINE" "$REGEX_SECTION__TEXT" < basic_annotate.log
CHECK_EXIT_CODE=$?
###
# from = atol (argv[1]);
#
../common/check_all_patterns_found.pl "main" "from = atol" "from = 20L;" "for\s*\(i = 1L; j; \+\+i\)" "return 0;" < basic_annotate.log
(( CHECK_EXIT_CODE += $? ))or some other way that would make it easy to find out what the check is looking for in general
thanks,
jirka
On Mon, Dec 07, 2015 at 07:53:14PM +0100, Michael Petlan wrote:
SNIP
Quoted 30 lines
tools/perf/testsuite/base_annotate/setup.sh new file +24
-0@@ -0,0 +1,35 @@ +#!/bin/bash + +# +# setup.sh of perf annotate test +# Author: Michael Petlan <[email protected]> +# +# Description: +# +# FIXME - build C program +# +# + +# include working environment +. ../common/init.sh +. ./settings.sh + +THIS_TEST_NAME=`basename $0 .sh` + +make -s -C examples +print_results $? 0 "building the example code" +TEST_RESULT=$? + +# record some data +$CMD_PERF record examples/load > /dev/null 2> setup_record.log
tools/perf/testsuite/base_annotate/setup.sh line 34
Quoted 10 lines
tools/perf/testsuite/base_annotate/setup.sh new file +10
-0+PERF_EXIT_CODE=$? + +# check the perf record output +../common/check_all_lines_matched.pl "$RE_LINE_RECORD1" "$RE_LINE_RECORD2" < setup_record.log +CHECK_EXIT_CODE=$? + +print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "record data" +(( TEST_RESULT += $? )) + +print_overall_results $TEST_RESULT
so setup.sh script is already running some tests?
I thought it's just for seting up the test data
or whatever environment the testcase needs..
jirka
Quoted 47 lines · Jiri Olsa
On Mon, Dec 07, 2015 at 07:53:14PM +0100, Michael Petlan wrote:
SNIP
Quoted 30 lines
tools/perf/testsuite/base_annotate/setup.sh new file +24
-0@@ -0,0 +1,35 @@ +#!/bin/bash + +# +# setup.sh of perf annotate test +# Author: Michael Petlan <[email protected]> +# +# Description: +# +# FIXME - build C program +# +# + +# include working environment +. ../common/init.sh +. ./settings.sh + +THIS_TEST_NAME=`basename $0 .sh` + +make -s -C examples +print_results $? 0 "building the example code" +TEST_RESULT=$? + +# record some data +$CMD_PERF record examples/load > /dev/null 2> setup_record.logtools/perf/testsuite/base_annotate/setup.sh line 34
Quoted 10 lines
tools/perf/testsuite/base_annotate/setup.sh new file +10
-0+PERF_EXIT_CODE=$? + +# check the perf record output +../common/check_all_lines_matched.pl "$RE_LINE_RECORD1" "$RE_LINE_RECORD2" < setup_record.log +CHECK_EXIT_CODE=$? + +print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "record data" +(( TEST_RESULT += $? )) + +print_overall_results $TEST_RESULTso
setup.shscript is already running some tests?
Quoted 4 lines
I thought it's just for seting up the test data
or whatever environment the testcase needs..jirka
It is setting up the test data or whatever environment the testcase needs, but it of course self-checks its success or fail. If make fails, it will be counted and it will be seen in the logs. The same about the sample perf.data recording - if it fails, it is good to know it within the setup phase.
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html