From nobody Sun May 10 09:54:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2300C433EF for ; Wed, 18 May 2022 04:20:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229713AbiEREUm (ORCPT ); Wed, 18 May 2022 00:20:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbiEREUi (ORCPT ); Wed, 18 May 2022 00:20:38 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BA5D21251 for ; Tue, 17 May 2022 21:20:36 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id o7-20020a256b47000000b0064ddc3bea70so914249ybm.4 for ; Tue, 17 May 2022 21:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=LvpJiUnSFpCiFAKE98nz9J5XPUyrNRc2U9N5mJnm5Hg=; b=Oju5r4aDWZ9Zqud5nYsTAl9JheS1ktMe0jzOrH9p2XeVTlhAYnaTONZuQnfO+3bjYp X12uYnhd/xGMi6E9AoSxjGdshhG1nM2sP2HCK8KnCu6Qdv1eLHfGgchPUcUgMzrMzm20 hQ2pXes2b6MoGLLnjMAWEcCYiB8/Poy7ITRbwbIoX4qU4sLyZUF+ZcZ8m/Tg75C61Nw7 W7867SE05iBb4gL3GcZ9Ro5E527A/V1EdYVfuvZikEFN8anOJ+r0b27zabd+GC0Qt3NF sD+xZrmcBXLBQ0lwBW0oc1lFNkPi+yTU4z1BD+LvMGfrJ3AKw/PUDMGl87JZTnaVO5HT f6dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=LvpJiUnSFpCiFAKE98nz9J5XPUyrNRc2U9N5mJnm5Hg=; b=pbAxrE4TEYVga5QIhD7lBrxBMeDl4so/j1PMBr1I0Dkq/3kaJoDYDUMjW+atMtw8/f tbFYg7NmPt8tG+bH2bGU9J3gj+mEIfgIf6a/pnoguhIEXeN0/kemHBP2ddcZ0KFSUbKq 4RsCiNv9i41o5f8u7qA8qcnu9KwDWuYIHSSyWhb0x2XTjsrcpivpRo84bhIl8UIrBRWm U7Xxw1fzqyewmQfCX0/5SMV5+xT7ObhjFoWJalIQG0VwXW/X+zqNO5bDDnGvLxdYh99f evHhvaEzM2NHxiHJap2SYAFNj/lCp3J8LhdxabWdeUNJZYwHWsR2TqNEa7hKLD35smF/ 09Iw== X-Gm-Message-State: AOAM533Bx0I/8LbZtaHmrjyE+R4X0MPukt4uJfiPUoCoRG2Vr6QfV2iE YKQ4MfWrTiur0tuB646159q/HWDiReuw X-Google-Smtp-Source: ABdhPJxa786aBoSAGP95NfMFnlI9dLOPTNSKBMoSDyj9KewGk9Xm9VagNfnviFtvuciptpIl68JDMEXQG9Go X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:a5a1:af73:fe09:fd5]) (user=irogers job=sendgmr) by 2002:a25:bd05:0:b0:64d:6ee0:f503 with SMTP id f5-20020a25bd05000000b0064d6ee0f503mr17703514ybk.415.1652847635670; Tue, 17 May 2022 21:20:35 -0700 (PDT) Date: Tue, 17 May 2022 21:20:20 -0700 In-Reply-To: <20220518042027.836799-1-irogers@google.com> Message-Id: <20220518042027.836799-2-irogers@google.com> Mime-Version: 1.0 References: <20220518042027.836799-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.550.gb090851708-goog Subject: [PATCH v2 1/8] perf test: Skip reason for suites with 1 test From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Riccardo Mancini , Sohaib Mohamed , Carsten Haitzler , Marco Elver , John Garry , Michael Petlan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a suite has just 1 subtest, the subtest number is given as -1 to avoid indented printing. When this subtest number is seen for the skip reason, use the reason of the first test. Reviewed-by: John Garry Acked-by: Namhyung Kim Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index fac3717d9ba1..33fcafa0fa79 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -137,10 +137,10 @@ static bool has_subtests(const struct test_suite *t) =20 static const char *skip_reason(const struct test_suite *t, int subtest) { - if (t->test_cases && subtest >=3D 0) - return t->test_cases[subtest].skip_reason; + if (!t->test_cases) + return NULL; =20 - return NULL; + return t->test_cases[subtest >=3D 0 ? subtest : 0].skip_reason; } =20 static const char *test_description(const struct test_suite *t, int subtes= t) --=20 2.36.0.550.gb090851708-goog From nobody Sun May 10 09:54:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F27E0C433FE for ; Wed, 18 May 2022 04:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbiEREUq (ORCPT ); Wed, 18 May 2022 00:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbiEREUj (ORCPT ); Wed, 18 May 2022 00:20:39 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAAD521251 for ; Tue, 17 May 2022 21:20:38 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id c205-20020a254ed6000000b0064d5bd93479so873953ybb.17 for ; Tue, 17 May 2022 21:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=/et+mNXky9AxgqPAZ+01K1qLv9QXAe8M1JaYskOrLf4=; b=aYImPI0UwHk+52e5no/ILuPrJfO3c3hinpptzjjpVQXzYxqXKctJPuu6vh7PjAQwGh 5YxQ59UjalDv7cVWGPtIZUuQ67qUayzv7cX/6ZWbi4VtWGZIntGJOb3oWax4NCunNetS L8ZekdeFUTPnlfnT/r6EWJQwP8FzXZBbrsR983XBL6YbqumBcv1Ae5jjGClfiVfGCvrI rGqtJgbI8D9AZQTHjd1+TSZZIKCzzisFzHV1NI+98fTGdpbqwa/yxR7MQvL0NUpNoiwx ++/W35XpKsPWGA7XCcN5TISjB1/eLUlL3VFNK11UkwGm/Fx1+DDzUKq1Z0GaLwmGepRA Oo9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/et+mNXky9AxgqPAZ+01K1qLv9QXAe8M1JaYskOrLf4=; b=ZZwFc0XaIg93ShsjRpmJ2L7nhEkmdeJYUVXrcekhUm5oK5uoTlM2mjT35l9YSoKfP8 kbng+6Qg/BmP70fCAXvwrWeDEQ5/IfDER1YOne4QccuHGpTYf7oB+9JHqDN6HQJgwcNF 3mU9agg+IO1FVtnB83lXpnaXWq8T4gXeI92c0X2poNx0DK2QTRNYCkloLdS3NxUrkG56 tpnRczT61L9lA6fpvIwyxtooreUIiddbwcGRGcwftmpop5QuWQzNRxl16xDjMIaqV8bC ch7CVIRWtR70Z2tDa7xrYD3VdAVoQlTL7+aI2zWH+pciPwIoegTDaQ0TUrjQeiHVgin6 ifTQ== X-Gm-Message-State: AOAM530OqOMmd7/Xp72jlI4yw3K+vh8ZVDuBBl1ZSLCueonJzGVYnpAo 2JkWp0+NgQn1O+W0HMHO8YGLn+pYj5jR X-Google-Smtp-Source: ABdhPJzA31F5Eh2pcBc3NkRDp7vhQd5a9Npu6LdorVkBhQJSHBs+FimXYU6pTuBJ4J9+7Ei5NKS7HwZYyWmk X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:a5a1:af73:fe09:fd5]) (user=irogers job=sendgmr) by 2002:a25:7008:0:b0:648:6d04:f4ab with SMTP id l8-20020a257008000000b006486d04f4abmr26390471ybc.127.1652847637939; Tue, 17 May 2022 21:20:37 -0700 (PDT) Date: Tue, 17 May 2022 21:20:21 -0700 In-Reply-To: <20220518042027.836799-1-irogers@google.com> Message-Id: <20220518042027.836799-3-irogers@google.com> Mime-Version: 1.0 References: <20220518042027.836799-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.550.gb090851708-goog Subject: [PATCH v2 2/8] perf test: Use skip in vmlinux kallsyms From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Riccardo Mancini , Sohaib Mohamed , Carsten Haitzler , Marco Elver , John Garry , Michael Petlan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently failures in reading vmlinux or kallsyms result in a test failure. However, the failure is typically permission related. Prefer to flag these failures as skip. Signed-off-by: Ian Rogers --- tools/perf/tests/vmlinux-kallsyms.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux= -kallsyms.c index 93dee542a177..4fd8d703ff19 100644 --- a/tools/perf/tests/vmlinux-kallsyms.c +++ b/tools/perf/tests/vmlinux-kallsyms.c @@ -114,7 +114,7 @@ static bool is_ignored_symbol(const char *name, char ty= pe) static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_= unused, int subtest __maybe_unused) { - int err =3D -1; + int err =3D TEST_FAIL; struct rb_node *nd; struct symbol *sym; struct map *kallsyms_map, *vmlinux_map, *map; @@ -142,7 +142,8 @@ static int test__vmlinux_matches_kallsyms(struct test_s= uite *test __maybe_unused * and find the .ko files that match them in /lib/modules/`uname -r`/. */ if (machine__create_kernel_maps(&kallsyms) < 0) { - pr_debug("machine__create_kernel_maps "); + pr_debug("machine__create_kernel_maps failed"); + err =3D TEST_SKIP; goto out; } =20 @@ -158,7 +159,8 @@ static int test__vmlinux_matches_kallsyms(struct test_s= uite *test __maybe_unused * code and with the one got from /proc/modules from the "kallsyms" code. */ if (machine__load_kallsyms(&kallsyms, "/proc/kallsyms") <=3D 0) { - pr_debug("dso__load_kallsyms "); + pr_debug("machine__load_kallsyms failed"); + err =3D TEST_SKIP; goto out; } =20 @@ -178,7 +180,7 @@ static int test__vmlinux_matches_kallsyms(struct test_s= uite *test __maybe_unused * Now repeat step 2, this time for the vmlinux file we'll auto-locate. */ if (machine__create_kernel_maps(&vmlinux) < 0) { - pr_debug("machine__create_kernel_maps "); + pr_info("machine__create_kernel_maps failed"); goto out; } =20 @@ -196,7 +198,7 @@ static int test__vmlinux_matches_kallsyms(struct test_s= uite *test __maybe_unused * to fixup the symbols. */ if (machine__load_vmlinux_path(&vmlinux) <=3D 0) { - pr_debug("Couldn't find a vmlinux that matches the kernel running on thi= s machine, skipping test\n"); + pr_info("Couldn't find a vmlinux that matches the kernel running on this= machine, skipping test\n"); err =3D TEST_SKIP; goto out; } --=20 2.36.0.550.gb090851708-goog From nobody Sun May 10 09:54:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5069EC433F5 for ; Wed, 18 May 2022 04:20:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229737AbiEREUv (ORCPT ); Wed, 18 May 2022 00:20:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbiEREUm (ORCPT ); Wed, 18 May 2022 00:20:42 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D99621277 for ; Tue, 17 May 2022 21:20:41 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id i17-20020a259d11000000b0064cd3084085so902543ybp.9 for ; Tue, 17 May 2022 21:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=y38KhyrUQduygK/6m8o41nq8hRxktYPzYp+6Ci4BGNw=; b=TpddIbIN7gqaeMZgnNcQVm4CEyupQQTIb3Stzc/l/sAfWrKi3wWYHHHnRKx93bqifx AfBXieoluKZYrXmEJNfrVOapq9PkgU5HcvKFh35RuWkAH1DeeDTFW6i0UOVdgzB8BhIA FZLAD8pImRG4aX2/wz6xRNNWO8cCtldYi/CWEz+dLINAdObqbG1Q3BkhJmascIm13vIV c4F+B9Of1oeWTC2t0QA1SnDP4DXbEVpRdfcuIlN97qyhLQanKxBv3du1fmwQICvhqKoU dign3evoPIY+ENjBpJzTL1KgyCp5e+z6NxBZXVhRZKYeuhYB7wNGmgaBZQzkwREjlHxE 5dPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=y38KhyrUQduygK/6m8o41nq8hRxktYPzYp+6Ci4BGNw=; b=EYB8xlF342wv+83ykicDDkxpstUHDlD3vNPvezQjey9QDVf6tN+oWKZ41DT9Tqs22j 2/H9QXkq/wP2PSx0TOrDhmHSAnBxtvcI2YKVhProvu+e8MeJi45sBkVxwVzEbIKzSUnW RktpQ03TLD93Z2uqAwLBffN8x4HNuoAoVKp7Qozv9VynPNqmPeTkBJ2p94k/T4C81uO0 rNvE84yFXaXtCXFPxxECiGPtPUYUwOyDGyg0f1R2gP+VND7cHFMTH7wmOkoGpMw3hBVt 6K8wYCtq9z9hW6QvKw6yBDLSNnoTM0nyWlsYsB/ALsJovNlG7kz5oB6vLSsJy3OU38Oo 3JXw== X-Gm-Message-State: AOAM531W+ch+bmPd0MPxq8VsLFUjUXFNZnq/ump++qiLULHrDKDnuFtD XFbETlIEF9F0g/rxznQWul5ksJqr/gq8 X-Google-Smtp-Source: ABdhPJy8VOPVmejo54U8ul9PvBKvNnuOhOiD9VhmDwDPVhx55pUpqe/7X3lHJjTvY2ykkIkVD+OO3ij3RWLm X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:a5a1:af73:fe09:fd5]) (user=irogers job=sendgmr) by 2002:a25:ab0c:0:b0:64d:a92b:3135 with SMTP id u12-20020a25ab0c000000b0064da92b3135mr13324412ybi.552.1652847640317; Tue, 17 May 2022 21:20:40 -0700 (PDT) Date: Tue, 17 May 2022 21:20:22 -0700 In-Reply-To: <20220518042027.836799-1-irogers@google.com> Message-Id: <20220518042027.836799-4-irogers@google.com> Mime-Version: 1.0 References: <20220518042027.836799-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.550.gb090851708-goog Subject: [PATCH v2 3/8] perf test: Use skip in openat syscall From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Riccardo Mancini , Sohaib Mohamed , Carsten Haitzler , Marco Elver , John Garry , Michael Petlan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Failures to open the tracepoint cause this test to fail, however, typically such failures are permission related. Lower the failure to just skipping the test in those cases and add a skip reason. Signed-off-by: Ian Rogers --- tools/perf/tests/openat-syscall-all-cpus.c | 23 +++++++++++++++++----- tools/perf/tests/openat-syscall.c | 20 +++++++++++++++---- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/= openat-syscall-all-cpus.c index 1ab362323d25..90828ae03ef5 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c @@ -22,7 +22,7 @@ static int test__openat_syscall_event_on_all_cpus(struct test_suite *test = __maybe_unused, int subtest __maybe_unused) { - int err =3D -1, fd, idx; + int err =3D TEST_FAIL, fd, idx; struct perf_cpu cpu; struct perf_cpu_map *cpus; struct evsel *evsel; @@ -49,6 +49,7 @@ static int test__openat_syscall_event_on_all_cpus(struct = test_suite *test __mayb if (IS_ERR(evsel)) { tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls"= , "sys_enter_openat"); pr_debug("%s\n", errbuf); + err =3D TEST_SKIP; goto out_cpu_map_delete; } =20 @@ -56,6 +57,7 @@ static int test__openat_syscall_event_on_all_cpus(struct = test_suite *test __mayb pr_debug("failed to open counter: %s, " "tweak /proc/sys/kernel/perf_event_paranoid?\n", str_error_r(errno, sbuf, sizeof(sbuf))); + err =3D TEST_SKIP; goto out_evsel_delete; } =20 @@ -88,7 +90,7 @@ static int test__openat_syscall_event_on_all_cpus(struct = test_suite *test __mayb =20 evsel->core.cpus =3D perf_cpu_map__get(cpus); =20 - err =3D 0; + err =3D TEST_OK; =20 perf_cpu_map__for_each_cpu(cpu, idx, cpus) { unsigned int expected; @@ -98,7 +100,7 @@ static int test__openat_syscall_event_on_all_cpus(struct= test_suite *test __mayb =20 if (evsel__read_on_cpu(evsel, idx, 0) < 0) { pr_debug("evsel__read_on_cpu\n"); - err =3D -1; + err =3D TEST_FAIL; break; } =20 @@ -106,7 +108,7 @@ static int test__openat_syscall_event_on_all_cpus(struc= t test_suite *test __mayb if (perf_counts(evsel->counts, idx, 0)->val !=3D expected) { pr_debug("evsel__read_on_cpu: expected to intercept %d calls on cpu %d,= got %" PRIu64 "\n", expected, cpu.cpu, perf_counts(evsel->counts, idx, 0)->val); - err =3D -1; + err =3D TEST_FAIL; } } =20 @@ -122,4 +124,15 @@ static int test__openat_syscall_event_on_all_cpus(stru= ct test_suite *test __mayb return err; } =20 -DEFINE_SUITE("Detect openat syscall event on all cpus", openat_syscall_eve= nt_on_all_cpus); + +static struct test_case tests__openat_syscall_event_on_all_cpus[] =3D { + TEST_CASE_REASON("Detect openat syscall event on all cpus", + openat_syscall_event_on_all_cpus, + "permissions"), + { .name =3D NULL, } +}; + +struct test_suite suite__openat_syscall_event_on_all_cpus =3D { + .desc =3D "Detect openat syscall event on all cpus", + .test_cases =3D tests__openat_syscall_event_on_all_cpus, +}; diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-sy= scall.c index 7f4c13c4b14d..7e05b8b5cc95 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c @@ -16,7 +16,7 @@ static int test__openat_syscall_event(struct test_suite *test __maybe_unus= ed, int subtest __maybe_unused) { - int err =3D -1, fd; + int err =3D TEST_FAIL, fd; struct evsel *evsel; unsigned int nr_openat_calls =3D 111, i; struct perf_thread_map *threads =3D thread_map__new(-1, getpid(), UINT_MA= X); @@ -25,13 +25,14 @@ static int test__openat_syscall_event(struct test_suite= *test __maybe_unused, =20 if (threads =3D=3D NULL) { pr_debug("thread_map__new\n"); - return -1; + return TEST_FAIL; } =20 evsel =3D evsel__newtp("syscalls", "sys_enter_openat"); if (IS_ERR(evsel)) { tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls"= , "sys_enter_openat"); pr_debug("%s\n", errbuf); + err =3D TEST_SKIP; goto out_thread_map_delete; } =20 @@ -39,6 +40,7 @@ static int test__openat_syscall_event(struct test_suite *= test __maybe_unused, pr_debug("failed to open counter: %s, " "tweak /proc/sys/kernel/perf_event_paranoid?\n", str_error_r(errno, sbuf, sizeof(sbuf))); + err =3D TEST_SKIP; goto out_evsel_delete; } =20 @@ -58,7 +60,7 @@ static int test__openat_syscall_event(struct test_suite *= test __maybe_unused, goto out_close_fd; } =20 - err =3D 0; + err =3D TEST_OK; out_close_fd: perf_evsel__close_fd(&evsel->core); out_evsel_delete: @@ -68,4 +70,14 @@ static int test__openat_syscall_event(struct test_suite = *test __maybe_unused, return err; } =20 -DEFINE_SUITE("Detect openat syscall event", openat_syscall_event); +static struct test_case tests__openat_syscall_event[] =3D { + TEST_CASE_REASON("Detect openat syscall event", + openat_syscall_event, + "permissions"), + { .name =3D NULL, } +}; + +struct test_suite suite__openat_syscall_event =3D { + .desc =3D "Detect openat syscall event", + .test_cases =3D tests__openat_syscall_event, +}; --=20 2.36.0.550.gb090851708-goog From nobody Sun May 10 09:54:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53302C433F5 for ; Wed, 18 May 2022 04:20:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229792AbiEREU4 (ORCPT ); Wed, 18 May 2022 00:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbiEREUo (ORCPT ); Wed, 18 May 2022 00:20:44 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91DC721256 for ; Tue, 17 May 2022 21:20:43 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2fefb9975c5so9978257b3.21 for ; Tue, 17 May 2022 21:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=kOmtF4LnMuuQ/gYjp/xxv4tsoB08CtJrje0cWKy7hYw=; b=hWhJnnH0w5iGS/GIOoqC3YyLdpf9RPFFxzQRXWn1cfjUu8CCUQ1G7gXpOXinWF6KWe 65MKumXCZHhuUk9OJ8M4piP7avxlCnYNiked6F5G2gyK8kcbS/qAQ2x+6DEJYCbOMmUo ah+X6RrmXP+37TkuQkEEkmKiyfPRd+ypteVXqhZDrUi2Ifv79IjRInSdotFycX3lsK0m 1NuobwHUtsTDL76MFgHI7oVdPrVGSXLFBGyFL4Tk7UiiaNrCqYpLNBa5k0jsDf20xaDu Vl5KgOsedi8KooEKXJR1RlkcfrtwKO68u3HhhVDIQs+7x51wHPoG+vw8FhYDWEmGWMzS BPXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=kOmtF4LnMuuQ/gYjp/xxv4tsoB08CtJrje0cWKy7hYw=; b=urz24yatCGiLl/hUOJcxVhJYl5IB/Qb1U+ovTMvL9A1TGUJaQL5dNTW6jGMpK3oA8Q WACeMXFJWJSx30HSZsg3jalm/uwxNtH7JokXzGIy9yJrADjRFMLiPPo/UPJpt83yXr1m GOZYGPhEv/rh7JkntD1fBB/rFbmzqoTvRKwi4dLPfrMfo8ua/eEVic9F4aiEZuGTcIK9 jRVPli5vqKvkkhuBP2eSVLgQihGFLVhBv6t/jpw6qw+25/UAfqqbg35TAT5YkCMbE+My YUj9vqIheKCqNcybr4qX//BKL4dAZHJKa/MZIJ2rBWbzd7dhZe6P+/3WI2sUPvc70Vmq 0L9A== X-Gm-Message-State: AOAM5323MRvzBx28WQI8Oxlfn1Rb5jIN59hznEUApmd+myIRUXxdEiAW ESb1F35xY5feC/TaEDPT2KeYq7cvc9jf X-Google-Smtp-Source: ABdhPJwa1yFHsKuws2qp1gAJ3FcCd+gq92TewZjLW654L9XrDnT3QHmktY5N+Lwvws51YRwziIVR33ixRnIZ X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:a5a1:af73:fe09:fd5]) (user=irogers job=sendgmr) by 2002:a25:8b81:0:b0:64b:3ea3:5cd with SMTP id j1-20020a258b81000000b0064b3ea305cdmr24520130ybl.542.1652847642452; Tue, 17 May 2022 21:20:42 -0700 (PDT) Date: Tue, 17 May 2022 21:20:23 -0700 In-Reply-To: <20220518042027.836799-1-irogers@google.com> Message-Id: <20220518042027.836799-5-irogers@google.com> Mime-Version: 1.0 References: <20220518042027.836799-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.550.gb090851708-goog Subject: [PATCH v2 4/8] perf test: Basic mmap use skip From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Riccardo Mancini , Sohaib Mohamed , Carsten Haitzler , Marco Elver , John Garry , Michael Petlan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If opening the event fails for basic mmap with EACCES it is more likely permission related that a true error. Mark the test as skip in this case and add a skip reason. Signed-off-by: Ian Rogers --- tools/perf/tests/mmap-basic.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index c3c17600f29c..30bbe144648a 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -31,7 +31,7 @@ */ static int test__basic_mmap(struct test_suite *test __maybe_unused, int su= btest __maybe_unused) { - int err =3D -1; + int err =3D TEST_FAIL; union perf_event *event; struct perf_thread_map *threads; struct perf_cpu_map *cpus; @@ -83,6 +83,10 @@ static int test__basic_mmap(struct test_suite *test __ma= ybe_unused, int subtest evsels[i] =3D evsel__newtp("syscalls", name); if (IS_ERR(evsels[i])) { pr_debug("evsel__new(%s)\n", name); + if (PTR_ERR(evsels[i]) =3D=3D -EACCES) { + /* Permissions failure, flag the failure as a skip. */ + err =3D TEST_SKIP; + } goto out_delete_evlist; } =20 @@ -166,4 +170,14 @@ static int test__basic_mmap(struct test_suite *test __= maybe_unused, int subtest return err; } =20 -DEFINE_SUITE("Read samples using the mmap interface", basic_mmap); +static struct test_case tests__basic_mmap[] =3D { + TEST_CASE_REASON("Read samples using the mmap interface", + basic_mmap, + "permissions"), + { .name =3D NULL, } +}; + +struct test_suite suite__basic_mmap =3D { + .desc =3D "Read samples using the mmap interface", + .test_cases =3D tests__basic_mmap, +}; --=20 2.36.0.550.gb090851708-goog From nobody Sun May 10 09:54:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ED1AC433F5 for ; Wed, 18 May 2022 04:21:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229803AbiEREU6 (ORCPT ); Wed, 18 May 2022 00:20:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229766AbiEREUq (ORCPT ); Wed, 18 May 2022 00:20:46 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 027D431239 for ; Tue, 17 May 2022 21:20:45 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id i17-20020a259d11000000b0064cd3084085so902543ybp.9 for ; Tue, 17 May 2022 21:20:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=MAjYUcMF8cvSpD3IrXmmGZ0bseIJMHTYZTi0/EOkzbY=; b=hv3dMBW1DzxUFqDSoqbUa/6gJniNJqbIIJNdZQcmA7P+ITyZmLb6I5NNftuPGDYfGW okMSyVlMbNG3+WuXeFKmZQs4JS4kvG9SmunFGg6AvF1NQVTEiLeA8wNRh+wmBTVlB3v4 iF4940Rek9QdNEqLGRRe+xga0x1HVwIJWCmmDepx2hLrScQOcbl+Kg6jkBTPjuPMoqS5 FZSRfzmxjAuIoRWS8Pt2+M/ImhPMQ0MLNojnqR1RHXD8bFKa9hGQ1iC2XIIKLE4OuLkE km7Scd7JnQ7jbphbMcPhJk+uiojuwneha8rMzg0EFkY6rGZR5rNAdC/cqDaFMglmH5rw anUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=MAjYUcMF8cvSpD3IrXmmGZ0bseIJMHTYZTi0/EOkzbY=; b=uyNmnWia0rccFY9l8KWJmcozOyUeNvgUf3DKDKepjWn23zJLxWUXQqWF6+/lU4ssLO oHgdiqS7Ooj3RNaVDi22OO918yUKDEQvZEhxN6yhTYJiJr8DCA+o3+rzY4lz5Wf0aAtu XM2oP/QJ8gPXHRgmiyRGZxTy5L1J3WvndlhFhY9TdD3v5Qw3ng1G7moX2kcsPNIZWMa1 IkafhL+PxyeeP8aYG6FjoZYZ/tfhiCud43vmVH1WbbCA3Nk0sJeK1Q271CrR6wmDUy/g l4wPWZZVLJMxB6qQGN2pxlWDnSqvueXJPS6DwZy87grRQu8WdARnDtoFkHHOHAClvC0H pdbA== X-Gm-Message-State: AOAM5322IfcdhuGXmz4UXZ9FIoc6cZMPrmg5aIHAobiCsdkSMDjINwl7 abKkKDXouP+e+CIkFaiGLiyTxaUjeSRt X-Google-Smtp-Source: ABdhPJz/Y25em1LQBTduunNiZnS002a0H+EyC5tCC0TQ93KtFWaUz8g3VoSCuofQQQbf9zZEVQ5oPizqZzlx X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:a5a1:af73:fe09:fd5]) (user=irogers job=sendgmr) by 2002:a25:c7d0:0:b0:64d:a15e:7599 with SMTP id w199-20020a25c7d0000000b0064da15e7599mr13472934ybe.251.1652847644539; Tue, 17 May 2022 21:20:44 -0700 (PDT) Date: Tue, 17 May 2022 21:20:24 -0700 In-Reply-To: <20220518042027.836799-1-irogers@google.com> Message-Id: <20220518042027.836799-6-irogers@google.com> Mime-Version: 1.0 References: <20220518042027.836799-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.550.gb090851708-goog Subject: [PATCH v2 5/8] perf test: Parse events tidy terms_test From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Riccardo Mancini , Sohaib Mohamed , Carsten Haitzler , Marco Elver , John Garry , Michael Petlan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove an unused variables. Make structs const. Fix checkpatch issue wrt unsigned not being with an int. Signed-off-by: Ian Rogers --- tools/perf/tests/parse-events.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-event= s.c index e71efadb24f5..7e802666d2d5 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -1980,11 +1980,10 @@ static struct evlist_test test__events_pmu[] =3D { =20 struct terms_test { const char *str; - __u32 type; int (*check)(struct list_head *terms); }; =20 -static struct terms_test test__terms[] =3D { +static const struct terms_test test__terms[] =3D { [0] =3D { .str =3D "config=3D10,config1,config2=3D3,umask=3D1,read,r0xead", .check =3D test__checkterms_simple, @@ -2112,7 +2111,7 @@ static int test_events(struct evlist_test *events, un= signed cnt) return ret2; } =20 -static int test_term(struct terms_test *t) +static int test_term(const struct terms_test *t) { struct list_head terms; int ret; @@ -2139,13 +2138,12 @@ static int test_term(struct terms_test *t) return ret; } =20 -static int test_terms(struct terms_test *terms, unsigned cnt) +static int test_terms(const struct terms_test *terms, int cnt) { int ret =3D 0; - unsigned i; =20 - for (i =3D 0; i < cnt; i++) { - struct terms_test *t =3D &terms[i]; + for (int i =3D 0; i < cnt; i++) { + const struct terms_test *t =3D &terms[i]; =20 pr_debug("running test %d '%s'\n", i, t->str); ret =3D test_term(t); --=20 2.36.0.550.gb090851708-goog From nobody Sun May 10 09:54:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B263C433EF for ; Wed, 18 May 2022 04:21:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229644AbiEREVH (ORCPT ); Wed, 18 May 2022 00:21:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbiEREUv (ORCPT ); Wed, 18 May 2022 00:20:51 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6350331345 for ; Tue, 17 May 2022 21:20:47 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2fed8245a03so10723017b3.1 for ; Tue, 17 May 2022 21:20:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=TnD0korMG/FM5gYCmH1Njrgw72EedmnJt8tATKJ2XT4=; b=khfembNG8zneSKuQEEHGn0lq/InWcEWDv4RIyS1CnNSqUtEwWEPOezARmLO3MiEC/0 ZfLiShPvRXMV4E+qOTsmH4sF4PLl3TaP9sLnJJC1wV6dchTnqi+Z8lDkwy9yB1wwzjgc q6VEOg0PuIaGdcE/JzO59TisF7kOMmB4lHaxvY/M+O2PA75KfU+dY8ZbZ0ISnuEQ52N8 47gPcRg2SrNEflwnK4Mb1+RI+KqykYO+VHSDZmKOLpXyY/Jh+wm44PlTju2MtzbTRLd1 IxePjeUr8bHPwh04yvR9g4GdKeT3p/LkbVE7apsPCKOGlX3WBHxChnl33E1fS0IcBRcx yjyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=TnD0korMG/FM5gYCmH1Njrgw72EedmnJt8tATKJ2XT4=; b=4x5kr+Sm3COXQSr+B1bWTBwMA9ELVmFhZyRpEq56jYvHt9Ot2UdPsG3ocCubOttpts X9+3o56iTfvmR7twMrSRCXjP9DsuKDxkbgv5UGvULWjhzoTJ1G0pVJVc+m85I+im/2wG RN8mYJj1zEcmSwaH9KEkxrxonF4uP3Oln6vZTUd/Q74bMomjh7sx+9FP7LDaX+qd7sJX wC/7a+/1DyLUasU86AmuJiYxhikWCwYqqXy6lF9nWaMc0B0ZaFsjPODCizB7ynMdDT2g DXAsOx0KZCxuhkpwu5nMVJpHog/Huhi14/aVkOx+UXllwyTJDKwSK3ZyFUp/gGv2Arnf /g+g== X-Gm-Message-State: AOAM531R500drxVoYeNoGnMtGXCmDUz5HLs979dH16QDIe7hoCNXk2za uQ3dC0h/D4kyrAUi8jYQEHSyCPP0V4h3 X-Google-Smtp-Source: ABdhPJz22hKpEg61DXNKla1u8OL158NTgqC854yWWibewPZZGMH6VhUPRxorNGHZahavCxgarFXR3UEjpm8W X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:a5a1:af73:fe09:fd5]) (user=irogers job=sendgmr) by 2002:a81:1a4f:0:b0:2f8:9a6:62d6 with SMTP id a76-20020a811a4f000000b002f809a662d6mr29831710ywa.74.1652847646532; Tue, 17 May 2022 21:20:46 -0700 (PDT) Date: Tue, 17 May 2022 21:20:25 -0700 In-Reply-To: <20220518042027.836799-1-irogers@google.com> Message-Id: <20220518042027.836799-7-irogers@google.com> Mime-Version: 1.0 References: <20220518042027.836799-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.550.gb090851708-goog Subject: [PATCH v2 6/8] perf test: Parse events tidy evlist_test From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Riccardo Mancini , Sohaib Mohamed , Carsten Haitzler , Marco Elver , John Garry , Michael Petlan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove two unused variables. Make structs const. Also fix the array index (aka id) for the event software/r0x1a/. Signed-off-by: Ian Rogers --- tools/perf/tests/parse-events.c | 171 ++++++++++++++++---------------- 1 file changed, 84 insertions(+), 87 deletions(-) diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-event= s.c index 7e802666d2d5..0d65770bd686 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -1637,344 +1637,342 @@ static int test__hybrid_cache_event(struct evlist= *evlist) =20 struct evlist_test { const char *name; - __u32 type; - const int id; bool (*valid)(void); int (*check)(struct evlist *evlist); }; =20 -static struct evlist_test test__events[] =3D { +static const struct evlist_test test__events[] =3D { { .name =3D "syscalls:sys_enter_openat", .check =3D test__checkevent_tracepoint, - .id =3D 0, + /* 0 */ }, { .name =3D "syscalls:*", .check =3D test__checkevent_tracepoint_multi, - .id =3D 1, + /* 1 */ }, { .name =3D "r1a", .check =3D test__checkevent_raw, - .id =3D 2, + /* 2 */ }, { .name =3D "1:1", .check =3D test__checkevent_numeric, - .id =3D 3, + /* 3 */ }, { .name =3D "instructions", .check =3D test__checkevent_symbolic_name, - .id =3D 4, + /* 4 */ }, { .name =3D "cycles/period=3D100000,config2/", .check =3D test__checkevent_symbolic_name_config, - .id =3D 5, + /* 5 */ }, { .name =3D "faults", .check =3D test__checkevent_symbolic_alias, - .id =3D 6, + /* 6 */ }, { .name =3D "L1-dcache-load-miss", .check =3D test__checkevent_genhw, - .id =3D 7, + /* 7 */ }, { .name =3D "mem:0", .check =3D test__checkevent_breakpoint, - .id =3D 8, + /* 8 */ }, { .name =3D "mem:0:x", .check =3D test__checkevent_breakpoint_x, - .id =3D 9, + /* 9 */ }, { .name =3D "mem:0:r", .check =3D test__checkevent_breakpoint_r, - .id =3D 10, + /* 0 */ }, { .name =3D "mem:0:w", .check =3D test__checkevent_breakpoint_w, - .id =3D 11, + /* 1 */ }, { .name =3D "syscalls:sys_enter_openat:k", .check =3D test__checkevent_tracepoint_modifier, - .id =3D 12, + /* 2 */ }, { .name =3D "syscalls:*:u", .check =3D test__checkevent_tracepoint_multi_modifier, - .id =3D 13, + /* 3 */ }, { .name =3D "r1a:kp", .check =3D test__checkevent_raw_modifier, - .id =3D 14, + /* 4 */ }, { .name =3D "1:1:hp", .check =3D test__checkevent_numeric_modifier, - .id =3D 15, + /* 5 */ }, { .name =3D "instructions:h", .check =3D test__checkevent_symbolic_name_modifier, - .id =3D 16, + /* 6 */ }, { .name =3D "faults:u", .check =3D test__checkevent_symbolic_alias_modifier, - .id =3D 17, + /* 7 */ }, { .name =3D "L1-dcache-load-miss:kp", .check =3D test__checkevent_genhw_modifier, - .id =3D 18, + /* 8 */ }, { .name =3D "mem:0:u", .check =3D test__checkevent_breakpoint_modifier, - .id =3D 19, + /* 9 */ }, { .name =3D "mem:0:x:k", .check =3D test__checkevent_breakpoint_x_modifier, - .id =3D 20, + /* 0 */ }, { .name =3D "mem:0:r:hp", .check =3D test__checkevent_breakpoint_r_modifier, - .id =3D 21, + /* 1 */ }, { .name =3D "mem:0:w:up", .check =3D test__checkevent_breakpoint_w_modifier, - .id =3D 22, + /* 2 */ }, { .name =3D "r1,syscalls:sys_enter_openat:k,1:1:hp", .check =3D test__checkevent_list, - .id =3D 23, + /* 3 */ }, { .name =3D "instructions:G", .check =3D test__checkevent_exclude_host_modifier, - .id =3D 24, + /* 4 */ }, { .name =3D "instructions:H", .check =3D test__checkevent_exclude_guest_modifier, - .id =3D 25, + /* 5 */ }, { .name =3D "mem:0:rw", .check =3D test__checkevent_breakpoint_rw, - .id =3D 26, + /* 6 */ }, { .name =3D "mem:0:rw:kp", .check =3D test__checkevent_breakpoint_rw_modifier, - .id =3D 27, + /* 7 */ }, { .name =3D "{instructions:k,cycles:upp}", .check =3D test__group1, - .id =3D 28, + /* 8 */ }, { .name =3D "{faults:k,cache-references}:u,cycles:k", .check =3D test__group2, - .id =3D 29, + /* 9 */ }, { .name =3D "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycle= s,1:3}:G,instructions:u", .check =3D test__group3, - .id =3D 30, + /* 0 */ }, { .name =3D "{cycles:u,instructions:kp}:p", .check =3D test__group4, - .id =3D 31, + /* 1 */ }, { .name =3D "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", .check =3D test__group5, - .id =3D 32, + /* 2 */ }, { .name =3D "*:*", .check =3D test__all_tracepoints, - .id =3D 33, + /* 3 */ }, { .name =3D "{cycles,cache-misses:G}:H", .check =3D test__group_gh1, - .id =3D 34, + /* 4 */ }, { .name =3D "{cycles,cache-misses:H}:G", .check =3D test__group_gh2, - .id =3D 35, + /* 5 */ }, { .name =3D "{cycles:G,cache-misses:H}:u", .check =3D test__group_gh3, - .id =3D 36, + /* 6 */ }, { .name =3D "{cycles:G,cache-misses:H}:uG", .check =3D test__group_gh4, - .id =3D 37, + /* 7 */ }, { .name =3D "{cycles,cache-misses,branch-misses}:S", .check =3D test__leader_sample1, - .id =3D 38, + /* 8 */ }, { .name =3D "{instructions,branch-misses}:Su", .check =3D test__leader_sample2, - .id =3D 39, + /* 9 */ }, { .name =3D "instructions:uDp", .check =3D test__checkevent_pinned_modifier, - .id =3D 40, + /* 0 */ }, { .name =3D "{cycles,cache-misses,branch-misses}:D", .check =3D test__pinned_group, - .id =3D 41, + /* 1 */ }, { .name =3D "mem:0/1", .check =3D test__checkevent_breakpoint_len, - .id =3D 42, + /* 2 */ }, { .name =3D "mem:0/2:w", .check =3D test__checkevent_breakpoint_len_w, - .id =3D 43, + /* 3 */ }, { .name =3D "mem:0/4:rw:u", .check =3D test__checkevent_breakpoint_len_rw_modifier, - .id =3D 44 + /* 4 */ }, #if defined(__s390x__) { .name =3D "kvm-s390:kvm_s390_create_vm", .check =3D test__checkevent_tracepoint, .valid =3D kvm_s390_create_vm_valid, - .id =3D 100, + /* 0 */ }, #endif { .name =3D "instructions:I", .check =3D test__checkevent_exclude_idle_modifier, - .id =3D 45, + /* 5 */ }, { .name =3D "instructions:kIG", .check =3D test__checkevent_exclude_idle_modifier_1, - .id =3D 46, + /* 6 */ }, { .name =3D "task-clock:P,cycles", .check =3D test__checkevent_precise_max_modifier, - .id =3D 47, + /* 7 */ }, { .name =3D "instructions/name=3Dinsn/", .check =3D test__checkevent_config_symbol, - .id =3D 48, + /* 8 */ }, { .name =3D "r1234/name=3Drawpmu/", .check =3D test__checkevent_config_raw, - .id =3D 49, + /* 9 */ }, { .name =3D "4:0x6530160/name=3Dnumpmu/", .check =3D test__checkevent_config_num, - .id =3D 50, + /* 0 */ }, { .name =3D "L1-dcache-misses/name=3Dcachepmu/", .check =3D test__checkevent_config_cache, - .id =3D 51, + /* 1 */ }, { .name =3D "intel_pt//u", .valid =3D test__intel_pt_valid, .check =3D test__intel_pt, - .id =3D 52, + /* 2 */ }, { .name =3D "cycles/name=3D'COMPLEX_CYCLES_NAME:orig=3Dcycles,desc=3Dchip= -clock-ticks'/Duk", .check =3D test__checkevent_complex_name, - .id =3D 53 + /* 3 */ }, { .name =3D "cycles//u", .check =3D test__sym_event_slash, - .id =3D 54, + /* 4 */ }, { .name =3D "cycles:k", .check =3D test__sym_event_dc, - .id =3D 55, + /* 5 */ }, { .name =3D "instructions:uep", .check =3D test__checkevent_exclusive_modifier, - .id =3D 56, + /* 6 */ }, { .name =3D "{cycles,cache-misses,branch-misses}:e", .check =3D test__exclusive_group, - .id =3D 57, + /* 7 */ }, }; =20 -static struct evlist_test test__events_pmu[] =3D { +static const struct evlist_test test__events_pmu[] =3D { { .name =3D "cpu/config=3D10,config1,config2=3D3,period=3D1000/u", .check =3D test__checkevent_pmu, - .id =3D 0, + /* 0 */ }, { .name =3D "cpu/config=3D1,name=3Dkrava/u,cpu/config=3D2/u", .check =3D test__checkevent_pmu_name, - .id =3D 1, + /* 1 */ }, { .name =3D "cpu/config=3D1,call-graph=3Dfp,time,period=3D100000/,cpu/con= fig=3D2,call-graph=3Dno,time=3D0,period=3D2000/", .check =3D test__checkevent_pmu_partial_time_callgraph, - .id =3D 2, + /* 2 */ }, { .name =3D "cpu/name=3D'COMPLEX_CYCLES_NAME:orig=3Dcycles,desc=3Dchip-cl= ock-ticks',period=3D0x1,event=3D0x2/ukp", .check =3D test__checkevent_complex_name, - .id =3D 3, + /* 3 */ }, { .name =3D "software/r1a/", .check =3D test__checkevent_raw_pmu, - .id =3D 4, + /* 4 */ }, { .name =3D "software/r0x1a/", .check =3D test__checkevent_raw_pmu, - .id =3D 4, + /* 5 */ }, }; =20 @@ -1990,55 +1988,55 @@ static const struct terms_test test__terms[] =3D { }, }; =20 -static struct evlist_test test__hybrid_events[] =3D { +static const struct evlist_test test__hybrid_events[] =3D { { .name =3D "cpu_core/cpu-cycles/", .check =3D test__hybrid_hw_event_with_pmu, - .id =3D 0, + /* 0 */ }, { .name =3D "{cpu_core/cpu-cycles/,cpu_core/instructions/}", .check =3D test__hybrid_hw_group_event, - .id =3D 1, + /* 1 */ }, { .name =3D "{cpu-clock,cpu_core/cpu-cycles/}", .check =3D test__hybrid_sw_hw_group_event, - .id =3D 2, + /* 2 */ }, { .name =3D "{cpu_core/cpu-cycles/,cpu-clock}", .check =3D test__hybrid_hw_sw_group_event, - .id =3D 3, + /* 3 */ }, { .name =3D "{cpu_core/cpu-cycles/k,cpu_core/instructions/u}", .check =3D test__hybrid_group_modifier1, - .id =3D 4, + /* 4 */ }, { .name =3D "r1a", .check =3D test__hybrid_raw1, - .id =3D 5, + /* 5 */ }, { .name =3D "cpu_core/r1a/", .check =3D test__hybrid_raw2, - .id =3D 6, + /* 6 */ }, { .name =3D "cpu_core/config=3D10,config1,config2=3D3,period=3D1000/u", .check =3D test__checkevent_pmu, - .id =3D 7, + /* 7 */ }, { .name =3D "cpu_core/LLC-loads/", .check =3D test__hybrid_cache_event, - .id =3D 8, + /* 8 */ }, }; =20 -static int test_event(struct evlist_test *e) +static int test_event(const struct evlist_test *e) { struct parse_events_error err; struct evlist *evlist; @@ -2093,15 +2091,14 @@ static int test_event_fake_pmu(const char *str) return ret; } =20 -static int test_events(struct evlist_test *events, unsigned cnt) +static int test_events(const struct evlist_test *events, int cnt) { int ret1, ret2 =3D 0; - unsigned i; =20 - for (i =3D 0; i < cnt; i++) { - struct evlist_test *e =3D &events[i]; + for (int i =3D 0; i < cnt; i++) { + const struct evlist_test *e =3D &events[i]; =20 - pr_debug("running test %d '%s'", e->id, e->name); + pr_debug("running test %d '%s'", i, e->name); ret1 =3D test_event(e); if (ret1) ret2 =3D ret1; @@ -2193,7 +2190,7 @@ static int test_pmu_events(void) } =20 while (!ret && (ent =3D readdir(dir))) { - struct evlist_test e =3D { .id =3D 0, }; + struct evlist_test e =3D { .name =3D NULL, }; char name[2 * NAME_MAX + 1 + 12 + 3]; =20 /* Names containing . are special and cannot be used directly */ @@ -2288,7 +2285,7 @@ static int test__checkevent_pmu_events_alias(struct e= vlist *evlist) =20 static int test_pmu_events_alias(char *event, char *alias) { - struct evlist_test e =3D { .id =3D 0, }; + struct evlist_test e =3D { .name =3D NULL, }; char name[2 * NAME_MAX + 20]; =20 snprintf(name, sizeof(name), "%s/event=3D1/,%s/event=3D1/", --=20 2.36.0.550.gb090851708-goog From nobody Sun May 10 09:54:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAABDC433EF for ; Wed, 18 May 2022 04:21:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229818AbiEREVL (ORCPT ); Wed, 18 May 2022 00:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229794AbiEREUv (ORCPT ); Wed, 18 May 2022 00:20:51 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAFF931348 for ; Tue, 17 May 2022 21:20:49 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id o7-20020a256b47000000b0064ddc3bea70so914457ybm.4 for ; Tue, 17 May 2022 21:20:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=F54usjAFz5vOzrdA7Nd+K5d7QeUNwuqGITpxppLDKa4=; b=odPp4kgnmwQQ4SnUxewUSNzh7Dh53hxIxND74XLjXNwxaMW6gbbyVeSe1iEVcTfhw/ gdRROBnW9p+t26XhT22/g841ITPy+0BPI8sfjEFukBAfzKrmBzm4PHFUgwyye5rtoMx4 IMnx9Is8HLb/QtX/TINqByoHEXUgM6cpj9NLOsrcq1pTPp65uEMRxRe5q35gP+7TyvAk x7L2R46t79gUKSANkJqswtei1kJot9yOb7JEt9fCF7Cb9bsOOkwFjUldR/z/m45c5mBV oz7uXJ3bhzc8lj1UxNuDsgAbuWVFSHirHYQYH03VLyrO/rXxRfUxvr/eUuFk//hqdktF OSIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=F54usjAFz5vOzrdA7Nd+K5d7QeUNwuqGITpxppLDKa4=; b=B2p8HQkxzJvmEWFwpCxL2F/UQFi4mOzooCA9CRV4mYgrBK5PxsdlYnL88AlCfNVuha gRyf+Wuh5MmTKSZA2MIkwgLFYcEHmOg1ifEUI/gRIz605GI/IKYd00U8AvheMjCzWM5+ +JVslDsy8ksULooLxssLBxwfVJDk5otzoKZAo9tQ6EgryoTbGqub7kOzcAS+cfJAW7qn Yg9vJJJAd74s8zsrWkYJxVRLOOJA8P1H4jSORKY5Z9iZAEROab2wdTEsLtFSPPoNgaBi fLKvtxuS7wDS6sddiNBdgGC2xTalHiz1eF41NfmJPnNW09FHu7vcmfnKM+TR4GjSJcq7 k8+g== X-Gm-Message-State: AOAM530LvLH/klyrXi0g2oIHKV8KiZ31pHh03Q41WmmQbZiIepSkNWUX Xm7u8pWWEQ17e9KEp+gO1A5pcZVHSqON X-Google-Smtp-Source: ABdhPJwQ53tXTg5XaTmNssXKWoqOg3S4q5z8eU/sC74qfnuNnYk4Faqsne7ja1QXmppCXBuoWCipFyFCZKZ2 X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:a5a1:af73:fe09:fd5]) (user=irogers job=sendgmr) by 2002:a25:9081:0:b0:64d:d424:a811 with SMTP id t1-20020a259081000000b0064dd424a811mr9891525ybl.298.1652847648872; Tue, 17 May 2022 21:20:48 -0700 (PDT) Date: Tue, 17 May 2022 21:20:26 -0700 In-Reply-To: <20220518042027.836799-1-irogers@google.com> Message-Id: <20220518042027.836799-8-irogers@google.com> Mime-Version: 1.0 References: <20220518042027.836799-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.550.gb090851708-goog Subject: [PATCH v2 7/8] perf test: Parse events break apart tests From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Riccardo Mancini , Sohaib Mohamed , Carsten Haitzler , Marco Elver , John Garry , Michael Petlan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Break multiple tests in the main test into individual test cases. Make better use of skip and add reasons. Skip also for parse event permission issues (detected by searching the error string). Rather than break out of tests on the first failure, keep going and logging to pr_debug. Signed-off-by: Ian Rogers --- tools/perf/tests/parse-events.c | 311 ++++++++++++++++++-------------- 1 file changed, 177 insertions(+), 134 deletions(-) diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-event= s.c index 0d65770bd686..459afdb256a1 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -56,7 +56,7 @@ static int test__checkevent_tracepoint(struct evlist *evl= ist) TEST_ASSERT_VAL("wrong sample_type", PERF_TP_SAMPLE_TYPE =3D=3D evsel->core.attr.sample_type); TEST_ASSERT_VAL("wrong sample_period", 1 =3D=3D evsel->core.attr.sample_p= eriod); - return 0; + return TEST_OK; } =20 static int test__checkevent_tracepoint_multi(struct evlist *evlist) @@ -74,7 +74,7 @@ static int test__checkevent_tracepoint_multi(struct evlis= t *evlist) TEST_ASSERT_VAL("wrong sample_period", 1 =3D=3D evsel->core.attr.sample_period); } - return 0; + return TEST_OK; } =20 static int test__checkevent_raw(struct evlist *evlist) @@ -84,7 +84,7 @@ static int test__checkevent_raw(struct evlist *evlist) TEST_ASSERT_VAL("wrong number of entries", 1 =3D=3D evlist->core.nr_entri= es); TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW =3D=3D evsel->core.attr.type); TEST_ASSERT_VAL("wrong config", 0x1a =3D=3D evsel->core.attr.config); - return 0; + return TEST_OK; } =20 static int test__checkevent_numeric(struct evlist *evlist) @@ -94,7 +94,7 @@ static int test__checkevent_numeric(struct evlist *evlist) TEST_ASSERT_VAL("wrong number of entries", 1 =3D=3D evlist->core.nr_entri= es); TEST_ASSERT_VAL("wrong type", 1 =3D=3D evsel->core.attr.type); TEST_ASSERT_VAL("wrong config", 1 =3D=3D evsel->core.attr.config); - return 0; + return TEST_OK; } =20 static int test__checkevent_symbolic_name(struct evlist *evlist) @@ -105,7 +105,7 @@ static int test__checkevent_symbolic_name(struct evlist= *evlist) TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE =3D=3D evsel->core.attr.= type); TEST_ASSERT_VAL("wrong config", PERF_COUNT_HW_INSTRUCTIONS =3D=3D evsel->core.attr.config); - return 0; + return TEST_OK; } =20 static int test__checkevent_symbolic_name_config(struct evlist *evlist) @@ -126,7 +126,7 @@ static int test__checkevent_symbolic_name_config(struct= evlist *evlist) 0 =3D=3D evsel->core.attr.config1); TEST_ASSERT_VAL("wrong config2", 1 =3D=3D evsel->core.attr.config2); - return 0; + return TEST_OK; } =20 static int test__checkevent_symbolic_alias(struct evlist *evlist) @@ -137,7 +137,7 @@ static int test__checkevent_symbolic_alias(struct evlis= t *evlist) TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE =3D=3D evsel->core.attr.= type); TEST_ASSERT_VAL("wrong config", PERF_COUNT_SW_PAGE_FAULTS =3D=3D evsel->core.attr.config); - return 0; + return TEST_OK; } =20 static int test__checkevent_genhw(struct evlist *evlist) @@ -147,7 +147,7 @@ static int test__checkevent_genhw(struct evlist *evlist) TEST_ASSERT_VAL("wrong number of entries", 1 =3D=3D evlist->core.nr_entri= es); TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE =3D=3D evsel->core.attr.= type); TEST_ASSERT_VAL("wrong config", (1 << 16) =3D=3D evsel->core.attr.config); - return 0; + return TEST_OK; } =20 static int test__checkevent_breakpoint(struct evlist *evlist) @@ -161,7 +161,7 @@ static int test__checkevent_breakpoint(struct evlist *e= vlist) evsel->core.attr.bp_type); TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 =3D=3D evsel->core.attr.bp_len); - return 0; + return TEST_OK; } =20 static int test__checkevent_breakpoint_x(struct evlist *evlist) @@ -174,7 +174,7 @@ static int test__checkevent_breakpoint_x(struct evlist = *evlist) TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_X =3D=3D evsel->core.attr.bp_type); TEST_ASSERT_VAL("wrong bp_len", sizeof(long) =3D=3D evsel->core.attr.bp_l= en); - return 0; + return TEST_OK; } =20 static int test__checkevent_breakpoint_r(struct evlist *evlist) @@ -189,7 +189,7 @@ static int test__checkevent_breakpoint_r(struct evlist = *evlist) HW_BREAKPOINT_R =3D=3D evsel->core.attr.bp_type); TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 =3D=3D evsel->core.attr.bp_len); - return 0; + return TEST_OK; } =20 static int test__checkevent_breakpoint_w(struct evlist *evlist) @@ -204,7 +204,7 @@ static int test__checkevent_breakpoint_w(struct evlist = *evlist) HW_BREAKPOINT_W =3D=3D evsel->core.attr.bp_type); TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 =3D=3D evsel->core.attr.bp_len); - return 0; + return TEST_OK; } =20 static int test__checkevent_breakpoint_rw(struct evlist *evlist) @@ -219,7 +219,7 @@ static int test__checkevent_breakpoint_rw(struct evlist= *evlist) (HW_BREAKPOINT_R|HW_BREAKPOINT_W) =3D=3D evsel->core.attr.bp_type); TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 =3D=3D evsel->core.attr.bp_len); - return 0; + return TEST_OK; } =20 static int test__checkevent_tracepoint_modifier(struct evlist *evlist) @@ -450,7 +450,7 @@ static int test__checkevent_pmu(struct evlist *evlist) */ TEST_ASSERT_VAL("wrong period", 0 =3D=3D evsel->core.attr.sample_peri= od); =20 - return 0; + return TEST_OK; } =20 static int test__checkevent_list(struct evlist *evlist) @@ -489,7 +489,7 @@ static int test__checkevent_list(struct evlist *evlist) TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); =20 - return 0; + return TEST_OK; } =20 static int test__checkevent_pmu_name(struct evlist *evlist) @@ -510,7 +510,7 @@ static int test__checkevent_pmu_name(struct evlist *evl= ist) TEST_ASSERT_VAL("wrong name", !strcmp(evsel__name(evsel), "cpu/config=3D2/u")); =20 - return 0; + return TEST_OK; } =20 static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evli= st) @@ -541,7 +541,7 @@ static int test__checkevent_pmu_partial_time_callgraph(= struct evlist *evlist) TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel)); TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->core.attr.samp= le_type)); =20 - return 0; + return TEST_OK; } =20 static int test__checkevent_pmu_events(struct evlist *evlist) @@ -559,7 +559,7 @@ static int test__checkevent_pmu_events(struct evlist *e= vlist) TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); =20 - return 0; + return TEST_OK; } =20 =20 @@ -591,7 +591,7 @@ static int test__checkevent_pmu_events_mix(struct evlis= t *evlist) TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.pinned); =20 - return 0; + return TEST_OK; } =20 static int test__checkterms_simple(struct list_head *terms) @@ -662,7 +662,7 @@ static int test__checkterms_simple(struct list_head *te= rms) term->type_val =3D=3D PARSE_EVENTS__TERM_TYPE_NUM); TEST_ASSERT_VAL("wrong val", term->val.num =3D=3D 0xead); TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config")); - return 0; + return TEST_OK; } =20 static int test__group1(struct evlist *evlist) @@ -704,7 +704,7 @@ static int test__group1(struct evlist *evlist) TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) =3D=3D 1); TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); =20 - return 0; + return TEST_OK; } =20 static int test__group2(struct evlist *evlist) @@ -759,7 +759,7 @@ static int test__group2(struct evlist *evlist) TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); =20 - return 0; + return TEST_OK; } =20 static int test__group3(struct evlist *evlist __maybe_unused) @@ -851,7 +851,7 @@ static int test__group3(struct evlist *evlist __maybe_u= nused) TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); =20 - return 0; + return TEST_OK; } =20 static int test__group4(struct evlist *evlist __maybe_unused) @@ -895,7 +895,7 @@ static int test__group4(struct evlist *evlist __maybe_u= nused) TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) =3D=3D 1); TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); =20 - return 0; + return TEST_OK; } =20 static int test__group5(struct evlist *evlist __maybe_unused) @@ -981,7 +981,7 @@ static int test__group5(struct evlist *evlist __maybe_u= nused) TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); =20 - return 0; + return TEST_OK; } =20 static int test__group_gh1(struct evlist *evlist) @@ -1021,7 +1021,7 @@ static int test__group_gh1(struct evlist *evlist) TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) =3D=3D 1); =20 - return 0; + return TEST_OK; } =20 static int test__group_gh2(struct evlist *evlist) @@ -1061,7 +1061,7 @@ static int test__group_gh2(struct evlist *evlist) TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) =3D=3D 1); =20 - return 0; + return TEST_OK; } =20 static int test__group_gh3(struct evlist *evlist) @@ -1101,7 +1101,7 @@ static int test__group_gh3(struct evlist *evlist) TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) =3D=3D 1); =20 - return 0; + return TEST_OK; } =20 static int test__group_gh4(struct evlist *evlist) @@ -1141,7 +1141,7 @@ static int test__group_gh4(struct evlist *evlist) TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) =3D=3D 1); =20 - return 0; + return TEST_OK; } =20 static int test__leader_sample1(struct evlist *evlist) @@ -1194,7 +1194,7 @@ static int test__leader_sample1(struct evlist *evlist) TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); =20 - return 0; + return TEST_OK; } =20 static int test__leader_sample2(struct evlist *evlist __maybe_unused) @@ -1233,7 +1233,7 @@ static int test__leader_sample2(struct evlist *evlist= __maybe_unused) TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); =20 - return 0; + return TEST_OK; } =20 static int test__checkevent_pinned_modifier(struct evlist *evlist) @@ -1277,7 +1277,7 @@ static int test__pinned_group(struct evlist *evlist) PERF_COUNT_HW_BRANCH_MISSES =3D=3D evsel->core.attr.config); TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); =20 - return 0; + return TEST_OK; } =20 static int test__checkevent_exclusive_modifier(struct evlist *evlist) @@ -1321,7 +1321,7 @@ static int test__exclusive_group(struct evlist *evlis= t) PERF_COUNT_HW_BRANCH_MISSES =3D=3D evsel->core.attr.config); TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); =20 - return 0; + return TEST_OK; } static int test__checkevent_breakpoint_len(struct evlist *evlist) { @@ -1335,7 +1335,7 @@ static int test__checkevent_breakpoint_len(struct evl= ist *evlist) TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 =3D=3D evsel->core.attr.bp_len); =20 - return 0; + return TEST_OK; } =20 static int test__checkevent_breakpoint_len_w(struct evlist *evlist) @@ -1350,7 +1350,7 @@ static int test__checkevent_breakpoint_len_w(struct e= vlist *evlist) TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 =3D=3D evsel->core.attr.bp_len); =20 - return 0; + return TEST_OK; } =20 static int @@ -1374,7 +1374,7 @@ static int test__checkevent_precise_max_modifier(stru= ct evlist *evlist) TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE =3D=3D evsel->core.attr.= type); TEST_ASSERT_VAL("wrong config", PERF_COUNT_SW_TASK_CLOCK =3D=3D evsel->core.attr.config); - return 0; + return TEST_OK; } =20 static int test__checkevent_config_symbol(struct evlist *evlist) @@ -1382,7 +1382,7 @@ static int test__checkevent_config_symbol(struct evli= st *evlist) struct evsel *evsel =3D evlist__first(evlist); =20 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "insn") =3D=3D = 0); - return 0; + return TEST_OK; } =20 static int test__checkevent_config_raw(struct evlist *evlist) @@ -1390,7 +1390,7 @@ static int test__checkevent_config_raw(struct evlist = *evlist) struct evsel *evsel =3D evlist__first(evlist); =20 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "rawpmu") =3D= =3D 0); - return 0; + return TEST_OK; } =20 static int test__checkevent_config_num(struct evlist *evlist) @@ -1398,7 +1398,7 @@ static int test__checkevent_config_num(struct evlist = *evlist) struct evsel *evsel =3D evlist__first(evlist); =20 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "numpmu") =3D= =3D 0); - return 0; + return TEST_OK; } =20 static int test__checkevent_config_cache(struct evlist *evlist) @@ -1406,7 +1406,7 @@ static int test__checkevent_config_cache(struct evlis= t *evlist) struct evsel *evsel =3D evlist__first(evlist); =20 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "cachepmu") =3D= =3D 0); - return 0; + return TEST_OK; } =20 static bool test__intel_pt_valid(void) @@ -1419,7 +1419,7 @@ static int test__intel_pt(struct evlist *evlist) struct evsel *evsel =3D evlist__first(evlist); =20 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "intel_pt//u") = =3D=3D 0); - return 0; + return TEST_OK; } =20 static int test__checkevent_complex_name(struct evlist *evlist) @@ -1427,7 +1427,7 @@ static int test__checkevent_complex_name(struct evlis= t *evlist) struct evsel *evsel =3D evlist__first(evlist); =20 TEST_ASSERT_VAL("wrong complex name parsing", strcmp(evsel->name, "COMPLE= X_CYCLES_NAME:orig=3Dcycles,desc=3Dchip-clock-ticks") =3D=3D 0); - return 0; + return TEST_OK; } =20 static int test__checkevent_raw_pmu(struct evlist *evlist) @@ -1437,7 +1437,7 @@ static int test__checkevent_raw_pmu(struct evlist *ev= list) TEST_ASSERT_VAL("wrong number of entries", 1 =3D=3D evlist->core.nr_entri= es); TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE =3D=3D evsel->core.attr.= type); TEST_ASSERT_VAL("wrong config", 0x1a =3D=3D evsel->core.attr.config); - return 0; + return TEST_OK; } =20 static int test__sym_event_slash(struct evlist *evlist) @@ -1447,7 +1447,7 @@ static int test__sym_event_slash(struct evlist *evlis= t) TEST_ASSERT_VAL("wrong type", evsel->core.attr.type =3D=3D PERF_TYPE_HARD= WARE); TEST_ASSERT_VAL("wrong config", evsel->core.attr.config =3D=3D PERF_COUNT= _HW_CPU_CYCLES); TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); - return 0; + return TEST_OK; } =20 static int test__sym_event_dc(struct evlist *evlist) @@ -1457,7 +1457,7 @@ static int test__sym_event_dc(struct evlist *evlist) TEST_ASSERT_VAL("wrong type", evsel->core.attr.type =3D=3D PERF_TYPE_HARD= WARE); TEST_ASSERT_VAL("wrong config", evsel->core.attr.config =3D=3D PERF_COUNT= _HW_CPU_CYCLES); TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); - return 0; + return TEST_OK; } =20 static int count_tracepoints(void) @@ -1521,7 +1521,7 @@ static int test__hybrid_hw_event_with_pmu(struct evli= st *evlist) TEST_ASSERT_VAL("wrong number of entries", 1 =3D=3D evlist->core.nr_entri= es); TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW =3D=3D evsel->core.attr.type); TEST_ASSERT_VAL("wrong config", 0x3c =3D=3D evsel->core.attr.config); - return 0; + return TEST_OK; } =20 static int test__hybrid_hw_group_event(struct evlist *evlist) @@ -1538,7 +1538,7 @@ static int test__hybrid_hw_group_event(struct evlist = *evlist) TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW =3D=3D evsel->core.attr.type); TEST_ASSERT_VAL("wrong config", 0xc0 =3D=3D evsel->core.attr.config); TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); - return 0; + return TEST_OK; } =20 static int test__hybrid_sw_hw_group_event(struct evlist *evlist) @@ -1554,7 +1554,7 @@ static int test__hybrid_sw_hw_group_event(struct evli= st *evlist) TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW =3D=3D evsel->core.attr.type); TEST_ASSERT_VAL("wrong config", 0x3c =3D=3D evsel->core.attr.config); TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); - return 0; + return TEST_OK; } =20 static int test__hybrid_hw_sw_group_event(struct evlist *evlist) @@ -1570,7 +1570,7 @@ static int test__hybrid_hw_sw_group_event(struct evli= st *evlist) evsel =3D evsel__next(evsel); TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE =3D=3D evsel->core.attr.= type); TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); - return 0; + return TEST_OK; } =20 static int test__hybrid_group_modifier1(struct evlist *evlist) @@ -1591,7 +1591,7 @@ static int test__hybrid_group_modifier1(struct evlist= *evlist) TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); - return 0; + return TEST_OK; } =20 static int test__hybrid_raw1(struct evlist *evlist) @@ -1602,7 +1602,7 @@ static int test__hybrid_raw1(struct evlist *evlist) TEST_ASSERT_VAL("wrong number of entries", 1 =3D=3D evlist->core.nr_entr= ies); TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW =3D=3D evsel->core.attr.type= ); TEST_ASSERT_VAL("wrong config", 0x1a =3D=3D evsel->core.attr.config); - return 0; + return TEST_OK; } =20 TEST_ASSERT_VAL("wrong number of entries", 2 =3D=3D evlist->core.nr_entri= es); @@ -1612,7 +1612,7 @@ static int test__hybrid_raw1(struct evlist *evlist) /* The type of second event is randome value */ evsel =3D evsel__next(evsel); TEST_ASSERT_VAL("wrong config", 0x1a =3D=3D evsel->core.attr.config); - return 0; + return TEST_OK; } =20 static int test__hybrid_raw2(struct evlist *evlist) @@ -1622,7 +1622,7 @@ static int test__hybrid_raw2(struct evlist *evlist) TEST_ASSERT_VAL("wrong number of entries", 1 =3D=3D evlist->core.nr_entri= es); TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW =3D=3D evsel->core.attr.type); TEST_ASSERT_VAL("wrong config", 0x1a =3D=3D evsel->core.attr.config); - return 0; + return TEST_OK; } =20 static int test__hybrid_cache_event(struct evlist *evlist) @@ -1632,7 +1632,7 @@ static int test__hybrid_cache_event(struct evlist *ev= list) TEST_ASSERT_VAL("wrong number of entries", 1 =3D=3D evlist->core.nr_entri= es); TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE =3D=3D evsel->core.attr.= type); TEST_ASSERT_VAL("wrong config", 0x2 =3D=3D (evsel->core.attr.config & 0xf= fffffff)); - return 0; + return TEST_OK; } =20 struct evlist_test { @@ -2043,20 +2043,24 @@ static int test_event(const struct evlist_test *e) int ret; =20 if (e->valid && !e->valid()) { - pr_debug("... SKIP"); - return 0; + pr_debug("... SKIP\n"); + return TEST_OK; } =20 evlist =3D evlist__new(); - if (evlist =3D=3D NULL) - return -ENOMEM; - + if (evlist =3D=3D NULL) { + pr_err("Failed allocation"); + return TEST_FAIL; + } parse_events_error__init(&err); ret =3D parse_events(evlist, e->name, &err); if (ret) { pr_debug("failed to parse event '%s', err %d, str '%s'\n", e->name, ret, err.str); parse_events_error__print(&err, e->name); + ret =3D TEST_FAIL; + if (strstr(err.str, "can't access trace events")) + ret =3D TEST_SKIP; } else { ret =3D e->check(evlist); } @@ -2091,21 +2095,37 @@ static int test_event_fake_pmu(const char *str) return ret; } =20 +static int combine_test_results(int existing, int latest) +{ + if (existing =3D=3D TEST_FAIL) + return TEST_FAIL; + if (existing =3D=3D TEST_SKIP) + return latest =3D=3D TEST_OK ? TEST_SKIP : latest; + return latest; +} + static int test_events(const struct evlist_test *events, int cnt) { - int ret1, ret2 =3D 0; + int ret =3D TEST_OK; =20 for (int i =3D 0; i < cnt; i++) { const struct evlist_test *e =3D &events[i]; + int test_ret; =20 - pr_debug("running test %d '%s'", i, e->name); - ret1 =3D test_event(e); - if (ret1) - ret2 =3D ret1; - pr_debug("\n"); + pr_debug("running test %d '%s'\n", i, e->name); + test_ret =3D test_event(e); + if (test_ret !=3D TEST_OK) { + pr_debug("Event test failure: test %d '%s'", i, e->name); + ret =3D combine_test_results(ret, test_ret); + } } =20 - return ret2; + return ret; +} + +static int test__events2(struct test_suite *test __maybe_unused, int subte= st __maybe_unused) +{ + return test_events(test__events, ARRAY_SIZE(test__events)); } =20 static int test_term(const struct terms_test *t) @@ -2151,6 +2171,11 @@ static int test_terms(const struct terms_test *terms= , int cnt) return ret; } =20 +static int test__terms2(struct test_suite *test __maybe_unused, int subtes= t __maybe_unused) +{ + return test_terms(test__terms, ARRAY_SIZE(test__terms)); +} + static int test_pmu(void) { struct stat st; @@ -2166,7 +2191,7 @@ static int test_pmu(void) return !ret; } =20 -static int test_pmu_events(void) +static int test__pmu_events(struct test_suite *test __maybe_unused, int su= btest __maybe_unused) { struct stat st; char path[PATH_MAX]; @@ -2174,24 +2199,29 @@ static int test_pmu_events(void) DIR *dir; int ret; =20 + if (!test_pmu()) + return TEST_SKIP; + snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", sysfs__mountpoint()); =20 ret =3D stat(path, &st); if (ret) { - pr_debug("omitting PMU cpu events tests\n"); - return 0; + pr_debug("omitting PMU cpu events tests: %s\n", path); + return TEST_OK; } =20 dir =3D opendir(path); if (!dir) { - pr_debug("can't open pmu event dir"); - return -1; + pr_debug("can't open pmu event dir: %s\n", path); + return TEST_FAIL; } =20 - while (!ret && (ent =3D readdir(dir))) { + ret =3D TEST_OK; + while ((ent =3D readdir(dir))) { struct evlist_test e =3D { .name =3D NULL, }; char name[2 * NAME_MAX + 1 + 12 + 3]; + int test_ret; =20 /* Names containing . are special and cannot be used directly */ if (strchr(ent->d_name, '.')) @@ -2202,19 +2232,33 @@ static int test_pmu_events(void) e.name =3D name; e.check =3D test__checkevent_pmu_events; =20 - ret =3D test_event(&e); - if (ret) - break; + test_ret =3D test_event(&e); + if (test_ret !=3D TEST_OK) { + pr_debug("Test PMU event failed for '%s'", name); + ret =3D combine_test_results(ret, test_ret); + } snprintf(name, sizeof(name), "%s:u,cpu/event=3D%s/u", ent->d_name, ent->= d_name); e.name =3D name; e.check =3D test__checkevent_pmu_events_mix; - ret =3D test_event(&e); + test_ret =3D test_event(&e); + if (test_ret !=3D TEST_OK) { + pr_debug("Test PMU event failed for '%s'", name); + ret =3D combine_test_results(ret, test_ret); + } } =20 closedir(dir); return ret; } =20 +static int test__pmu_events2(struct test_suite *test __maybe_unused, int s= ubtest __maybe_unused) +{ + if (!test_pmu()) + return TEST_SKIP; + + return test_events(test__events_pmu, ARRAY_SIZE(test__events_pmu)); +} + static bool test_alias(char **event, char **alias) { char path[PATH_MAX]; @@ -2273,6 +2317,14 @@ static bool test_alias(char **event, char **alias) return false; } =20 +static int test__hybrid(struct test_suite *test __maybe_unused, int subtes= t __maybe_unused) +{ + if (!perf_pmu__has_hybrid()) + return TEST_SKIP; + + return test_events(test__hybrid_events, ARRAY_SIZE(test__hybrid_events)); +} + static int test__checkevent_pmu_events_alias(struct evlist *evlist) { struct evsel *evsel1 =3D evlist__first(evlist); @@ -2280,10 +2332,10 @@ static int test__checkevent_pmu_events_alias(struct= evlist *evlist) =20 TEST_ASSERT_VAL("wrong type", evsel1->core.attr.type =3D=3D evsel2->core.= attr.type); TEST_ASSERT_VAL("wrong config", evsel1->core.attr.config =3D=3D evsel2->c= ore.attr.config); - return 0; + return TEST_OK; } =20 -static int test_pmu_events_alias(char *event, char *alias) +static int test__pmu_events_alias(char *event, char *alias) { struct evlist_test e =3D { .name =3D NULL, }; char name[2 * NAME_MAX + 20]; @@ -2296,72 +2348,63 @@ static int test_pmu_events_alias(char *event, char = *alias) return test_event(&e); } =20 -static int test_pmu_events_alias2(void) +static int test__alias(struct test_suite *test __maybe_unused, int subtest= __maybe_unused) { - static const char events[][30] =3D { - "event-hyphen", - "event-two-hyph", - }; - unsigned long i; - int ret =3D 0; + char *event, *alias; + int ret; =20 - for (i =3D 0; i < ARRAY_SIZE(events); i++) { - ret =3D test_event_fake_pmu(&events[i][0]); - if (ret) { - pr_err("check_parse_fake %s failed\n", &events[i][0]); - break; - } - } + if (!test_alias(&event, &alias)) + return TEST_SKIP; =20 + ret =3D test__pmu_events_alias(event, alias); + + free(event); + free(alias); return ret; } =20 -static int test__parse_events(struct test_suite *test __maybe_unused, int = subtest __maybe_unused) +static int test__pmu_events_alias2(struct test_suite *test __maybe_unused, + int subtest __maybe_unused) { - int ret1, ret2 =3D 0; - char *event, *alias; - -#define TEST_EVENTS(tests) \ -do { \ - ret1 =3D test_events(tests, ARRAY_SIZE(tests)); \ - if (!ret2) \ - ret2 =3D ret1; \ -} while (0) - - if (perf_pmu__has_hybrid()) { - TEST_EVENTS(test__hybrid_events); - return ret2; - } - - TEST_EVENTS(test__events); - - if (test_pmu()) - TEST_EVENTS(test__events_pmu); - - if (test_pmu()) { - int ret =3D test_pmu_events(); - if (ret) - return ret; - } + static const char events[][30] =3D { + "event-hyphen", + "event-two-hyph", + }; + int ret =3D TEST_OK; =20 - if (test_alias(&event, &alias)) { - int ret =3D test_pmu_events_alias(event, alias); + for (unsigned int i =3D 0; i < ARRAY_SIZE(events); i++) { + int test_ret =3D test_event_fake_pmu(&events[i][0]); =20 - free(event); - free(alias); - if (ret) - return ret; + if (test_ret !=3D TEST_OK) { + pr_debug("check_parse_fake %s failed\n", &events[i][0]); + ret =3D combine_test_results(ret, test_ret); + } } =20 - ret1 =3D test_pmu_events_alias2(); - if (!ret2) - ret2 =3D ret1; - - ret1 =3D test_terms(test__terms, ARRAY_SIZE(test__terms)); - if (!ret2) - ret2 =3D ret1; - - return ret2; + return ret; } =20 -DEFINE_SUITE("Parse event definition strings", parse_events); +static struct test_case tests__parse_events[] =3D { + TEST_CASE_REASON("Test event parsing", + events2, + "permissions"), + TEST_CASE_REASON("Test parsing of \"hybrid\" CPU events", + hybrid, + "not hybrid"), + TEST_CASE_REASON("Parsing of all PMU events from sysfs", + pmu_events, + "permissions"), + TEST_CASE_REASON("Parsing of given PMU events from sysfs", + pmu_events2, + "permissions"), + TEST_CASE_REASON("Parsing of aliased events from sysfs", alias, + "no aliases in sysfs"), + TEST_CASE("Parsing of aliased events", pmu_events_alias2), + TEST_CASE("Parsing of terms (event modifiers)", terms2), + { .name =3D NULL, } +}; + +struct test_suite suite__parse_events =3D { + .desc =3D "Parse event definition strings", + .test_cases =3D tests__parse_events, +}; --=20 2.36.0.550.gb090851708-goog From nobody Sun May 10 09:54:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DC3CC433F5 for ; Wed, 18 May 2022 04:21:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229828AbiEREVQ (ORCPT ); Wed, 18 May 2022 00:21:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbiEREUx (ORCPT ); Wed, 18 May 2022 00:20:53 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36450220D1 for ; Tue, 17 May 2022 21:20:52 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2d7eaa730d9so10319057b3.13 for ; Tue, 17 May 2022 21:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ulc7jVR4esIc7uAea3k2kp75KCKMXlF4y2JGNUw/UGw=; b=bxid9/puL5bhxOXx2DTa8x8S1jgQCq5ay8qtP8LgiP6EyAB9Jn/k76q9uY+42eXvyT 7ZP0zMdq/j1OnIk//ijsmuz6SH1sN4KDPXScFDLgtlLjwqHonUI8XOUEn1HfFSbhdfJr BjWr6JBk+5YusFdxIF/xgJuhHNA8LdL+WFERkJbck2kMhpFWX3H93AAVl1RDqGxoEpIO cxU53lF8O8g4Rl+CbZ1W9tMvTGBkhD426abmXzh7kl24a+/5D1A2EYPmhd0wvIrSAgyL MITt5pQLPyDvsOgutXaR4QDTMIpr8URZnJ1svgVo/dYHBbohIpIzEv6wr8cZiRWiZy73 2fcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ulc7jVR4esIc7uAea3k2kp75KCKMXlF4y2JGNUw/UGw=; b=ew1zT+iCs95UhrgN4Rzc4dQKauWoaZ6taQIobtFKJt0rA7TaHSistW0iEp0l4Vw+TN FdFFB+yLRg+W4/wgCZ0kvDkA4ILQEJksWsLwP5h5GHC2SzdHhF+Ou+7Ew6owghYDyoSz MbU491zTeOevtz/S3SYtS4IYDpGn9/jkWTQUpfgA8VNPRuvqyW8hOFN93vQCtgiivxIV PbCMqN9Yv+ujGMfd/ujsmViy60F4wzLyEyEn3UJc1WCpt+FUzjx4DH/Bn07yO5EJ8XQw HlAIRezzUro2N+AFL2VMMz1Ipezh9xzfv54YYfbUaf4v1Adwyce8ULZUK/GNICXZOu/9 8y+w== X-Gm-Message-State: AOAM533t6fqWWOn7nKmQmg/OiHVlQNQERZ4bF6z08GPnqdasM1S83dh4 +rncbEiqULhB199C1NsbW0aTSs93x4kD X-Google-Smtp-Source: ABdhPJyi/kenzf5f6IvXdgmpjEuRxks7EA7p2I2jEiPI1ZIU8yY0XO2JOXI4l5qnLfdLCvciyP4mtpcve1ex X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:a5a1:af73:fe09:fd5]) (user=irogers job=sendgmr) by 2002:a25:230f:0:b0:64d:76e2:6aa5 with SMTP id j15-20020a25230f000000b0064d76e26aa5mr16689099ybj.116.1652847651210; Tue, 17 May 2022 21:20:51 -0700 (PDT) Date: Tue, 17 May 2022 21:20:27 -0700 In-Reply-To: <20220518042027.836799-1-irogers@google.com> Message-Id: <20220518042027.836799-9-irogers@google.com> Mime-Version: 1.0 References: <20220518042027.836799-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.550.gb090851708-goog Subject: [PATCH v2 8/8] perf test: Use skip in PERF_RECORD_* From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Riccardo Mancini , Sohaib Mohamed , Carsten Haitzler , Marco Elver , John Garry , Michael Petlan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check if the error code is EACCES and make the test a skip with a "permissions" skip reason if so. Signed-off-by: Ian Rogers --- tools/perf/tests/perf-record.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index 6354465067b8..6a001fcfed68 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c @@ -330,7 +330,21 @@ static int test__PERF_RECORD(struct test_suite *test _= _maybe_unused, int subtest out_delete_evlist: evlist__delete(evlist); out: - return (err < 0 || errs > 0) ? -1 : 0; + if (err =3D=3D -EACCES) + return TEST_SKIP; + if (err < 0) + return TEST_FAIL; + return TEST_OK; } =20 -DEFINE_SUITE("PERF_RECORD_* events & perf_sample fields", PERF_RECORD); +static struct test_case tests__PERF_RECORD[] =3D { + TEST_CASE_REASON("PERF_RECORD_* events & perf_sample fields", + PERF_RECORD, + "permissions"), + { .name =3D NULL, } +}; + +struct test_suite suite__PERF_RECORD =3D { + .desc =3D "PERF_RECORD_* events & perf_sample fields", + .test_cases =3D tests__PERF_RECORD, +}; --=20 2.36.0.550.gb090851708-goog