From: Shuah Khan <skhan@linuxfoundation.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Tom Zanussi <tom.zanussi@linux.intel.com>,
Li Philip <philip.li@intel.com>,
Liu Yiding <yidingx.liu@intel.com>,
Xiao Yang <yangx.jy@cn.fujitsu.com>,
Andreas Schwab <schwab@linux-m68k.org>,
David Laight <David.Laight@ACULAB.COM>,
skhan@linuxfoundation.org
Subject: Re: [PATCH v2] selftests/ftrace: Use printf for backslash included command
Date: Thu, 28 May 2020 10:24:18 -0600 [thread overview]
Message-ID: <02fbbc09-a52a-5e54-43a5-3de93c698072@linuxfoundation.org> (raw)
In-Reply-To: <20200525185905.5fecd8073e686001712dfdf9@kernel.org>
On 5/25/20 3:59 AM, Masami Hiramatsu wrote:
> Hi Shuah,
>
> Could you pick this to kselftest-next?
>
> Thank you,
>
> On Mon, 11 May 2020 22:36:27 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
>
>> Since the built-in echo has different behavior in POSIX shell
>> (dash) and bash, kprobe_syntax_errors.tc can fail on dash which
>> interpret backslash escape automatically.
>>
>> To fix this issue, we explicitly use printf "%s" (not interpret
>> backslash escapes) if the command string can include backslash.
>>
>> Reported-by: Liu Yiding <yidingx.liu@intel.com>
>> Suggested-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
>> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
>> ---
>> tools/testing/selftests/ftrace/test.d/functions | 8 +++++---
>> .../ftrace/test.d/kprobe/kprobe_syntax_errors.tc | 4 +++-
>> 2 files changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
>> index 61a3c7e2634d..697c77ef2e2b 100644
>> --- a/tools/testing/selftests/ftrace/test.d/functions
>> +++ b/tools/testing/selftests/ftrace/test.d/functions
>> @@ -119,12 +119,14 @@ yield() {
>> ping $LOCALHOST -c 1 || sleep .001 || usleep 1 || sleep 1
>> }
>>
>> +# Since probe event command may include backslash, explicitly use printf "%s"
>> +# to NOT interpret it.
>> ftrace_errlog_check() { # err-prefix command-with-error-pos-by-^ command-file
>> - pos=$(echo -n "${2%^*}" | wc -c) # error position
>> - command=$(echo "$2" | tr -d ^)
>> + pos=$(printf "%s" "${2%^*}" | wc -c) # error position
>> + command=$(printf "%s" "$2" | tr -d ^)
>> echo "Test command: $command"
>> echo > error_log
>> - (! echo "$command" >> "$3" ) 2> /dev/null
>> + (! printf "%s" "$command" >> "$3" ) 2> /dev/null
>> grep "$1: error:" -A 3 error_log
>> N=$(tail -n 1 error_log | wc -c)
>> # " Command: " and "^\n" => 13
>> diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
>> index ef1e9bafb098..eb0f4ab4e070 100644
>> --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
>> +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
>> @@ -91,7 +91,9 @@ esac
>> if grep -q "Create/append/" README && grep -q "imm-value" README; then
>> echo 'p:kprobes/testevent _do_fork' > kprobe_events
>> check_error '^r:kprobes/testevent do_exit' # DIFF_PROBE_TYPE
>> -echo 'p:kprobes/testevent _do_fork abcd=\1' > kprobe_events
>> +
>> +# Explicitly use printf "%s" to not interpret \1
>> +printf "%s" 'p:kprobes/testevent _do_fork abcd=\1' > kprobe_events
>> check_error 'p:kprobes/testevent _do_fork ^bcd=\1' # DIFF_ARG_TYPE
>> check_error 'p:kprobes/testevent _do_fork ^abcd=\1:u8' # DIFF_ARG_TYPE
>> check_error 'p:kprobes/testevent _do_fork ^abcd=\"foo"' # DIFF_ARG_TYPE
>>
>
>
Applied to
git.kernel.org/pub/scm/linux/kernel/git/shuah/linux kselftest.git/ next
branch for Linux 5.8-rc1
thanks,
-- Shuah
next prev parent reply other threads:[~2020-05-28 16:24 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-01 13:37 [PATCH 0/3] selftests/ftrace: Fix ftracetest testcases for dash, etc Masami Hiramatsu
2020-05-01 13:37 ` [PATCH 1/3] selftests/ftrace: Make XFAIL green color Masami Hiramatsu
2020-05-01 14:15 ` Steven Rostedt
2020-05-01 13:37 ` [PATCH 2/3] selftests/ftrace: Pick only the first kprobe event to test Masami Hiramatsu
2020-05-01 14:17 ` Steven Rostedt
2020-05-01 15:38 ` shuah
2020-05-01 16:20 ` Steven Rostedt
2020-05-01 16:30 ` Shuah Khan
2020-05-02 3:05 ` Masami Hiramatsu
2020-05-01 13:38 ` [PATCH 3/3] selftests/ftrace: Use /bin/echo instead of built-in echo Masami Hiramatsu
2020-05-01 14:19 ` Steven Rostedt
2020-05-02 3:08 ` Masami Hiramatsu
2020-05-07 13:12 ` Steven Rostedt
2020-05-07 15:50 ` Masami Hiramatsu
2020-05-07 17:25 ` Steven Rostedt
2020-05-07 20:32 ` Zanussi, Tom
2020-05-08 7:11 ` Masami Hiramatsu
2020-05-07 6:45 ` Xiao Yang
2020-05-07 9:15 ` Masami Hiramatsu
2020-05-11 7:22 ` Xiao Yang
2020-05-11 9:27 ` Masami Hiramatsu
2020-05-11 10:34 ` David Laight
2020-05-11 12:01 ` [PATCH] selftests/ftrace: Use /bin/echo for backslash included command Masami Hiramatsu
2020-05-11 12:19 ` Andreas Schwab
2020-05-11 13:36 ` [PATCH v2] selftests/ftrace: Use printf " Masami Hiramatsu
2020-05-11 13:38 ` Masami Hiramatsu
2020-05-11 13:46 ` David Laight
2020-05-11 14:05 ` Masami Hiramatsu
2020-05-11 14:59 ` David Laight
2020-05-11 20:28 ` Steven Rostedt
2020-05-11 13:42 ` Andreas Schwab
2020-05-11 13:58 ` Masami Hiramatsu
2020-05-25 9:59 ` Masami Hiramatsu
2020-05-28 16:24 ` Shuah Khan [this message]
2020-05-07 9:22 ` [PATCH 3/3] selftests/ftrace: Use /bin/echo instead of built-in echo Andreas Schwab
2020-05-07 15:52 ` Masami Hiramatsu
2020-05-01 14:21 ` [PATCH 0/3] selftests/ftrace: Fix ftracetest testcases for dash, etc Steven Rostedt
2020-05-01 14:28 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=02fbbc09-a52a-5e54-43a5-3de93c698072@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=David.Laight@ACULAB.COM \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=philip.li@intel.com \
--cc=rostedt@goodmis.org \
--cc=schwab@linux-m68k.org \
--cc=shuah@kernel.org \
--cc=tom.zanussi@linux.intel.com \
--cc=yangx.jy@cn.fujitsu.com \
--cc=yidingx.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox