git: c728c56c870a - main - kqueue tests: Add file and line info to some test failure output
Date: Wed, 25 May 2022 00:18:17 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c728c56c870abe230e45cee5c477f0d890ebacef commit c728c56c870abe230e45cee5c477f0d890ebacef Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2022-05-25 00:14:20 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2022-05-25 00:14:20 +0000 kqueue tests: Add file and line info to some test failure output This brings us slightly closer to upstream and is useful when debugging test failures. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation --- tests/sys/kqueue/libkqueue/common.h | 7 ++++--- tests/sys/kqueue/libkqueue/main.c | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/sys/kqueue/libkqueue/common.h b/tests/sys/kqueue/libkqueue/common.h index a92e544910ba..07ca908a114d 100644 --- a/tests/sys/kqueue/libkqueue/common.h +++ b/tests/sys/kqueue/libkqueue/common.h @@ -49,8 +49,8 @@ char * kevent_to_str(struct kevent *); struct kevent * kevent_get(int); struct kevent * kevent_get_timeout(int, int); - -void kevent_cmp(struct kevent *, struct kevent *); +#define kevent_cmp(a,b) _kevent_cmp(a,b, __FILE__, __LINE__) +void _kevent_cmp(struct kevent *expected, struct kevent *got, const char *file, int line); void kevent_add(int kqfd, struct kevent *kev, @@ -72,7 +72,8 @@ kevent_add(int kqfd, struct kevent *kev, } while (0); /* Checks if any events are pending, which is an error. */ -void test_no_kevents(void); +#define test_no_kevents() _test_no_kevents(__FILE__, __LINE__) +void _test_no_kevents(const char *, int); void test_no_kevents_quietly(void); void test_begin(const char *); diff --git a/tests/sys/kqueue/libkqueue/main.c b/tests/sys/kqueue/libkqueue/main.c index 5b37b0f1fb63..3e586faf7380 100644 --- a/tests/sys/kqueue/libkqueue/main.c +++ b/tests/sys/kqueue/libkqueue/main.c @@ -27,7 +27,7 @@ static int testnum = 1; /* Checks if any events are pending, which is an error. */ void -test_no_kevents(void) +_test_no_kevents(const char *file, int line) { int nfds; struct timespec timeo; @@ -38,7 +38,7 @@ test_no_kevents(void) memset(&timeo, 0, sizeof(timeo)); nfds = kevent(kqfd, NULL, 0, &kev, 1, &timeo); if (nfds != 0) { - puts("\nUnexpected event:"); + printf("\n[%s:%d]: Unexpected event:", file, line); kev_str = kevent_to_str(&kev); puts(kev_str); free(kev_str); @@ -239,7 +239,7 @@ kevent_add(int fd, struct kevent *kev, } void -kevent_cmp(struct kevent *k1, struct kevent *k2) +_kevent_cmp(struct kevent *k1, struct kevent *k2, const char *file, int line) { char *kev1_str; char *kev2_str; @@ -258,8 +258,8 @@ kevent_cmp(struct kevent *k1, struct kevent *k2) k1->ext[0] != k2->ext[2] || k1->ext[0] != k2->ext[3]) { kev1_str = kevent_to_str(k1); kev2_str = kevent_to_str(k2); - printf("kevent_cmp: mismatch:\n %s !=\n %s\n", - kev1_str, kev2_str); + printf("[%s:%d]: kevent_cmp: mismatch:\n %s !=\n %s\n", + file, line, kev1_str, kev2_str); free(kev1_str); free(kev2_str); abort();