lkml.org 
[lkml]   [2018]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] perf test shell: make perf inet_pton test more portable
Em Thu, Jun 21, 2018 at 03:32:50PM -0500, Kim Phillips escreveu:
> On Thu, 21 Jun 2018 12:18:00 -0300
> Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> > Would be good if we had some utility that given a two files, one with
> > regexps, could tell if, line by line, those expressions matched, better,
> > one that is present in all these OSes...
>
> I didn't find any, but given the two-file notion might be acceptable,
> hopefully you might find the following more readable/acceptable?:

Looks better, you build the expected lines in a separate file, then read
both it and the output, then do the matching, cleaner. And I assume it
works with dash, right?

- Arnaldo

> diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> index 263057039693..94e513e62b34 100755
> --- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> +++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> @@ -14,35 +14,40 @@ libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1
> nm -Dg $libc 2>/dev/null | fgrep -q inet_pton || exit 254
>
> trace_libc_inet_pton_backtrace() {
> - idx=0
> - expected[0]="ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)"
> - expected[1]=".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"
> +
> + expected=`mktemp -u /tmp/expected.XXX`
> +
> + echo "ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" > $expected
> + echo ".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
> case "$(uname -m)" in
> s390x)
> eventattr='call-graph=dwarf,max-stack=4'
> - expected[2]="gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"
> - expected[3]="(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"
> - expected[4]="main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$"
> + echo "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
> + echo "(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
> + echo "main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected
> ;;
> *)
> eventattr='max-stack=3'
> - expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$"
> - expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$"
> + echo "getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected
> + echo ".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected
> ;;
> esac
>
> - file=`mktemp -u /tmp/perf.data.XXX`
> + perf_data=`mktemp -u /tmp/perf.data.XXX`
> + perf_script=`mktemp -u /tmp/perf.script.XXX`
> + perf record -e probe_libc:inet_pton/$eventattr/ -o $perf_data ping -6 -c 1 ::1 > /dev/null 2>&1
> + perf script -i $perf_data > $perf_script
>
> - perf record -e probe_libc:inet_pton/$eventattr/ -o $file ping -6 -c 1 ::1 > /dev/null 2>&1
> - perf script -i $file | while read line ; do
> + exec 3<$perf_script
> + exec 4<$expected
> + while read line <&3 && read -r pattern <&4; do
> + [ -z "$pattern" ] && break
> echo $line
> - echo "$line" | egrep -q "${expected[$idx]}"
> + echo "$line" | egrep -q "$pattern"
> if [ $? -ne 0 ] ; then
> - printf "FAIL: expected backtrace entry %d \"%s\" got \"%s\"\n" $idx "${expected[$idx]}" "$line"
> + printf "FAIL: expected backtrace entry \"%s\" got \"%s\"\n" "$pattern" "$line"
> exit 1
> fi
> - let idx+=1
> - [ -z "${expected[$idx]}" ] && break
> done
>
> # If any statements are executed from this point onwards,
> @@ -58,6 +63,6 @@ skip_if_no_perf_probe && \
> perf probe -q $libc inet_pton && \
> trace_libc_inet_pton_backtrace
> err=$?
> -rm -f ${file}
> +rm -f ${perf_data} ${perf_script} ${expected}
> perf probe -q -d probe_libc:inet_pton
> exit $err
>
> Thanks,
>
> Kim

\
 
 \ /
  Last update: 2018-06-29 17:23    [W:0.524 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site