From patchwork Tue Aug 31 12:53:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12467155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95842C432BE for ; Tue, 31 Aug 2021 12:54:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75B116103D for ; Tue, 31 Aug 2021 12:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230466AbhHaMzH (ORCPT ); Tue, 31 Aug 2021 08:55:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbhHaMzG (ORCPT ); Tue, 31 Aug 2021 08:55:06 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DD54C061575 for ; Tue, 31 Aug 2021 05:54:11 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a25so38434455ejv.6 for ; Tue, 31 Aug 2021 05:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=h/VSd1nH2U2Cl4ryJMRlfcYTXhgdbJH9ossr08otlLk=; b=hqWPQ4Z1hAZQW9YMWk0Y29SWv+EGE92Ndsk3Ssbwm8Nja7p4HMBZ0wPdEmEq1+rV/F ykMECIuLMLPETNKvd9LNV7PRB+5+bLwwyM4AJENsacVMZhHpeY30n15zYShijYkkqwDX Yh9hHOYmqnm1QjjZbhikE1dbyZsM6l0oiSv12UqKyT6CI+5JKZfuk5VugiY7VAP70tZG Dv+lZg2YSX+3hj7mRkYVeqk0jwFputSG1z/smw4DHUAylrR6xf1dKPuSHm515wdcoq87 6O0WTgdNUP9GbM/XQMBKEuXzd9Ayc2oDFtuTM/uAXcex08++VKz3qhj+JBCQphKg5n83 5+DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=h/VSd1nH2U2Cl4ryJMRlfcYTXhgdbJH9ossr08otlLk=; b=T5ohtJHFZTuxyhaRkRE9/RTWUO5Z1GW18r/x4lITv2PAR7+LILdPafV2v11Azdv93E jnTsJFgS1eC1kxlheEz+2K6zFnhJ3MVAVufwswBuU6Ry9eNMybhgydPjS/pZbQ/5fOXJ oqym9vFCYevs+0UFFXzxYhGVriUl2ccvGb/Vetb8CKZkZ/6MMbn8i2t1+zKW3foXQJaE Fx0UMh/jHbAfxjLW3TlN2uBb7YTcddarvmWtNFMmNL9U2owQJYOKvZcPdt837ENJyihc SRLAv1vIjeVSEXQyQzUtJWCx8zWQo906DVoDpAKU75RKhvRBeRC//J6zRfGXwUONd5We Yn1Q== X-Gm-Message-State: AOAM532lefzKFLbR7jvPCmy+OlN1UG+TQt0bs6y0vsn6At0m03nO5cVs VkyeWDOz20zqm0OhjGQsTCefx0ib/uc= X-Google-Smtp-Source: ABdhPJycEZXEYJBUE7qz5/oH6TzxX/cujxN71BIscUqahkz+NVAxAjjDDTgOk6xA2rhwCxL8zqdAkg== X-Received: by 2002:a17:906:2441:: with SMTP id a1mr31231728ejb.550.1630414449655; Tue, 31 Aug 2021 05:54:09 -0700 (PDT) Received: from crow.. ([95.87.199.93]) by smtp.gmail.com with ESMTPSA id be5sm9346976edb.57.2021.08.31.05.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 05:54:09 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: linux-trace-devel@vger.kernel.org Cc: "Yordan Karadzhov (VMware)" Subject: [PATCH 1/4] trace-cruncher: Add optional sort to tfs_list2py_list() Date: Tue, 31 Aug 2021 15:53:54 +0300 Message-Id: <20210831125357.56862-1-y.karadz@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org This helper function is used to convert the NULL-terminated array of strings returned by the APIs of libtracefs into a Python list of strings. Here we add an option the returned string to be sorted in alphabetical order. Signed-off-by: Yordan Karadzhov (VMware) --- src/ftracepy-utils.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c index 53fc95f..0fcadd8 100644 --- a/src/ftracepy-utils.c +++ b/src/ftracepy-utils.c @@ -475,7 +475,7 @@ static bool write_to_file_and_check(struct tracefs_instance *instance, return ret == 0 ? true : false; } -static PyObject *tfs_list2py_list(char **list) +static PyObject *tfs_list2py_list(char **list, bool sort) { PyObject *py_list = PyList_New(0); int i; @@ -483,6 +483,9 @@ static PyObject *tfs_list2py_list(char **list) for (i = 0; list && list[i]; i++) PyList_Append(py_list, PyUnicode_FromString(list[i])); + if (sort) + PyList_Sort(py_list); + tracefs_list_free(list); return py_list; @@ -636,7 +639,7 @@ PyObject *PyFtrace_available_tracers(PyObject *self, PyObject *args, if (!list) return NULL; - return tfs_list2py_list(list); + return tfs_list2py_list(list, false); } PyObject *PyFtrace_set_current_tracer(PyObject *self, PyObject *args, @@ -724,7 +727,7 @@ PyObject *PyFtrace_available_event_systems(PyObject *self, PyObject *args, if (!list) return NULL; - return tfs_list2py_list(list); + return tfs_list2py_list(list, false); } PyObject *PyFtrace_available_system_events(PyObject *self, PyObject *args, @@ -750,10 +753,11 @@ PyObject *PyFtrace_available_system_events(PyObject *self, PyObject *args, list = tracefs_system_events(tracefs_instance_get_dir(instance), system); + if (!list) return NULL; - return tfs_list2py_list(list); + return tfs_list2py_list(list, false); } bool get_event_enable_file(struct tracefs_instance *instance, From patchwork Tue Aug 31 12:53:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12467157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAE6EC4320A for ; Tue, 31 Aug 2021 12:54:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A886360FC0 for ; Tue, 31 Aug 2021 12:54:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230175AbhHaMzH (ORCPT ); Tue, 31 Aug 2021 08:55:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbhHaMzH (ORCPT ); Tue, 31 Aug 2021 08:55:07 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A0C7C061575 for ; Tue, 31 Aug 2021 05:54:12 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id x11so38589861ejv.0 for ; Tue, 31 Aug 2021 05:54:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0wkIf+NaX+AdnH7XiJUXOr4HCirVQw2nQxwwFX+IM7c=; b=rtkTEC7bGm5D4iYU3zqiGptIb2G8Uvd7/TJXc2QJtCDUcJCLLZNG+tMhU6LmPT1sWu MYY+pEtASBJs0u5KC7GeAE4y9W+G8eEBFhFLSmKIrSQOJq6x/ltTqELgh5y4eujwkHAR DGZSJHBapODgrxFyh/q/ksw7SuJn5c5Cj7thanD6Nu1DDP5Pm+ilP78DyhQEidU+Vbb9 wTlsMTzdyjdYs64Ue9Lr3o9Lx3fS2Uf8NDgcI+qhT8MoHVxCxFI2Z43wnjoY+S1Tl7BF aTYRrMF/U3IEiEn7oE3ELa85bdyCs63A2t5gPul+6bV49vdGD1jvzL4yY6tloln34BAf l9hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0wkIf+NaX+AdnH7XiJUXOr4HCirVQw2nQxwwFX+IM7c=; b=XKbIPtSkz4hkptyEVyBnUXbAo/2xyFTPJgSb8DsuQKa8OtIGPLSl3HRJfmHzBzGUgZ K3UsEZ14bDhgYKS9LgXFfqfzvgowECIIHE6wibmHFzo7xqVOKe14EOiqMtoffggYvLz5 0q+qVMbIL6GZJavFMAPNWB1mmwzXhxzTki07gpfyR+zd5nutmie+XAU2UXX9HoETEtUe rpbi4HexfdkaNPG5iD5eywdKRd5Pp6MClBCzcDq4E6NEBip1y+6tEpWKX9jA8qFnbiNY n++9wwho3+dyIYm1e9rLBrddUqC+tMeMbklNwCgax52LUlLfx/NezaRWzBVE1tBTghGf eRlw== X-Gm-Message-State: AOAM531l2dbINXmRZV+BmOr1kfKjd6FKvMPGTuupD/6DAuweoHJq1RHT 12Y8sPlniPboJlvlb7E4C4/A4ebJXmo= X-Google-Smtp-Source: ABdhPJxJQTGC0w1kVatibhuieRLMYYNCaSBvfOfuxWwSi+FZLi8yVX0HTQXGrY33h7aXB8zkRDKPMQ== X-Received: by 2002:a17:907:7844:: with SMTP id lb4mr19275799ejc.381.1630414450534; Tue, 31 Aug 2021 05:54:10 -0700 (PDT) Received: from crow.. ([95.87.199.93]) by smtp.gmail.com with ESMTPSA id be5sm9346976edb.57.2021.08.31.05.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 05:54:10 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: linux-trace-devel@vger.kernel.org Cc: "Yordan Karadzhov (VMware)" Subject: [PATCH 2/4] trace-cruncher: Add optional sort to available_system_events() Date: Tue, 31 Aug 2021 15:53:55 +0300 Message-Id: <20210831125357.56862-2-y.karadz@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210831125357.56862-1-y.karadz@gmail.com> References: <20210831125357.56862-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org An optional parameter 'sort' is added. If set to True, the returned list of event names is sorted in alphabetical order. The default value of 'sort' is False. Signed-off-by: Yordan Karadzhov (VMware) --- src/ftracepy-utils.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c index 0fcadd8..f884106 100644 --- a/src/ftracepy-utils.c +++ b/src/ftracepy-utils.c @@ -733,18 +733,20 @@ PyObject *PyFtrace_available_event_systems(PyObject *self, PyObject *args, PyObject *PyFtrace_available_system_events(PyObject *self, PyObject *args, PyObject *kwargs) { - static char *kwlist[] = {"system", "instance", NULL}; + static char *kwlist[] = {"system", "instance", "sort", NULL}; struct tracefs_instance *instance; PyObject *py_inst = NULL; const char *system; + int sort = false; char **list; if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "s|O", + "s|Op", kwlist, &system, - &py_inst)) { + &py_inst, + &sort)) { return NULL; } @@ -757,7 +759,7 @@ PyObject *PyFtrace_available_system_events(PyObject *self, PyObject *args, if (!list) return NULL; - return tfs_list2py_list(list, false); + return tfs_list2py_list(list, sort); } bool get_event_enable_file(struct tracefs_instance *instance, From patchwork Tue Aug 31 12:53:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12467159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 510D4C432BE for ; Tue, 31 Aug 2021 12:54:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 34C7161051 for ; Tue, 31 Aug 2021 12:54:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232238AbhHaMzI (ORCPT ); Tue, 31 Aug 2021 08:55:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbhHaMzI (ORCPT ); Tue, 31 Aug 2021 08:55:08 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E695C061575 for ; Tue, 31 Aug 2021 05:54:13 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id u3so38346302ejz.1 for ; Tue, 31 Aug 2021 05:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c9pp2YjBs7uw+inFCfj8LpaWJy3nC58Un7gERWT88QY=; b=A2gMvLv20mqcToFJNaJ7aLXdUoVV/uApC4TBky7AgVfg6Hzf2kwEFUA51Z/gVEPYN7 dg0vQZBKU0yvubAQxCXViMJEn+pnjrixf7fI/cRI+G0wEkJkRyqo16sI8h9jC0MOFKSP rSo+UerjrsF6TsukTnj2LqLak5JEm5c2oW9/PZJOPCg4ouY0Q8SA9qVtjv6oc3EQc0ao KWixBuas00OIScXKfKO6okOFaPJnqHQ6l0YKd2DCwiza3jZxBrCiDGQ2PiLo0DzpCWAL GDJshl3A/BAuPud3QLCYseAxvXR5Gn9yhJKRXHSuO244Mq8HLnT1sgAn5+xTHUZDu33j C7hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c9pp2YjBs7uw+inFCfj8LpaWJy3nC58Un7gERWT88QY=; b=bJ4Rz9EbzqY15zRW5BG+OSg+pywp9QqZjofkr1sNUmKdG+RPi2MVLJfW79WGCKLmLN WgH1dIN5BB5TOWPdyXpDbvN57ap6OyOzuNw1P9eS3o7CqKoAJy5xoPA8JNqBDIxf35wo x2TnCSxAGlltpyq8rCFfv27gCjcZAY1uGOaSdRyUEtW5xysYkQpvfsY314MtUuf8oT+W 9JyeawgUpquyZp4KzL7hSpD5VGSdCSrAU4og5SyBHSn6wJAD4MIVhKtiU3uBbloHetfs PzsFQTsxXsESc0rscFM+H12E3ERjFDPvzYKvwTYTs92TwRpt7Fz36FaNcC4ouV5vuB0Q m37Q== X-Gm-Message-State: AOAM532AtQBX8wxJwgs4PMYuwU/r1sl9/BKYSTiQdC/jFIQM5kQ6vA/1 z79SO4L3wAgeBaVLvsc/rkqCBUia/5s= X-Google-Smtp-Source: ABdhPJxgzGuyox6sNYg/J0DMtaFNfzr6cBWfn26zU3+wbLoGe2puvE8l1m1GFmXe0hRTsVu49NwZag== X-Received: by 2002:a17:906:ae4f:: with SMTP id lf15mr29792057ejb.124.1630414451556; Tue, 31 Aug 2021 05:54:11 -0700 (PDT) Received: from crow.. ([95.87.199.93]) by smtp.gmail.com with ESMTPSA id be5sm9346976edb.57.2021.08.31.05.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 05:54:11 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: linux-trace-devel@vger.kernel.org Cc: "Yordan Karadzhov (VMware)" Subject: [PATCH 3/4] trace-cruncher: Add optional sort to available_event_systems() Date: Tue, 31 Aug 2021 15:53:56 +0300 Message-Id: <20210831125357.56862-3-y.karadz@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210831125357.56862-1-y.karadz@gmail.com> References: <20210831125357.56862-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org An optional parameter 'sort' is added. If set to True, the returned list of system names is sorted in alphabetical order. The default value of 'sort' is False. Signed-off-by: Yordan Karadzhov (VMware) --- src/ftracepy-utils.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c index f884106..b94745d 100644 --- a/src/ftracepy-utils.c +++ b/src/ftracepy-utils.c @@ -717,17 +717,29 @@ PyObject *PyFtrace_get_current_tracer(PyObject *self, PyObject *args, PyObject *PyFtrace_available_event_systems(PyObject *self, PyObject *args, PyObject *kwargs) { + static char *kwlist[] = {"instance", "sort", NULL}; struct tracefs_instance *instance; + PyObject *py_inst = NULL; + int sort = false; char **list; - if (!get_instance_from_arg(args, kwargs, &instance)) + if (!PyArg_ParseTupleAndKeywords(args, + kwargs, + "|Op", + kwlist, + &py_inst, + &sort)) { + return false; + } + + if (!get_optional_instance(py_inst, &instance)) return NULL; list = tracefs_event_systems(tracefs_instance_get_dir(instance)); if (!list) return NULL; - return tfs_list2py_list(list, false); + return tfs_list2py_list(list, sort); } PyObject *PyFtrace_available_system_events(PyObject *self, PyObject *args, From patchwork Tue Aug 31 12:53:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12467161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C1A2C43214 for ; Tue, 31 Aug 2021 12:54:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A44361041 for ; Tue, 31 Aug 2021 12:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232251AbhHaMzJ (ORCPT ); Tue, 31 Aug 2021 08:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbhHaMzJ (ORCPT ); Tue, 31 Aug 2021 08:55:09 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0D34C061575 for ; Tue, 31 Aug 2021 05:54:13 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id e21so38376244ejz.12 for ; Tue, 31 Aug 2021 05:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L/W8EFIlGS+Cd0HJ8OdZKFcPxUBHrjWzs5U237S6x5g=; b=pmem1WMJQ2x0smhf8Crw6d78uzwVIFqNQzBLQtXABISJqUD4bD8HQwtUVG2hkV1LWB Orlkg6A8mnTzT5WxLwsGmOSvXZqmBZefKQ6XJ4v0wJjZM0RW0Kv6zs6o78w9yajNmAWz klpIVfftXL45BRyd5o6aNZ/3SnmVuNXb5a0H9913p5bHsdWsb01Xr0MlQ3g9zQXPylIe VWudOz26VZA0JL9iN+bt9J8guw1wuYWaOxPOYG8PehZVyikUwSeeYhiW7Oocn0QCghAU zo5tKdA3/cO0mgaijM2MHHoyVb1vRiGs3Z/Ma2Db6VWLR6riRKAFirTDuhyrSns9+bZ/ M8xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L/W8EFIlGS+Cd0HJ8OdZKFcPxUBHrjWzs5U237S6x5g=; b=dhNcEl5NMMUQQBHXGfvWFaHyThHPbzI0nDMoEXYa0BPPaH0zG7MdQm9Qgp5WnFKCHz suIP8sN0JA+fAAFG8seTQ+DL1BqC3Q3WpppB9fYr5n0bfvp8wiF3YlpQh1MCBKlFu5sD 4bqNxlBU5nDWObtN4vrUUGoblQybrhip40OSVo36ogJmWogrEd9tsH7Ggn/J1Ob12B2p tJXuIOPs6sjFs2YQ4MbXnRmKy0Q94gkTK/3kWN81YDgt2Z/oXZJ5tW87NCeTFD9qA4/m KxLwPv+1bKcM2HYzEAXi252xvXTwrGXL1sb6HyFhLOLb6ImKG7pDjTRlpy+m8c0+/Rr+ Vk6w== X-Gm-Message-State: AOAM5331RUq9Iq8THx6TfSKv7GjmFzhKI/9lTJeXONNks75SONO2WQFd 1TqMwTvhqtU1jp7RdUYrV9DLNQnnVGU= X-Google-Smtp-Source: ABdhPJzPkSWSIFFGeY+/antd5M853jKLeOVkB/lmldMFV6DqImEJ3uRAi7ciPAsajOvawegGvPduhQ== X-Received: by 2002:a17:906:7855:: with SMTP id p21mr19163843ejm.330.1630414452234; Tue, 31 Aug 2021 05:54:12 -0700 (PDT) Received: from crow.. ([95.87.199.93]) by smtp.gmail.com with ESMTPSA id be5sm9346976edb.57.2021.08.31.05.54.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 05:54:12 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: linux-trace-devel@vger.kernel.org Cc: "Yordan Karadzhov (VMware)" Subject: [PATCH 4/4] trace-cruncher: Add tests for sorted events/systems Date: Tue, 31 Aug 2021 15:53:57 +0300 Message-Id: <20210831125357.56862-4-y.karadz@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210831125357.56862-1-y.karadz@gmail.com> References: <20210831125357.56862-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org An optional parameter 'sort' was added to available_event_systems() and available_system_events(). Here we add the corresponding test cases. Signed-off-by: Yordan Karadzhov (VMware) --- .../tests/1_unit/test_01_ftracepy_unit.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py b/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py index 971fd5f..710d3e1 100644 --- a/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py +++ b/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py @@ -111,19 +111,23 @@ class TracersTestCase(unittest.TestCase): class EventsTestCase(unittest.TestCase): def test_available_systems(self): - systems = ft.available_event_systems() - self.assertTrue(len(systems) > 1) + systems = ft.available_event_systems(sort=True) + self.assertTrue(len(systems) > 2) self.assertTrue('sched' in systems) + for i in range(len(systems) - 2): + self.assertTrue(systems[i] < systems[i + 1]) inst = ft.create_instance(instance_name) systems = ft.available_event_systems(inst) - self.assertTrue(len(systems) > 1) + self.assertTrue(len(systems) > 2) self.assertTrue('sched' in systems) def test_available_system_events(self): - events = ft.available_system_events(system='sched') - self.assertTrue(len(events) > 1) + events = ft.available_system_events(system='sched', sort=True) + self.assertTrue(len(events) > 2) self.assertTrue('sched_switch' in events) + for i in range(len(events) - 2): + self.assertTrue(events[i] < events[i + 1]) inst = ft.create_instance(instance_name) events = ft.available_system_events(instance=inst,