Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp531768ybg; Mon, 1 Jun 2020 07:45:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXcQdzMAb8L3BwlsVND+3oD+HcaUcQVW9xm+vLuPNzLGq2glXe+fv70sfeW3rdftp6w8QB X-Received: by 2002:a17:906:5e08:: with SMTP id n8mr19854550eju.132.1591022702577; Mon, 01 Jun 2020 07:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591022702; cv=none; d=google.com; s=arc-20160816; b=CdFzRtBpjKH29yG4nc2tPiEc3FofTub5DpxoDSvdY1BFnKtvkGF6aNGT1OnuDkyRXI LUnxHWT3vxf94u5MalZjlYmoPlB3bZB6voQ+q1nZAVfHUCN4WF7t3KUyacNb3MM/XS7W FLCzXFtYKxeN0sbMnDaX3Pjw6Rj7EhHQhDMyzU4ebALkaigaqBTdZyt6sznIQCT1B236 7roIIrFLuAswS7RBOuTuF+xIl15gCE8vyXOMqSxFJbenEf9qZmAf2xn8GQQi6iWXxkcc jYdawFNaVjYnWLsdjQuTm8uLDa3Vk52hZLu8PY8ajFSfhOQRejNMyfKdgU02DWsxHrJ8 Zdvw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4G+O3D2ZMeIFfJCSsbaFIMkKlNGbIDLBR7CmEkysgQs=; b=gWWFRODSL4RcDuGcXZzwOnskkALeYoJkVaR+hG/XlqgRXKVZD9ehTZyha5TZtM0Gq8 4vS2pKk8QYjflCL3i+r7hovvsvgWDfn3hV9/8SK0PcRQmbIL6HveEnNsPz/v++1bYher TXwnfyXYbV14SI8KHG5fRWk9a3ff7EkhLbNoNmtYcN4+BYN04/dar7Sv/GhZK3rTlJir ey14t+3unauVUEeMmz7Gw+pudlIrmRP8jBanuGPm26WR1EA8MzevH5MdZyNKbAgWUSUf SVcKCA6W34BvFZjminJe/e+hTpefXPUHbQuzlgVQE+EQ3kH5WCXpMvBW9b/DnKyUp14Q oYiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="N7/G5E3S"; 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 j3si10625513ejb.294.2020.06.01.07.44.39; Mon, 01 Jun 2020 07:45:02 -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="N7/G5E3S"; 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 S1727828AbgFAOmi (ORCPT + 99 others); Mon, 1 Jun 2020 10:42:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:50412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726017AbgFAOmh (ORCPT ); Mon, 1 Jun 2020 10:42:37 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E6BA62074B; Mon, 1 Jun 2020 14:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591022556; bh=/qUCcHzpW3wKJxQdeY8BbIistWbJNBBTmLGi4DKJQi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N7/G5E3S5Dl6ByXpQBxlljvOZHmtq2PiCDFpmZ3x36v3K+bjypuYb8aJnPA3EKvor QLLZHMf/MeT5YIn98u+VcTPQYBUkfRNwjwQnT7n8UFjctQce1iI0Vn9IPK6M9XUiFb O9LPz/scTo64B2pHhqDO207e9HFvGzef8pJlH9o8= From: Masami Hiramatsu To: Shuah Khan , Steven Rostedt Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan , Tom Zanussi , Masami Hiramatsu Subject: [PATCH 3/7] selftests/ftrace: Add "requires:" list support Date: Mon, 1 Jun 2020 23:42:32 +0900 Message-Id: <159102255252.31199.7974644473989099256.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159102252279.31199.12855129586058455119.stgit@devnote2> References: <159102252279.31199.12855129586058455119.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce "requires:" list to check required ftrace interface for each test. This will simplify the interface checking code and unify the error message. Another good point is, it can skip the ftrace initializing. Note that this requires list must be written as a shell comment. Signed-off-by: Masami Hiramatsu --- tools/testing/selftests/ftrace/ftracetest | 8 +++++++- tools/testing/selftests/ftrace/test.d/functions | 9 +++++++++ tools/testing/selftests/ftrace/test.d/template | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest index d3f6652311ef..cdf7940b6610 100755 --- a/tools/testing/selftests/ftrace/ftracetest +++ b/tools/testing/selftests/ftrace/ftracetest @@ -267,6 +267,11 @@ testcase() { # testfile prlog -n "[$CASENO]$INSTANCE$desc" } +checkreq() { # testfile + requires=`grep "^#[ \t]*requires:" $1 | cut -f2- -d:` + check_requires $requires +} + test_on_instance() { # testfile grep -q "^#[ \t]*flags:.*instance" $1 } @@ -356,7 +361,8 @@ trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL __run_test() { # testfile # setup PID and PPID, $$ is not updated. - (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; initialize_ftrace; . $1) + (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; + checkreq $1; initialize_ftrace; . $1) [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID } diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions index 697c77ef2e2b..5100eb1ada0f 100644 --- a/tools/testing/selftests/ftrace/test.d/functions +++ b/tools/testing/selftests/ftrace/test.d/functions @@ -113,6 +113,15 @@ initialize_ftrace() { # Reset ftrace to initial-state enable_tracing } +check_requires() { # Check required files + for i in $* ; do + if [ ! -e $i ]; then + echo "Required feature interface $i doesn't exist." + exit_unsupported + fi + done +} + LOCALHOST=127.0.0.1 yield() { diff --git a/tools/testing/selftests/ftrace/test.d/template b/tools/testing/selftests/ftrace/test.d/template index e1a5d14c4eaf..d679e5c9e1ee 100644 --- a/tools/testing/selftests/ftrace/test.d/template +++ b/tools/testing/selftests/ftrace/test.d/template @@ -1,6 +1,7 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # description: %HERE DESCRIBE WHAT THIS DOES% +# requires: %HERE LIST UP REQUIRED FILES% # you have to add ".tc" extention for your testcase file # Note that all tests are run with "errexit" option.