On Wed, Apr 19, 2023 at 6:36 AM Hoo Robert <robert.hoo.linux@xxxxxxxxx> wrote: > > How about goto > ts_diff = timespec_elapsed(start); > Otherwise last stats won't get chances to be calc'ed. Good idea, done. > > + TEST_ASSERT(r == 1, > > + "Unexpected number of events (%d) from epoll, errno = %d", > > + r, errno); > > > too much indentation, also seen elsewhere. Augh, my editor has been set to a tab width of 4 this entire time. That... explains a lot >:( > > } > > > > - if (!(pollfd[0].revents & POLLIN)) > > - continue; > > + TEST_ASSERT(!(evt.events & (EPOLLERR | EPOLLHUP)), > > + "Reader thread received EPOLLERR or EPOLLHUP on uffd."); > > > > r = read(uffd, &msg, sizeof(msg)); > > if (r == -1) { > > - if (errno == EAGAIN) > > - continue; > > - pr_info("Read of uffd got errno %d\n", errno); > > - return NULL; > > + TEST_ASSERT(errno == EAGAIN, > > + "Error reading from UFFD: errno = %d", errno); > > + continue; > > } > > > > - if (r != sizeof(msg)) { > > - pr_info("Read on uffd returned unexpected size: %d bytes", r); > > - return NULL; > > - } > > + TEST_ASSERT(r == sizeof(msg), > > + "Read on uffd returned unexpected number of bytes (%d)", r); > > > > if (!(msg.event & UFFD_EVENT_PAGEFAULT)) > > continue; > > @@ -93,8 +89,8 @@ static void *uffd_handler_thread_fn(void *arg) > > if (reader_args->delay) > > usleep(reader_args->delay); > > r = reader_args->handler(reader_args->uffd_mode, uffd, &msg); > > - if (r < 0) > > - return NULL; > > + TEST_ASSERT(r >= 0, > > + "Reader thread handler fn returned negative value %d", r); > > pages++; > > } > > >