From: Carl E. L. <ce...@li...> - 2012-08-20 18:48:27
|
OProfile testsuite, Add symbol checking functionality This patch adds additional testing and workload capability. The patch adds the capability to easily add a new workload specification and a list of symbols that should be present in the OProfile report. The testsuite runs each of the specified workloads with each of the event lists currently specified and then checks that each of the symbols for workload are found in the OProfile report. Signed-off-by: Carl Love <ce...@us...> --- testsuite/Makefile | 25 +++++++++++ testsuite/README | 8 ++++ testsuite/lib/op_workloads.exp | 32 ++++++++++++++ testsuite/lib/verify.exp | 19 ++++++++ .../oprofile-opcontrol/oprofile-opcontrol-run.exp | 34 ++++++++++++--- testsuite/oprofile-operf/oprofile-operf-run.exp | 50 ++++++++++++++-------- testsuite/workloads/memcpyt_src/Makefile | 23 ++++++++++ testsuite/workloads/memcpyt_src/memcpyt.c | 45 +++++++++++++++++++ testsuite/workloads/thread_src/Makefile | 23 ++++++++++ testsuite/workloads/thread_src/thread.c | 47 ++++++++++++++++++++ 10 files changed, 281 insertions(+), 25 deletions(-) create mode 100644 testsuite/Makefile create mode 100644 testsuite/lib/op_workloads.exp create mode 100644 testsuite/lib/verify.exp create mode 100644 testsuite/workloads/memcpyt_src/Makefile create mode 100644 testsuite/workloads/memcpyt_src/memcpyt.c create mode 100644 testsuite/workloads/thread_src/Makefile create mode 100644 testsuite/workloads/thread_src/thread.c diff --git a/testsuite/Makefile b/testsuite/Makefile new file mode 100644 index 0000000..aabc40f --- /dev/null +++ b/testsuite/Makefile @@ -0,0 +1,25 @@ +# Makefile +# Copyright (C) 2012 Carl Love, IBM +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +memcpyt: + cd workloads/memcpyt_src && $(MAKE) + cd workloads/thread_src && $(MAKE) + +clean: + rm workloads/memcpyt_src/memcpyt_bin + rm workloads/thread_src/thread_bin diff --git a/testsuite/README b/testsuite/README index 5bcb4fe..bed8ad3 100644 --- a/testsuite/README +++ b/testsuite/README @@ -2,6 +2,14 @@ This testsuite directory contains a simple testsuite to check the functionality of OProfile on the machine. The testsuite supports testing the previous user interface using opcontrol and the new operf interface. +The testsuite consists of several workloads. Each workload is run using +an architecture specific list of event sets. The OProfile report for +each workload run is then checked to make sure the expected symbols that +are specific to that workload are found in the profile report. + +Setting up the testsuite requires the workloads be compiled by typing +"make" in this directory. The workload executables can be "cleaned up" +by typing "make clean". Running the opcontrol OProfile testsuite requires the following: diff --git a/testsuite/lib/op_workloads.exp b/testsuite/lib/op_workloads.exp new file mode 100644 index 0000000..7183e31 --- /dev/null +++ b/testsuite/lib/op_workloads.exp @@ -0,0 +1,32 @@ + + +if {! [array exists op_workload_table]} { + array set op_workload_table {} +} + +# Make sure the workload binary name is unique and not a substring of the +# directory or the test to see if the symbol exists may find the symbol in +# the directory name not the executable. + +set op_workload_table(tcl) \ + { \ + {tclsh oprofile-operf/workload.tcl 5000} \ + {libtcl} \ + {/no-vmlinux} \ + } + +set op_workload_table(memcpy) \ + { \ + {workloads/memcpyt_src/memcpyt_bin} \ + {memcpyt_bin} \ + {main} \ + {/no-vmlinux} \ + } + +set op_workload_table(thread) \ + { \ + {workloads/thread_src/thread_bin} \ + {thread_bin} \ + {mythread} \ + {/no-vmlinux} \ + } diff --git a/testsuite/lib/verify.exp b/testsuite/lib/verify.exp new file mode 100644 index 0000000..c2e6729 --- /dev/null +++ b/testsuite/lib/verify.exp @@ -0,0 +1,19 @@ +proc verify_output { workload_table_entry } { + + set workload_spec $workload_table_entry + set max [llength $workload_spec] + + # Note, first entry in the workload spec is the name of the workload + # executable file. The following entries are the symbols contained in + # the binary file. + for {set index 1} {$index < $max} {incr index} { + set symbol [lindex $workload_spec $index] + set result [local_exec "opreport --symbols --long-filenames" "" "" 100 ] + + if { [regexp $symbol "$result" ]} { + pass "opreport contains symbol: $symbol" + } else { + fail "opreport does not contain symbol: $symbol" + } + } +} diff --git a/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp b/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp index 5edbb59..618dc88 100644 --- a/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp +++ b/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp @@ -19,6 +19,8 @@ load_lib "op_events.exp" load_lib "op_util.exp" +load_lib "op_workloads.exp" +load_lib "verify.exp" set op_daemon_running 0 @@ -232,13 +234,31 @@ proc op_daemon_stop {} { } proc op_daemon_cycle {ctrs} { - op_daemon_delete_any_samples $ctrs - op_daemon_start $ctrs - op_spin 5000 - op_daemon_flush - op_daemon_check_samples_exist $ctrs - op_daemon_stop - op_daemon_delete_any_samples $ctrs + global op_workload_table + + foreach entry [array name op_workload_table] { + print "op_daemon_cycle entry: $entry" + + set workload [lindex $op_workload_table($entry) 0] + print "op_daemon_cycle workload: $workload" + + op_daemon_delete_any_samples $ctrs + op_daemon_start $ctrs + + # run the workload +# op_spin 5000 + local_exec ${workload} "" "" 100 + + op_daemon_flush + op_daemon_check_samples_exist $ctrs + + op_daemon_stop + op_daemon_delete_any_samples $ctrs + + # verify the instersting symbols for this test are found in + # the output + verify_output $op_workload_table($entry) + } } proc op_check_daemon {} { diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp index 868d698..f2ada9b 100644 --- a/testsuite/oprofile-operf/oprofile-operf-run.exp +++ b/testsuite/oprofile-operf/oprofile-operf-run.exp @@ -19,6 +19,8 @@ load_lib "op_events.exp" load_lib "op_util.exp" +load_lib "op_workloads.exp" +load_lib "verify.exp" set operf_version "" set operf_supported 0 @@ -62,29 +64,41 @@ proc oprofile-operf_get_version {} { } proc do_test {ctrs} { + global op_workload_table set ctr_opts {} set kernel 1 set user 1 set count 5000 - set workload "tclsh oprofile-operf/workload.tcl $count" - - set test "operf do test" - foreach ctr $ctrs { -# n - counter number, no longer used but didn't want to change specification format - set n [lindex $ctr 0] - set event [lindex $ctr 1] - set um [lindex $ctr 2] - set count [lindex $ctr 3] - append ctr_opts "${event}:${count}:${um}:${kernel}:${user}," - } - set cmd "operf --events ${ctr_opts} ${workload}" - set test $cmd + set name tcl + set entry $op_workload_table($name) + set workload [lindex $entry 0] + + foreach entry [array name op_workload_table] { + set workload [lindex $op_workload_table($entry) 0] + set test "operf do test" + set ctr_opts "" + + foreach ctr $ctrs { +# n - counter number, no longer used but didn't want to change specification format + set n [lindex $ctr 0] + set event [lindex $ctr 1] + set um [lindex $ctr 2] + set count [lindex $ctr 3] + append ctr_opts "${event}:${count}:${um}:${kernel}:${user}," + } + set cmd "operf --events ${ctr_opts} ${workload}" + set test $cmd - if {[lindex [local_exec $cmd "" "" 100] 0] == 0} { + if {[lindex [local_exec $cmd "" "" 100] 0] == 0} { pass $test - } else { + } else { fail $test + } + + # verify the instersting symbols for this test are found in + # the output + verify_output $op_workload_table($entry) } } @@ -97,10 +111,10 @@ proc operf_check_samples_exist {ctrs} { set n [lindex $ctr 0] set event [lindex $ctr 1] - verbose "running opreport --long-filenames event:$event" - set result [local_exec "opreport --long-filenames event:$event" "" "" 100 ] + verbose "running opreport --symbols --long-filenames event:$event" + set result [local_exec "opreport --symbols --long-filenames event:$event" "" "" 100 ] + if { [regexp "error:" "$result" ]} { -# if { [regexp "opreport error:" "$result" ]} fix check to match output fail "$test: {$event} created nonzero sample files" } else { pass "$test: {$event} created nonzero sample files" diff --git a/testsuite/workloads/memcpyt_src/Makefile b/testsuite/workloads/memcpyt_src/Makefile new file mode 100644 index 0000000..f88db6c --- /dev/null +++ b/testsuite/workloads/memcpyt_src/Makefile @@ -0,0 +1,23 @@ +# Makefile +# Copyright (C) 2012 Carl Love, IBM +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +# Make sure the workload binary name is unique and not a substring of the +# directory or the test to see if the symbol exists may find the symbol in +# the directory name not the executable. +memcpyt: memcpyt.c + gcc -g -o memcpyt_bin memcpyt.c diff --git a/testsuite/workloads/memcpyt_src/memcpyt.c b/testsuite/workloads/memcpyt_src/memcpyt.c new file mode 100644 index 0000000..f128190 --- /dev/null +++ b/testsuite/workloads/memcpyt_src/memcpyt.c @@ -0,0 +1,45 @@ +/* Makefile + * Copyright (C) 2012 IBM + + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <string.h> + +main() +{ + int j; + long a4k, b4k; + char a[8192], b[8192]; + int source_offset, dest_offset; + char *source_address, *dest_address; + int iterations, copy_length; + + iterations = 1000000000; + copy_length = 65; + source_offset = 3; + dest_offset = 7; + + a4k = (long)(a+4095) & 0xfff; + b4k = (long)(b+4095) & 0xfff; + a4k = (4095 - a4k) & 0xfff; + b4k = (4095 - b4k) & 0xfff; + + source_address=a+a4k+source_offset; + dest_address=b+b4k+dest_offset; + + for(j=0;j<iterations;j++) + memcpy(dest_address, source_address, copy_length); +} diff --git a/testsuite/workloads/thread_src/Makefile b/testsuite/workloads/thread_src/Makefile new file mode 100644 index 0000000..a7c5e36 --- /dev/null +++ b/testsuite/workloads/thread_src/Makefile @@ -0,0 +1,23 @@ +# Makefile +# Copyright (C) 2012 Carl Love, IBM +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +# Make sure the workload binary name is unique and not a substring of the +# directory or the test to see if the symbol exists may find the symbol in +# the directory name not the executable. +thread: thread.c + gcc -g -o thread_bin -pthread thread.c diff --git a/testsuite/workloads/thread_src/thread.c b/testsuite/workloads/thread_src/thread.c new file mode 100644 index 0000000..ae4eb70 --- /dev/null +++ b/testsuite/workloads/thread_src/thread.c @@ -0,0 +1,47 @@ +/* Makefile + * Copyright (C) 2012 IBM + + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <stdio.h> +#include <pthread.h> +#include <stdlib.h> + +#define N 300 +void* mythread(void* arg) +{ + int i,j,k; + long c; + for(i=0; i< N; i++) + for(j=0; j< N; j++) + for(k=0; k< N; k++) + c=i+j+k; + printf("In thread!\n"); + return NULL; +} +int main() +{ + pthread_t th; + + if ( pthread_create(&th,NULL,mythread,NULL)!=0) + { + printf("can not create thread,exit!\n"); + exit(0); + } + printf("main process!\n"); + sleep(3); + return 0; +} -- 1.7.12.rc1.22.gbfbf4d4 |