From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org, y.karadz@gmail.com
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH v7 14/15] libtracefs: Add utest for event probes
Date: Mon, 15 Nov 2021 12:45:55 +0200 [thread overview]
Message-ID: <20211115104556.121359-15-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20211115104556.121359-1-tz.stoyanov@gmail.com>
All library APIs should be covered by the library unit test, that's why
it is extended with new eeven probes tests.
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
utest/tracefs-utest.c | 68 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index 2e4084d..96b2baf 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -782,6 +782,73 @@ static void test_kprobes(void)
test_kprobes_instance(test_instance);
}
+static void test_eprobes_instance(struct tracefs_instance *instance)
+{
+ struct probe_test etests[] = {
+ { TRACEFS_DYNEVENT_EPROBE, "e", NULL, "sopen_in", "syscalls.sys_enter_openat",
+ "file=+0($filename):ustring" },
+ { TRACEFS_DYNEVENT_EPROBE, "e", "etest", "sopen_out", "syscalls.sys_exit_openat",
+ "res=$ret:u64" },
+ };
+ int count = sizeof(etests) / sizeof((etests)[0]);
+ struct tracefs_dynevent **deprobes;
+ struct tracefs_dynevent **devents;
+ char *tsys, *tevent;
+ char *tmp, *sav;
+ int ret;
+ int i;
+
+ deprobes = calloc(count + 1, sizeof(*deprobes));
+
+ /* Invalid parameters */
+ CU_TEST(tracefs_eprobe_alloc("test", NULL, "test", "test", "test") == NULL);
+ CU_TEST(tracefs_eprobe_alloc("test", "test", NULL, "test", "test") == NULL);
+ CU_TEST(tracefs_eprobe_alloc("test", "test", "test", NULL, "test") == NULL);
+
+ ret = tracefs_dynevent_destroy_all(TRACEFS_DYNEVENT_EPROBE, true);
+ CU_TEST(ret == 0);
+ get_dynevents_check(TRACEFS_DYNEVENT_EPROBE, 0);
+
+ for (i = 0; i < count; i++) {
+ tmp = strdup(etests[i].address);
+ tsys = strtok_r(tmp, "./", &sav);
+ tevent = strtok_r(NULL, "", &sav);
+ deprobes[i] = tracefs_eprobe_alloc(etests[i].system, etests[i].event,
+ tsys, tevent, etests[i].format);
+ free(tmp);
+ CU_TEST(deprobes[i] != NULL);
+ }
+ deprobes[i] = NULL;
+
+ get_dynevents_check(TRACEFS_DYNEVENT_EPROBE, 0);
+ CU_TEST(check_probes(etests, count, deprobes, false, instance));
+
+ for (i = 0; i < count; i++) {
+ CU_TEST(tracefs_dynevent_create(deprobes[i]) == 0);
+ }
+
+ devents = get_dynevents_check(TRACEFS_DYNEVENT_EPROBE, count);
+ CU_TEST(check_probes(etests, count, devents, true, instance));
+ tracefs_dynevent_list_free(devents);
+ devents = NULL;
+
+ for (i = 0; i < count; i++) {
+ CU_TEST(tracefs_dynevent_destroy(deprobes[i], false) == 0);
+ }
+ get_dynevents_check(TRACEFS_DYNEVENT_EPROBE, 0);
+ CU_TEST(check_probes(etests, count, deprobes, false, instance));
+
+ for (i = 0; i < count; i++)
+ tracefs_dynevent_free(deprobes[i]);
+
+ free(deprobes);
+}
+
+static void test_eprobes(void)
+{
+ test_eprobes_instance(test_instance);
+}
+
static void test_instance_file(void)
{
struct tracefs_instance *instance = NULL;
@@ -1616,4 +1683,5 @@ void test_tracefs_lib(void)
test_ftrace_marker);
CU_add_test(suite, "kprobes", test_kprobes);
CU_add_test(suite, "syntetic events", test_synthetic);
+ CU_add_test(suite, "eprobes", test_eprobes);
}
--
2.33.1
next prev parent reply other threads:[~2021-11-15 10:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 10:45 [PATCH v7 00/15] libtracefs dynamic events support Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 01/15] libtracefs: New APIs for dynamic events Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 02/15] libtracefs: New APIs for kprobe allocation Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 03/15] libtracefs: Remove redundant kprobes APIs Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 04/15] libtracefs: Reimplement kprobe raw APIs Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 05/15] libtracefs: Extend kprobes unit test Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 06/15] libtracefs: Rename tracefs_synth_init API Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 07/15] libtracefs: Use the internal dynamic events API when creating synthetic events Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 08/15] libtracefs: Remove instance parameter from synthetic events APIs Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 09/15] libtracefs: Add unit test for synthetic events Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 10/15] libtracefs: Update kprobes man pages Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 11/15] libtracefs: Document dynamic events APIs Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 12/15] libtracefs: Do not clean sqlhist man page source Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 13/15] libtracefs: Introduce eprobe API Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` Tzvetomir Stoyanov (VMware) [this message]
2021-11-15 10:45 ` [PATCH v7 15/15] libtracefs: Document " 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=20211115104556.121359-15-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=y.karadz@gmail.com \
/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).