Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1880817ybk; Mon, 11 May 2020 06:39:57 -0700 (PDT) X-Google-Smtp-Source: APiQypI2gX/WH0KUPRp8NHWw8i5dOxKtzwHvvhSZQCbQwXtTdRgpv2X6IFciHpb7kr8OVx3j5DIM X-Received: by 2002:a17:906:c7cc:: with SMTP id dc12mr7451041ejb.263.1589204397559; Mon, 11 May 2020 06:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589204397; cv=none; d=google.com; s=arc-20160816; b=uy3bbNjb/eBl3/z41xpZXXW2RBM3NCx2jAZiNgvnI8cEx81BprAEB+ZbDvqgJjtvmn LmEBU8Y0klDT4Il2pafvk0gbDlM9ui29BMQUjfcCpUOv0KTeNoLBnkG1TsWUQ+8CUKw9 J52CtqkB0ABi+FhZLzJK5yzzLNOIhSNi8vwRcHObI7rhTwYvKzoeqEH3PhbIufbS7YYy tsZym/npGlKz3DDl4leJf/nXChTNL+FS8Z0LThb4/gzWuPW593+5uhscQAVLBqg2zlCh 4J/OafwgmqMN6HQkrbJ17RkEiwT6ldgUNzhnbqrUp4MNzKaHl34FlOsjne3vgTuwPJkP jB9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=S07lGSSmnKXt5fD4Q0rwAC7BPypfhmt4V/Vi1tBUlPM=; b=PuJTJK4/+fSm0ibbMgLyXBJQTAQtn49VtfTB3C8vRLuz7NVhlfIgR7G0UmQ3nQRcSn 0mkJqRTpXrMkDFK5GTpPGtAPEd4qgi5eJfC60HOo8XmNltn8Uu9o5mYycuxOqlpMkBEr 7BoR3k59b3f3au21rehOLtXT3ajVhdcLg9pwuJl1YyC9oId6ORkM34caoOafyP9FXiJl GWhbUwP3ETX1RO1VnXYBLxWnkMRAaQZYkNhzQetceboM7l2GjSIE6YE3SIN2myZDr1tp o2HwhgNc0BuUqv7FqK9UhiF2Gdpguoq82N3f/E714n5MQg7ws8XuvR9Tg2mInB5fLxcd ngfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z5rmd7KS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g23si4009861edm.358.2020.05.11.06.39.34; Mon, 11 May 2020 06:39:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z5rmd7KS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729659AbgEKNiL (ORCPT + 99 others); Mon, 11 May 2020 09:38:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:44738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726934AbgEKNiK (ORCPT ); Mon, 11 May 2020 09:38:10 -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 498A0206F9; Mon, 11 May 2020 13:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589204289; bh=WwDE+Fb8z57q8OKzPF9RACs94iZxWF3u3IPperUFdGA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=z5rmd7KSgTp2/xdiux62bJoMVYAgSuMtc8CTcMJLP9uc7ZMzaJhz4YArkSNYtcmux 704q5CAPni+6iRE5LE0Wpbu2t8n4Fv5ZPLQqVaftO52tBd6SSsjjqJxEKUzRIEW/7O 6CnknnK2DX5mlxMjnFpEobk3BV883/MgwyUtxCn8= Date: Mon, 11 May 2020 22:38:04 +0900 From: Masami Hiramatsu To: Masami Hiramatsu Cc: 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: <20200511223804.9483cab03c9221818ff4fc5b@kernel.org> In-Reply-To: <158920418730.16156.8299185499520876735.stgit@devnote2> References: <87imh21x6f.fsf@igel.home> <158920418730.16156.8299185499520876735.stgit@devnote2> X-Mailer: Sylpheed 3.5.1 (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 Andreas and David, OK, what about this fix? 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