Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5881631ybi; Sun, 21 Jul 2019 04:35:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXY7t/Kzy63JbLrnPTyyBRjPLu7ExZXoX3ow8dKIiGMexb2C1EMkfIjc5lQTDhm8fz8tA2 X-Received: by 2002:a63:394:: with SMTP id 142mr66348605pgd.43.1563708937561; Sun, 21 Jul 2019 04:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563708937; cv=none; d=google.com; s=arc-20160816; b=ZQFoEWWwgcN79kyimlqNoaOmuDTP49NnZwMDtVdKcwsW/EB0uMeTD9RxeTdtFJ10aX ss1q04MUBw7n7FVbI0C2jEqR/JTDddMvp5pN6nZbZJA/h20zfKndRBDRxBkw3xN6rf1W IgejunGf9nUG7y+sGrJkpNM/1mQLCSEwGU46YzEXQnLMnoh4bh5rmcgAgbHpqz/NZbNw /+ss72m8IuTozFwJFpj03sdYrv0zhhEjQWoyV7z+xhEulh1aVA/dosNPjWiriFTZAYkn MIUHLjI4XN44Bc6k35a9WmWkXC/SfvnKPyBwicdcVysdptzvpfUxqOKKd0hs7qr5F9Id PAIg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=aEnSgfAjFXeW5r85JBlszi08v3Dz2W2QRO6W1bl5oRo=; b=CxxDe77b2ukCiwaWKBjrTX9W9NDWcGLXnQ9qltA05xnwyvEdq5lEpDF6yI+01ddU/2 4zQqDWngv9SMP5xp5RK0hTRSo0dV49/i0+f7qHIs/u1GgAy/k81nb4ToeFwQSW3c3/UK XBl1GYh89LM+mQuDwpnDBNxRpU5xVabbR0rwTnofeuEX9rfx5OzsUGiPUyxPryLfX1re ZAtYTWJa9vUe3GbcOFi6cjant4I1XMarrdcSukHHeO7zB0UrJxMO1smdZ0VLDCUie8ta mKUUo1fzPko+VK0Zy/Zve9J1uO9Sc4T0KseQ74f+FDl2B0ZvzfFx1dvVjuSlN9JRff0W qgJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i18si7184794pfa.23.2019.07.21.04.35.22; Sun, 21 Jul 2019 04:35:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727559AbfGULdJ (ORCPT + 99 others); Sun, 21 Jul 2019 07:33:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43282 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726390AbfGULdJ (ORCPT ); Sun, 21 Jul 2019 07:33:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 07180C18B2C6; Sun, 21 Jul 2019 11:33:09 +0000 (UTC) Received: from krava.redhat.com (ovpn-204-23.brq.redhat.com [10.40.204.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE04C5D9D3; Sun, 21 Jul 2019 11:33:04 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Andi Kleen , Alexey Budankov , Michael Petlan Subject: [PATCH 78/79] libperf: Add perf_evsel__enable/disable test Date: Sun, 21 Jul 2019 13:25:05 +0200 Message-Id: <20190721112506.12306-79-jolsa@kernel.org> In-Reply-To: <20190721112506.12306-1-jolsa@kernel.org> References: <20190721112506.12306-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 21 Jul 2019 11:33:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add simple perf_evsel enable/disable test together with evsel counter reading interface. Link: http://lkml.kernel.org/n/tip-fsqjctyzhrzw5e085h3bvvhi@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/lib/tests/test-evsel.c | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tools/perf/lib/tests/test-evsel.c b/tools/perf/lib/tests/test-evsel.c index 268712292f60..2c648fe5617e 100644 --- a/tools/perf/lib/tests/test-evsel.c +++ b/tools/perf/lib/tests/test-evsel.c @@ -70,12 +70,55 @@ static int test_stat_thread(void) return 0; } +static int test_stat_thread_enable(void) +{ + struct perf_counts_values counts = { .val = 0 }; + struct perf_thread_map *threads; + struct perf_evsel *evsel; + struct perf_event_attr attr = { + .type = PERF_TYPE_SOFTWARE, + .config = PERF_COUNT_SW_TASK_CLOCK, + .disabled = 1, + }; + int err; + + threads = perf_thread_map__new_dummy(); + __T("failed to create threads", threads); + + perf_thread_map__set_pid(threads, 0, 0); + + evsel = perf_evsel__new(&attr); + __T("failed to create evsel", evsel); + + err = perf_evsel__open(evsel, NULL, threads); + __T("failed to open evsel", err == 0); + + perf_evsel__read(evsel, 0, 0, &counts); + __T("failed to read value for evsel", counts.val == 0); + + err = perf_evsel__enable(evsel); + __T("failed to enable evsel", err == 0); + + perf_evsel__read(evsel, 0, 0, &counts); + __T("failed to read value for evsel", counts.val != 0); + + err = perf_evsel__disable(evsel); + __T("failed to enable evsel", err == 0); + + perf_evsel__close(evsel); + perf_evsel__delete(evsel); + + perf_thread_map__put(threads); + return 0; +} + int main(int argc, char **argv) { __T_START; test_stat_cpu(); test_stat_thread(); + test_stat_thread_enable(); __T_OK; return 0; -- 2.21.0