From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 2/4] libtracefs: Unit test for iterate over raw events in sorted order
Date: Tue, 6 Apr 2021 07:19:59 +0300 [thread overview]
Message-ID: <20210406042001.912544-3-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20210406042001.912544-1-tz.stoyanov@gmail.com>
Enhanced the unit test of tracefs_iterate_raw_events() API to check if
events are iterated in sorted order: latest first. Added a check for the
correct CPU number in the record, passed to the callback.
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
utest/tracefs-utest.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index ed2693b..fea4e1f 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -20,7 +20,7 @@
#define TRACEFS_SUITE "trasefs library"
#define TEST_INSTANCE_NAME "cunit_test_iter"
#define TEST_TRACE_DIR "/tmp/trace_utest.XXXXXX"
-#define TEST_ARRAY_SIZE 500
+#define TEST_ARRAY_SIZE 5000
#define ALL_TRACERS "available_tracers"
#define CUR_TRACER "current_tracer"
@@ -36,6 +36,7 @@ struct test_sample {
};
static struct test_sample test_array[TEST_ARRAY_SIZE];
static int test_found;
+static unsigned long long last_ts;
static int test_callback(struct tep_event *event, struct tep_record *record,
int cpu, void *context)
@@ -45,8 +46,13 @@ static int test_callback(struct tep_event *event, struct tep_record *record,
int *cpu_test = (int *)context;
int i;
+ CU_TEST(last_ts <= record->ts);
+ last_ts = record->ts;
+
if (cpu_test && *cpu_test >= 0 && *cpu_test != cpu)
return 0;
+ CU_TEST(cpu == record->cpu);
+
field = tep_find_field(event, "buf");
if (field) {
sample = ((struct test_sample *)(record->data + field->offset));
@@ -136,6 +142,7 @@ static void test_instance_iter_raw_events(struct tracefs_instance *instance)
ret = tracefs_iterate_raw_events(NULL, instance, NULL, 0, test_callback, NULL);
CU_TEST(ret < 0);
+ last_ts = 0;
ret = tracefs_iterate_raw_events(test_tep, NULL, NULL, 0, test_callback, NULL);
CU_TEST(ret == 0);
ret = tracefs_iterate_raw_events(test_tep, instance, NULL, 0, NULL, NULL);
--
2.30.2
next prev parent reply other threads:[~2021-04-06 4:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 4:19 [PATCH 0/4] Iterate over raw events in sorted order Tzvetomir Stoyanov (VMware)
2021-04-06 4:19 ` [PATCH 1/4] libtracefs: " Tzvetomir Stoyanov (VMware)
2021-04-06 16:01 ` Steven Rostedt
2021-04-06 4:19 ` Tzvetomir Stoyanov (VMware) [this message]
2021-04-06 4:20 ` [PATCH 3/4] libtracefs: Unit test for iterate over raw events in selected CPUs Tzvetomir Stoyanov (VMware)
2021-04-06 4:20 ` [PATCH 4/4] libtracefs: tracefs_iterate_raw_events() documentation update Tzvetomir Stoyanov (VMware)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210406042001.912544-3-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).