From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 406FBC433E1 for ; Mon, 25 May 2020 09:59:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 208C0207CB for ; Mon, 25 May 2020 09:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590400753; bh=dFvT/rav7y2msyyMHKKB49+6/JbmifHHbRyoV4o0gjg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=AZmWZqBa97k6qFdNzZMmijGS5TvhgDiB6gYwIoV+T6IQPcMjDdhhx62EB3OmUMBeX Hbzjai552J0GLhvtAPpk2fBqtEJyl9e6b3peC4HbZ/X8g3WayjLQlrS2usuR+bpaxI MMZhLC5g+QFojFxVnw/MC/pdAePRQT8U9QTURI+g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389705AbgEYJ7M (ORCPT ); Mon, 25 May 2020 05:59:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:58592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389398AbgEYJ7L (ORCPT ); Mon, 25 May 2020 05:59:11 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4AF3C20787; Mon, 25 May 2020 09:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590400751; bh=dFvT/rav7y2msyyMHKKB49+6/JbmifHHbRyoV4o0gjg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LcRbBDykBXk62o50QbWX56I4nMWRbBZd+d8cUfZnhvJxwsnisb9MOjbF2sU5n+kT6 aGZkouliWEAgN3U6LbulyWW6ksAyKoVk30zwr/B7LLl5in613enj5ff9zANWY0WoRS 1OSxyOi38KK/TS8lTfsZ8jVI71GiTRC2xm0eKB8g= Date: Mon, 25 May 2020 18:59:05 +0900 From: Masami Hiramatsu To: Shuah Khan Cc: Masami Hiramatsu , Shuah Khan , Steven Rostedt , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Zanussi , Li Philip , Liu Yiding , Xiao Yang , Andreas Schwab , David Laight Subject: Re: [PATCH v2] selftests/ftrace: Use printf for backslash included command Message-Id: <20200525185905.5fecd8073e686001712dfdf9@kernel.org> In-Reply-To: <158920418730.16156.8299185499520876735.stgit@devnote2> References: <87imh21x6f.fsf@igel.home> <158920418730.16156.8299185499520876735.stgit@devnote2> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Shuah, Could you pick this to kselftest-next? Thank you, On Mon, 11 May 2020 22:36:27 +0900 Masami Hiramatsu 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 > Suggested-by: Xiao Yang > Signed-off-by: Masami Hiramatsu > --- > 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 > -- Masami Hiramatsu