From patchwork Thu Aug 16 16:43:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 10567855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA7F813B4 for ; Thu, 16 Aug 2018 16:44:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 999E52B53C for ; Thu, 16 Aug 2018 16:44:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CC332B544; Thu, 16 Aug 2018 16:44:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35EE92B53C for ; Thu, 16 Aug 2018 16:44:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729384AbeHPTnu (ORCPT ); Thu, 16 Aug 2018 15:43:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:54402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729169AbeHPTns (ORCPT ); Thu, 16 Aug 2018 15:43:48 -0400 Received: from localhost.localdomain (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 A9ACD208E9; Thu, 16 Aug 2018 16:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1534437852; bh=2Km1pLSPBcTAtF/6tYi64YTnSCEi/qYp5Wy43bZaYx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nnjg2yhmHj6JzisyfD/4jw9B5Y9bWkpWEUwUHZ7rqDX1v0P4TLd5H/5QVOD2L5O34 gbPbDOg1RKeNFfgqkw4mBKfBm5Kg/xaMlxPz2199cNo/ahp6PZhuVHOFuqsdRzx7zh 2DrVc4QxqYCYizoXYmqdmUDU1lvuWZk1AzktnyDc= From: Masami Hiramatsu To: Shuah Khan , Steven Rostedt Cc: Ingo Molnar , Masami Hiramatsu , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 31/32] selftests/ftrace: Add output format testcase Date: Fri, 17 Aug 2018 01:43:49 +0900 Message-Id: <153443782973.23257.16320326555688796000.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <153443695002.23257.13628220023468200991.stgit@devbox> References: <153443695002.23257.13628220023468200991.stgit@devbox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a testcase for tracing output format using trace_marker. This tests raw, hex and bin format output. Signed-off-by: Masami Hiramatsu --- .../ftrace/test.d/00basic/print_format.tc | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/print_format.tc diff --git a/tools/testing/selftests/ftrace/test.d/00basic/print_format.tc b/tools/testing/selftests/ftrace/test.d/00basic/print_format.tc new file mode 100644 index 000000000000..55feb542e83e --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/00basic/print_format.tc @@ -0,0 +1,51 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: Change print trace format + +if [ ! -f trace_marker ]; then + echo "trace_marker is not supported, can not continue testing" + exit_unresolved +fi + +do_reset() { + if [ `cat options/bin` -eq 1 ]; then + grep -v "^#" trace | od -h | cut -f 2- -d " " | xargs echo + fi + echo 0 > options/hex + echo 0 > options/raw + echo 0 > options/bin + cat trace + exit 1 +} + +echo > trace +echo "abcdefgh" > trace_marker +echo 0 > tracing_on + +: "Get the pid and cpu#" +IDS=`grep -v "^#" trace | sed -e 's/[[:space:]]*.*-\([[:digit:]]*\)[[:space:]]*\[\([[:digit:]]*\)\].*/\1 \2/'` + +read_pid_cpu() { + _PID=$1 + _CPU=`printf "%d" $2` +} + +read_pid_cpu $IDS + +: "Test raw output format" +echo 1 > options/raw +grep -v "^#" trace | grep "^$_PID $_CPU" || do_reset +echo 0 > options/raw + +: "Test hex output format" +echo 1 > options/hex +PAT=`printf "%08x %08x" $_PID $_CPU` +grep -v "^#" trace | grep "^$PAT" || do_reset +echo 0 > options/hex + +: "Test bin output format" +echo 1 > options/bin +PAT=`printf "%04x [[:xdigit:]]* [[:xdigit:]]*%02x" $_PID $_CPU` +# Make a stream of hexdump +grep -v "^#" trace | od -h | cut -f 2- -d " " | xargs echo | grep "$PAT" || do_reset +echo 0 > options/bin