From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Subject: [PATCH 3/3] trace-cmd utest: Add tests for trace-cmd sqlhist
Date: Fri, 5 Jan 2024 23:22:29 -0500 [thread overview]
Message-ID: <20240106042428.279706-4-rostedt@goodmis.org> (raw)
In-Reply-To: <20240106042428.279706-1-rostedt@goodmis.org>
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Add tests to test the trace-cmd sqlhist command as well as the
trace-cmd show --hist and --trigger options.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
utest/tracecmd-utest.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/utest/tracecmd-utest.c b/utest/tracecmd-utest.c
index 6ba2318eaeb4..d67678e36554 100644
--- a/utest/tracecmd-utest.c
+++ b/utest/tracecmd-utest.c
@@ -32,6 +32,13 @@ static char tracecmd_exec[PATH_MAX];
#define TRACECMD_IN "-i", TRACECMD_FILE
#define TRACECMD_IN2 "-i", TRACECMD_FILE2
+#define TRACECMD_SQL_HIST "SELECT irq FROM irq_handler_entry"
+#define TRACECMD_SQL_READ_HIST "show", "--hist", "irq_handler_entry"
+
+#define SYNTH_EVENT "wakeup"
+#define TRACECMD_SQL_SYNTH "-e", "-n", SYNTH_EVENT, "SELECT start.pid AS this_pid, (end.TIMESTAMP_USECS - start.TIMESTAMP_USECS) AS delta FROM sched_waking as start JOIN sched_switch AS end ON start.pid = end.next_pid"
+#define TRACECMD_SQL_START_SYNTH "start", "-e", SYNTH_EVENT
+
static char **get_args(const char *cmd, va_list ap)
{
const char *param;
@@ -326,6 +333,25 @@ static void test_trace_record_report(void)
CU_TEST(ret == 0);
}
+static void test_trace_sqlhist_hist(void)
+{
+ int ret;
+
+ ret = run_trace("sqlhist", "-e", TRACECMD_SQL_HIST, NULL);
+ CU_TEST(ret == 0);
+ ret = grep_match(" *Hits: [0-9][0-9]*", TRACECMD_SQL_READ_HIST, NULL);
+ CU_TEST(ret == 0);
+ ret = run_trace("sqlhist", TRACECMD_SQL_SYNTH, NULL);
+ CU_TEST(ret == 0);
+ ret = run_trace(TRACECMD_SQL_START_SYNTH, NULL);
+ CU_TEST(ret == 0);
+ sleep(1);
+ ret = grep_match(SYNTH_EVENT ":", "show", NULL);
+ CU_TEST(ret == 0);
+
+ tracefs_instance_reset(NULL);
+}
+
static int read_stats(const char *out, const char *match, const char *cmd, ...)
{
struct do_grep_it gdata;
@@ -508,6 +534,8 @@ void test_tracecmd_lib(void)
}
CU_add_test(suite, "Simple record and report",
test_trace_record_report);
+ CU_add_test(suite, "Create a histogram",
+ test_trace_sqlhist_hist);
CU_add_test(suite, "Test convert from v7 to v6",
test_trace_convert6);
CU_add_test(suite, "Use libraries to read file",
--
2.42.0
prev parent reply other threads:[~2024-01-06 4:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-06 4:22 [PATCH 0/3] trace-cmd: Add sqlhist option and show hist and triggers Steven Rostedt
2024-01-06 4:22 ` [PATCH 1/3] trace-cmd show: Add --hist and --trigger options Steven Rostedt
2024-01-06 4:22 ` [PATCH 2/3] trace-cmd sqlhist: Add 'sqlhist' command Steven Rostedt
2024-01-06 4:22 ` Steven Rostedt [this message]
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=20240106042428.279706-4-rostedt@goodmis.org \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.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 read-only IMAP folder(s) and NNTP newsgroup(s).