Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5635844rdb; Wed, 13 Dec 2023 14:59:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfT0i6brD9/5cZU2C+0dZzylVJ4CFW8pVh64E6gcmEO2lIbgStfChJSCukQlzO5i+zdClw X-Received: by 2002:a17:902:e807:b0:1d1:cb7a:a908 with SMTP id u7-20020a170902e80700b001d1cb7aa908mr10349846plg.60.1702508384261; Wed, 13 Dec 2023 14:59:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702508384; cv=none; d=google.com; s=arc-20160816; b=oNc8Km+Mce99C6qQSOCImYwbHn2X9wIt0fE9aqgMuS2R9rPriZfKXg1d7rmfH9TfLi qxz4sC4QXA1aInv5R9FhU3ygLkld2u86hRxblpnre5j8kFIOO9ArB3tAv4+TM6Rtu0t9 xVJntRCtipJI2bSTzlzbK9u/liJ7VeT0knHBUlEU4LVev7R9zCfZ6jhoVjlsc0LMubpv k5HgBXhrAF199KrbpbsvLMSghkQDz+RIN0IP3D1RJutn5uDJkC/r7tWgXq6KNSiHa4Yo Ojw9kQQzKCWIv3OTaUkOAAevREEkd6jznfhpcOUlPu4Hv1j3qCU60a+exS+1BrVzMDMq SLlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=qs13yFirO0uBku0s003CSLpSBX0DkLgidBWMaIooQZs=; fh=5hzahh6hQHTw5Ti1BZXftjUpEgQKeWnhCW/Ese3xkZ0=; b=up0d9e+Qxb6Eb54ZFIWt89zXRBENfR3yUju29UEYWSkAxXVshN7pWwCiMv2KtA9uwd tgFXQz9JoJpmPYtKBsbcuuUyccBoHwu1j8WQ/Q71kx94y1CbvSWp0gmzoHOlrJLPuVA+ QquaOWu2maLK1689X1pWXNSRFGE269TMfjpauwW4+2vildD3NjVHxsuWGgAIxPB0pTza taKFzEgcBXKg9Qpewe+FS1470MoQbwMQD2+V4ypV2HdVJSzrMK48wNDyD751JUXMul6d tGhgniGgI1C2axAx+xGIzEbQZolKuUacSgZf9l4ucCi/rAktvdlGwBZDAcMR0ziSb8tp 8JGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hY36A9Cw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id b8-20020a170903228800b001d09c539cd5si10495719plh.133.2023.12.13.14.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 14:59:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hY36A9Cw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2115D827D0C7; Wed, 13 Dec 2023 14:59:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442444AbjLMW7Z (ORCPT + 99 others); Wed, 13 Dec 2023 17:59:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229763AbjLMW7Y (ORCPT ); Wed, 13 Dec 2023 17:59:24 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20FD6EA for ; Wed, 13 Dec 2023 14:59:31 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0881C433C9; Wed, 13 Dec 2023 22:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702508370; bh=tu87z2m0yzSYCrpZUb09UJnCb9MAH5ku9bxrta7xiXw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hY36A9CwjW4Ty/pXdnOweeE+wQ0Ya22fO53ILzsQPxdcW0Jf/Y3ErRLmtdDojdFLp tOlP/tEgGDdQnxEqcVMB8djOZl8lHOfONUmdxWkIt9wTDtQt7X4ytnR28UZyMNu0od s8K4uM4/C8ohD8dgVoiiSZYs9+1p2cJyMU5+GWhzT2UCBHABuY6jH1zhKZdgeRM72x 394b4GfPamjk/Rf+YqlH/xT1n+Gh1vxETzAy+2bOr/W1X4adoHGsS6PjDyAfbD3L74 lyGW1M7BGXGcCKS/Yfjx4o59TPoWdNfy37S6w7cQwgiM/g1e5UeakK88leErFezb8l jOzra2NCdG2DA== Date: Thu, 14 Dec 2023 07:59:26 +0900 From: Masami Hiramatsu (Google) To: Steven Rostedt Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Shuah Khan , linux-kselftest@vger.kernel.org Subject: Re: [PATCH v4] tracing/selftests: Add test to test the trace_marker Message-Id: <20231214075926.e3969c8746068953fe910ed0@kernel.org> In-Reply-To: <20231213111527.6a4c9b58@gandalf.local.home> References: <20231213111527.6a4c9b58@gandalf.local.home> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 14:59:41 -0800 (PST) On Wed, 13 Dec 2023 11:15:27 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > Add a test that writes longs strings, some over the size of the sub buffer > and make sure that the entire content is there. This looks good to me. and tested. Acked-by: Masami Hiramatsu (Google) Tested-by: Masami Hiramatsu (Google) Thank you, > > Signed-off-by: Steven Rostedt (Google) > --- > Changes since v3: https://lore.kernel.org/linux-trace-kernel/20231212192317.0fb6b101@gandalf.local.home > > - Removed / */ from regex, to catch more than one space added to the > beginning of the print. This would have caught the bug of using "%*s" > instead of "%.*s". Luckily, the trace_printk test caught that. > > .../ftrace/test.d/00basic/trace_marker.tc | 82 +++++++++++++++++++ > 1 file changed, 82 insertions(+) > create mode 100755 tools/testing/selftests/ftrace/test.d/00basic/trace_marker.tc > > diff --git a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker.tc b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker.tc > new file mode 100755 > index 000000000000..9aa0db2b84fc > --- /dev/null > +++ b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker.tc > @@ -0,0 +1,82 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0 > +# description: Basic tests on writing to trace_marker > +# requires: trace_marker > +# flags: instance > + > +get_buffer_data_size() { > + sed -ne 's/^.*data.*size:\([0-9][0-9]*\).*/\1/p' events/header_page > +} > + > +get_buffer_data_offset() { > + sed -ne 's/^.*data.*offset:\([0-9][0-9]*\).*/\1/p' events/header_page > +} > + > +get_event_header_size() { > + type_len=`sed -ne 's/^.*type_len.*:[^0-9]*\([0-9][0-9]*\).*/\1/p' events/header_event` > + time_len=`sed -ne 's/^.*time_delta.*:[^0-9]*\([0-9][0-9]*\).*/\1/p' events/header_event` > + array_len=`sed -ne 's/^.*array.*:[^0-9]*\([0-9][0-9]*\).*/\1/p' events/header_event` > + total_bits=$((type_len+time_len+array_len)) > + total_bits=$((total_bits+7)) > + echo $((total_bits/8)) > +} > + > +get_print_event_buf_offset() { > + sed -ne 's/^.*buf.*offset:\([0-9][0-9]*\).*/\1/p' events/ftrace/print/format > +} > + > +event_header_size=`get_event_header_size` > +print_header_size=`get_print_event_buf_offset` > + > +data_offset=`get_buffer_data_offset` > + > +marker_meta=$((event_header_size+print_header_size)) > + > +make_str() { > + cnt=$1 > + # subtract two for \n\0 as marker adds these > + cnt=$((cnt-2)) > + printf -- 'X%.0s' $(seq $cnt) > +} > + > +write_buffer() { > + size=$1 > + > + str=`make_str $size` > + > + # clear the buffer > + echo > trace > + > + # write the string into the marker > + echo -n $str > trace_marker > + > + echo $str > +} > + > +test_buffer() { > + > + size=`get_buffer_data_size` > + oneline_size=$((size-marker_meta)) > + echo size = $size > + echo meta size = $marker_meta > + > + # Now add a little more the meta data overhead will overflow > + > + str=`write_buffer $size` > + > + # Make sure the line was broken > + new_str=`awk ' /tracing_mark_write:/ { sub(/^.*tracing_mark_write: /,"");printf "%s", $0; exit}' trace` > + > + if [ "$new_str" = "$str" ]; then > + exit fail; > + fi > + > + # Make sure the entire line can be found > + new_str=`awk ' /tracing_mark_write:/ { sub(/^.*tracing_mark_write: /,"");printf "%s", $0; }' trace` > + > + if [ "$new_str" != "$str" ]; then > + exit fail; > + fi > +} > + > +test_buffer > -- > 2.42.0 > -- Masami Hiramatsu (Google)