Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp562350ybm; Thu, 28 May 2020 09:28:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZjQorifix2+uGa8M67oqHiluspys+7X7PSrlNgLqJTK+UYwfKVfoidPaeX2ZIbLpz+46h X-Received: by 2002:a50:f7c4:: with SMTP id i4mr4056948edn.306.1590683335561; Thu, 28 May 2020 09:28:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590683335; cv=none; d=google.com; s=arc-20160816; b=nqv81oCrioKfLD2ojWZBN1sAbzEMIVW1k66E+ldo25bjFZfYAGxulBhkv1Z16wfjiF vVOYvXfMTUuOTBPy73R2HLE4FIqI30EEAQnHA2AKx1sJCJtei3U3Sz+FVr9qqIiMTM61 ZAJoc2+zqNLKXvFNO6Ja9+0htIO3W9Ro+9L9twNuOvkM0+Y9qjtgZetHmBLkhGyCRM0o F/veykGNHdrb9u8NA42dh0Fib809Plwoi1yfG1mw2DH7O9au3nb8F5RVbcXsGG5XmRUr dOCNN0EFFtVOFt/GvFU3Ej1SLOECeUfVYIYbJqTi66yDNtsfw7osxQ9kUIGzD1563P2S hMQA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=lNE5zhFi30q9WwsA8BI91uOqjeUOdLA24NbPUP4RY6U=; b=EDbQjl//LcUJdFFvjOihc9sgWdH0o+vFYTJtMA6llKSbinsr95TG/lt47zOoKyXfJM TXTUQGbkLBKoqPo+0Xmtl4euLNFBQhyz/PtkB2E0SZeiHvr0FfJx0rr01453CrRrxLV8 6hbSALDYhf5gdF5+JNjQy5vd1Jq+oVWgk2Dk2n5CV36PU1kFd9V05wHIWkJsA0XzPEEa xH8fsfOMihXyXQlLSspLwrdEs4IIXBlCrO2NAvUHHec6M5iFxmeKuioOPHpqOCvILEeR DqLPKx2NbGzZQvq2exITx8Ue7sBLr05CV0bkSBnrKEvCAMv2Nvg6PNgv9komNuyjBr5P mpGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=f8zB+CQ9; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si4199145ejs.213.2020.05.28.09.28.31; Thu, 28 May 2020 09:28:55 -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=@linuxfoundation.org header.s=google header.b=f8zB+CQ9; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404950AbgE1QYX (ORCPT + 99 others); Thu, 28 May 2020 12:24:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404897AbgE1QYW (ORCPT ); Thu, 28 May 2020 12:24:22 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89CF4C08C5C7 for ; Thu, 28 May 2020 09:24:22 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id z9so555100oid.2 for ; Thu, 28 May 2020 09:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=lNE5zhFi30q9WwsA8BI91uOqjeUOdLA24NbPUP4RY6U=; b=f8zB+CQ9fKWIaBHJ3pRbSgQc/OvlY8b4ouWU1n9vC4OCtflD7zxXTJDkmVBl+33vDn iWeZHsQkp5lcYaKK6OERajrqZ3NfdOZpj5uNzjN1ur9TcdcH2MoplDaNGt7zN9W4dCos N+RFMJn2m8sXhZ0jlBMrWIYOV87q9p6Qq4LWw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lNE5zhFi30q9WwsA8BI91uOqjeUOdLA24NbPUP4RY6U=; b=gZLpuQv7hR/6yFebzVA0GGEkgrnmOfMG7gRIxCjJnilluwG5JxWtg8drbltJGP46Y4 MsEspEEmB6EW/RGMX5OoQKFi7GJp0W3XkTm9Z2mUDXsoQVryrOIb9AMppFwtmn5j5s/K Z/tvbbmc/Yxx5HM9G0PGqIYke2NnRFaVyv5DkmrCqiYkWImZzHxw0U9D63RH15e/3TGv ZkATHsu4aAJdHqZKZbRbDtf0ra/EdhdoJRvRNbzzgHB1Nd8+Aw13pgnOZF5qRcTokKXr fmSSssKztdcB0fSqu62c+F5Q1/0a5UtHAxqAINyyI3e4eVRMAvC3NfQ58FrNzMffGpdO Hlcg== X-Gm-Message-State: AOAM532JN1E/AkeyzznCY4IMv1jGZ2Ceugza1LS560hP8rdHGQLozaTw ezG3hVxpcJEYjCTiTLYoheKe9A== X-Received: by 2002:aca:af55:: with SMTP id y82mr2624443oie.178.1590683060534; Thu, 28 May 2020 09:24:20 -0700 (PDT) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id x3sm1839339ooc.22.2020.05.28.09.24.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 May 2020 09:24:19 -0700 (PDT) Subject: Re: [PATCH v2] selftests/ftrace: Use printf for backslash included command 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 , skhan@linuxfoundation.org References: <87imh21x6f.fsf@igel.home> <158920418730.16156.8299185499520876735.stgit@devnote2> <20200525185905.5fecd8073e686001712dfdf9@kernel.org> From: Shuah Khan Message-ID: <02fbbc09-a52a-5e54-43a5-3de93c698072@linuxfoundation.org> Date: Thu, 28 May 2020 10:24:18 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200525185905.5fecd8073e686001712dfdf9@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.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 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 >> > > Applied to git.kernel.org/pub/scm/linux/kernel/git/shuah/linux kselftest.git/ next branch for Linux 5.8-rc1 thanks, -- Shuah