From: Cao Ruichuang <create0818@163.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org,
Tzvetomir Stoyanov <tz.stoyanov@gmail.com>,
Emil Thorsoe <ethorsoe@tuxera.com>,
Cao Ruichuang <create0818@163.com>
Subject: [PATCH 2/2] libtraceevent utest: Avoid host-specific getname_flags output
Date: Mon, 1 Jun 2026 18:37:50 +0800 [thread overview]
Message-ID: <20260601103750.68805-3-create0818@163.com> (raw)
In-Reply-To: <20260601103750.68805-1-create0818@163.com>
test_btf_read() loads /sys/kernel/btf/vmlinux and expects
getname_flags() to print exactly two arguments:
getname_flags(filename=0x7ffe7d33f3d0, flags=0)
That prototype is not stable across kernels. On a Rocky Linux 9.7
system, the kernel BTF for getname_flags() has a third parameter named
empty, and tep_btf_print_args() correctly prints it.
Keep the exact output check for hosts that match the expected prototype.
For hosts that append extra getname_flags() BTF parameters after the
expected arguments, treat that host-specific suffix as an acceptable
variant only if the output still has the expected argument prefix and a
complete closing suffix.
Fixes: 0294b73f17e9 ("libtraceevent utest: Add simple test to test BTF parsing")
Assisted-by: Codex:gpt-5.5
Signed-off-by: Cao Ruichuang <create0818@163.com>
---
utest/traceevent-utest.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/utest/traceevent-utest.c b/utest/traceevent-utest.c
index b93d686..04f6726 100644
--- a/utest/traceevent-utest.c
+++ b/utest/traceevent-utest.c
@@ -16,6 +16,7 @@
#include <time.h>
#include <dirent.h>
#include <ftw.h>
+#include <string.h>
#include <sys/mman.h>
#include <stdint.h>
@@ -529,10 +530,21 @@ static int read_full(int fd, void *buf, size_t size)
return 0;
}
+static bool output_has_extra_args(const char *output, const char *prefix)
+{
+ size_t len = strlen(output);
+ size_t plen = strlen(prefix);
+
+ return len > plen + 3 && strncmp(output, prefix, plen) == 0 &&
+ output[plen] == ',' && strcmp(output + len - 2, ")\n") == 0;
+}
+
static void test_btf_read(void)
{
uint64_t args[] = {0x7ffe7d33f3d0, 0, 0, 0, 0, 0};
const char *func = "getname_flags";
+ const char *expected = "getname_flags(filename=0x7ffe7d33f3d0, flags=0)\n";
+ const char *expected_prefix = "getname_flags(filename=0x7ffe7d33f3d0, flags=0";
struct trace_seq *s = test_seq;
struct stat st;
void *buf;
@@ -582,7 +594,13 @@ static void test_btf_read(void)
trace_seq_puts(s, ")\n");
trace_seq_terminate(s);
- CU_TEST(strcmp(s->buffer, "getname_flags(filename=0x7ffe7d33f3d0, flags=0)\n") == 0);
+ if (strcmp(s->buffer, expected) != 0 &&
+ output_has_extra_args(s->buffer, expected_prefix)) {
+ printf("[KERNEL BTF HAS EXTRA getname_flags ARGS] ...");
+ return;
+ }
+
+ CU_TEST(strcmp(s->buffer, expected) == 0);
}
static int test_suite_destroy(void)
--
2.39.5 (Apple Git-154)
prev parent reply other threads:[~2026-06-01 10:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 10:37 [PATCH 0/2] libtraceevent: Fix BTF utest host dependencies Cao Ruichuang
2026-06-01 10:37 ` [PATCH 1/2] libtraceevent utest: Handle short reads when reading BTF Cao Ruichuang
2026-06-01 14:11 ` Steven Rostedt
2026-06-01 10:37 ` Cao Ruichuang [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=20260601103750.68805-3-create0818@163.com \
--to=create0818@163.com \
--cc=ethorsoe@tuxera.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tz.stoyanov@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