From patchwork Fri Apr 28 15:34:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Maguire X-Patchwork-Id: 88675 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1017625vqo; Fri, 28 Apr 2023 08:38:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YMb61pCwsjB4VsMbzg2Kw2zOZU9fsBC1veuDr3aJ0IXML47wGhc4w8eUtQii9ZmaHEwl9 X-Received: by 2002:a17:902:9898:b0:1a6:961e:fcfe with SMTP id s24-20020a170902989800b001a6961efcfemr5022075plp.30.1682696313052; Fri, 28 Apr 2023 08:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682696313; cv=none; d=google.com; s=arc-20160816; b=noJD4Ry2VOVRJE79DcJTXUuocwAGaeaBH4hQrat37K4udmEASlTwfn15BvMGzRwg/b GBO6Q76KEQgsD9b9BNr0IuvoSmIDggLHJJJOMIG9veepPZKVacqHp5rGeH7PcJY2yyt7 x4/rHQsUmLcyejmVNSG5OEhf+lOudslUqZakxFd/AA290bvVGR+jnyO6P/OG/kJ0OF4F wr1dPwaMW9W4wddWMkjCps7Q63yOoqlEv7qjcuom8Yh5lBus6XrQ/p3FU2+lb0ABcMGT lrFUa0rL6upQfdocYfAvJgppTel3wOfuXD20jbezkwY/58IOUR7udcbwk/fcVZKYQoPa 8QnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=A8n7IWYsz0evWA6hKev01ep+OFzLGkqSGTqbwsVvpIE=; b=LpxpUCm8VCWhbuekzZHqLTseZoComLwsWQbonE7VFujZ6SE/THIIsyHTWaac3uwxjn tnypkxaPl5zrT8qZfi1KCy1JEjjA+M96ZTHgVH8ZvJoo8RuQsucGN/TNAlvYbUUs6Ve3 ebia/VOU08ZLHfy0ysFoKG0C513fLQ23neBVjBVr+w+6BMFE8qs6HrniAndk7RdJAuJM pZOPJAj/cskMPC7wrMZLy49QBBL7dB4a0kDQ/4nIRWdEqk58XgCf8yHYTXI81rFe4vEs 8LLWkeXwM6YBvQf2dHpkq6V57gBw9PooOw7yofKw3t5U8fkWtyfZ7NNV+hrJu8Il/ZWV 3KwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=1Dnp43vu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 126-20020a630184000000b00524cf94760csi19907626pgb.335.2023.04.28.08.38.20; Fri, 28 Apr 2023 08:38:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=1Dnp43vu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346116AbjD1Pfb (ORCPT + 99 others); Fri, 28 Apr 2023 11:35:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346531AbjD1PfL (ORCPT ); Fri, 28 Apr 2023 11:35:11 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C1375244; Fri, 28 Apr 2023 08:35:10 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33SF3p1x013972; Fri, 28 Apr 2023 15:35:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-03-30; bh=A8n7IWYsz0evWA6hKev01ep+OFzLGkqSGTqbwsVvpIE=; b=1Dnp43vuzDmcpvc08SYw3ZjNKtJj8cVlMZ+vvxNyNXmTu5sE9Hq7kFCYLd6yAQoyg52d 9G6OE23+ZiqsdPvy4EwGPu3PFkm7LPb4gl57A4FWebagbmknJozZ6Y/LBJ73IyKh3ywt m0/Z/UG8bJPVSX/OHWnv8JRLMAxHZEnK2cyBvBvP624UXst9hv2JLjUayoc5/AP1M6No 6Q4ihR8/UheZqjA812x638Fr3V06tXZ8RjZGFV5Etgh5c4XUX0ltouqoK5VUIpqxYQN9 y+8+ZHAHgIjMQ9/VY2+yIa2BAzBK+Izvd/LGaoQ2ANkdecLmJBmDGvdpiTPScxR5Sp5t ag== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q460def6d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:35:05 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33SE5fMg028161; Fri, 28 Apr 2023 15:35:05 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3q461b4ru3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 15:35:05 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33SFYqUK028134; Fri, 28 Apr 2023 15:35:04 GMT Received: from myrouter.uk.oracle.com (dhcp-10-175-188-60.vpn.oracle.com [10.175.188.60]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3q461b4rm0-6; Fri, 28 Apr 2023 15:35:04 +0000 From: Alan Maguire To: rostedt@goodmis.org, mhiramat@kernel.org Cc: corbet@lwn.net, shuah@kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Maguire Subject: [PATCH v2 tracing 5/6] selftests/ftrace: add test coverage for filter predicates Date: Fri, 28 Apr 2023 16:34:48 +0100 Message-Id: <1682696089-27937-6-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> References: <1682696089-27937-1-git-send-email-alan.maguire@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-28_04,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304280125 X-Proofpoint-GUID: Dvlj8wiFgnu_z9HszsNHs87LfXHJmZDC X-Proofpoint-ORIG-GUID: Dvlj8wiFgnu_z9HszsNHs87LfXHJmZDC X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764434969405916103?= X-GMAIL-MSGID: =?utf-8?q?1764434969405916103?= add tests verifying filter predicates work for 1/2/4/8/16 byte values, IPv4, IPv6, MAC addresses and strings; use predicats at event and subsystem level. Signed-off-by: Alan Maguire --- .../selftests/ftrace/test.d/event/filter.tc | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/event/filter.tc diff --git a/tools/testing/selftests/ftrace/test.d/event/filter.tc b/tools/testing/selftests/ftrace/test.d/event/filter.tc new file mode 100644 index 000000000000..21d4715e2176 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/event/filter.tc @@ -0,0 +1,91 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: event tracing - enable filter predicates +# requires: set_event events/sched +# flags: + +do_reset() { + echo 0 > ${event}/enable + echo 0 > ${event}/filter + clear_trace +} + +fail() { #msg + echo $1 + exit_fail +} + +test_filter() { # event filter cmd + event=$1 + filter="$2" + cmd=$3 + findevent=`basename $event` + echo "$filter" > ${event}/filter + echo 1 > ${event}/enable + $cmd + count=`grep $findevent trace |wc -l` + if [ $count -lt 1 ]; then + fail "at least one $event should be recorded for '$filter'" + fi + do_reset +} + +# verify filter predicates at trace event/subsys level for +# - string (prev_comm) +# - 1-byte value (common_flags) +# - 2-byte value (common_type) +# - 4-byte value (next_pid) +# - 8-byte value (prev_state) + +for event in events/sched/sched_switch events/sched +do + for filter in "prev_comm == 'ftracetest'" \ + "common_flags != 0" \ + "common_type >= 0" \ + "next_pid > 0" \ + "prev_state != 0" + do + test_filter "$event" "$filter" "yield" + done +done + +# verify '==', '!=' filter predicates for IPv4 addresses at event/subsys +# level +for event in events/fib/fib_table_lookup events/fib ; do + for filter in "dst == 127.0.0.1" \ + "src != 127.0.0.1" + do + test_filter "$event" "$filter" "ping -c 1 127.0.0.1" + done +done + +# verify '==', '!=' filter predicates for IPv6 addresses/16-byte arrays +# at event/subsys level +for event in events/fib6/fib6_table_lookup events/fib6 ; do + for filter in "dst == 0x00000000000000000000000000000001" \ + "src != 0x00000000000000000000000000000001" \ + "dst == ::1" \ + "src != ::1" \ + "dst == 0:0:0:0:0:0:0:1" \ + "dst == 0000:0000:0000:0000:0000:0000:0000:00001" + do + test_filter "$event" "$filter" "ping -c 1 -6 ::1" + done +done + +set +e +modprobe cfg80211 +set -e + +if [[ -d events/cfg80211/rdev_get_key ]]; then + for event in events/cfg80211/rdev_get_key ; do + for filter in "mac_addr == de:ad:be:ef:de:ad" \ + "mac_addr != AB:CD:EF:01:23:45" + do + echo "$filter" > events/cfg80211/rdev_get_key/filter + echo 0 > events/cfg80211/rdev_get_key/filter + done + done +fi + +exit 0