Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5003430rdb; Tue, 12 Dec 2023 16:22:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEvcJcMPZfh4sH14LNgC23ojth9t1zLinPm6rTJagcgCv0zW6lFH/EZQ/pf19aZdVVJ9Ha X-Received: by 2002:a17:902:7795:b0:1cf:fa64:6e50 with SMTP id o21-20020a170902779500b001cffa646e50mr4093467pll.62.1702426970224; Tue, 12 Dec 2023 16:22:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702426970; cv=none; d=google.com; s=arc-20160816; b=g6WsHThbCqVWy0oyC+Ai1w2MppzYOm8UQsvGm8t+x2WL/LJb8MpGp5SZNpxkGdB8A4 V8TGl48uU4s+SdFHARvMwQcoMTlCAm00XcqO5l6Nj6ukSZFpcPNR8YbGPufEHi5WQTX5 fztMEbVeJs0jdqGghocd8llAYSg2EIS4QytDbYEIRIe7dwRzVAAa+aCC5wWprsps4WhT dBUrz3QMnQsyn9NCqyGFvKw2tbeFbRiQ8il9Wl5rpDTO/hBImvhg6+JFt2ofEuxZSnDH xxlhfFc/BtlpobB6nT6W0+jPfVrBc7uxWvWyXLOowYT+wepfD2guPn8AOcNuzgpGDfsw IqmQ== 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 :message-id:subject:cc:to:from:date; bh=IbWr8K2Vx+/NXeqI7vQRBzQqxCb0YrguBFFw05g/4b8=; fh=NdLKlkF21tthkjg7TFYsCcVE9+mNBwBIZGGjccGgMeM=; b=PQbf3hWB/e/b3GjzpN64/BI4gFk5M/ENHCD6l3E/0tVlIF1L+vX2ukMQZbk9ZJLo9n 6GYJqxUoaKsTKJ8LJPNSxLfeO6s7nlSf6vm5AD79qUfiPpBNgXoBCcRotTvcs6mrbc6C 7AOIGQ3Ay0i0OXiVFy7DBYnNHN+3kE5fvFdc6kdit7adpgd1APRS+hfwpSI0NuWiErX3 ZN+80h/zOb11XcBiTakJJF8qRoRs0AmAAoe0bGTRE/b6tUElzCL4bZYCVYC5lhxBGWUK ErktRmhA27eXGVr3qRToCSONVvQR/rnYfSnqXWjaneRptUTZDDnpItXgyJ0/wLhBZN64 kVDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id l16-20020a170903121000b001d044978d21si8800907plh.349.2023.12.12.16.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 16:22:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0E154804B10F; Tue, 12 Dec 2023 16:22:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377735AbjLMAWa (ORCPT + 99 others); Tue, 12 Dec 2023 19:22:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232620AbjLMAW3 (ORCPT ); Tue, 12 Dec 2023 19:22:29 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 503CE92 for ; Tue, 12 Dec 2023 16:22:36 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04D0FC433C7; Wed, 13 Dec 2023 00:22:34 +0000 (UTC) Date: Tue, 12 Dec 2023 19:23:17 -0500 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Shuah Khan , linux-kselftest@vger.kernel.org Subject: [PATCH v3] tracing/selftests: Add test to test the trace_marker Message-ID: <20231212192317.0fb6b101@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (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=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 16:22:47 -0800 (PST) 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. Signed-off-by: Steven Rostedt (Google) --- Changes since v2: https://lore.kernel.org/linux-trace-kernel/20231212151632.25c9b67d@gandalf.local.home - Realized with the upcoming change of the dynamic subbuffer sizes, that this test will fail if the subbuffer is bigger than what the trace_seq can hold. Now the trace_marker does not always utilize the full subbuffer but the size of the trace_seq instead. As that size isn't available to user space, we can only just make sure all content is there. .../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..b24aff5807df --- /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