From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 3/4] libtracefs: Unit test for iterate over raw events in selected CPUs
Date: Tue, 6 Apr 2021 07:20:00 +0300 [thread overview]
Message-ID: <20210406042001.912544-4-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 walk
through the selected CPUs only. Added some forgotten calls to CPU_FREE()
for freeing used CPU sets.
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
utest/tracefs-utest.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index fea4e1f..f9441af 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -49,8 +49,9 @@ static int test_callback(struct tep_event *event, struct tep_record *record,
CU_TEST(last_ts <= record->ts);
last_ts = record->ts;
- if (cpu_test && *cpu_test >= 0 && *cpu_test != cpu)
- return 0;
+ if (cpu_test && *cpu_test >= 0) {
+ CU_TEST(*cpu_test == cpu);
+ }
CU_TEST(cpu == record->cpu);
field = tep_find_field(event, "buf");
@@ -105,18 +106,30 @@ static void test_iter_write(struct tracefs_instance *instance)
sched_setaffinity(0, cpu_size, cpusave);
close(fd);
+ CPU_FREE(cpuset);
+ CPU_FREE(cpusave);
}
static void iter_raw_events_on_cpu(struct tracefs_instance *instance, int cpu)
{
+ int cpus = sysconf(_SC_NPROCESSORS_CONF);
+ cpu_set_t *cpuset = NULL;
+ int cpu_size = 0;
int check = 0;
int ret;
int i;
+ if (cpu >= 0) {
+ cpuset = CPU_ALLOC(cpus);
+ cpu_size = CPU_ALLOC_SIZE(cpus);
+ CPU_ZERO_S(cpu_size, cpuset);
+ CPU_SET(cpu, cpuset);
+ }
test_found = 0;
+ last_ts = 0;
test_iter_write(instance);
- ret = tracefs_iterate_raw_events(test_tep, instance, NULL, 0,
+ ret = tracefs_iterate_raw_events(test_tep, instance, cpuset, cpu_size,
test_callback, &cpu);
CU_TEST(ret == 0);
if (cpu < 0) {
@@ -132,6 +145,9 @@ static void iter_raw_events_on_cpu(struct tracefs_instance *instance, int cpu)
}
CU_TEST(test_found == check);
}
+
+ if (cpuset)
+ CPU_FREE(cpuset);
}
static void test_instance_iter_raw_events(struct tracefs_instance *instance)
--
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 ` [PATCH 2/4] libtracefs: Unit test for iterate " Tzvetomir Stoyanov (VMware)
2021-04-06 4:20 ` Tzvetomir Stoyanov (VMware) [this message]
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-4-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).