transport: test: Pass time to trigger pldm_transport_poll(..., 0)

The test transport uses a timerfd to implement latency when required,
but also to indicate readiness when latency hasn't been specified. The
implementation for immediate readiness is a bit of a hack, as it just
sets an exceptionally short timer period (1ns). However, intermittently
it appears this 1ns expiry is not exceeded by the time we test the fd
state via poll().

To resolve that issue, ensure we've waited twice the timer expiry
period.

Also fix a subsequent segfault when the readiness test fails. The
memcmp(msg, ...) invocation must be protected by a prior `ASSERT_EQ()`
as the msg pointer may not be valid if the result is not
PLDM_REQUESTER_SUCCESS (execution is allowed to proceed if an EXPECT_*()
condition fails).

Prior to the fix the failure was often triggered at least once with the
following invocation:

```
meson test -C build --repeat 10 --test-args="--gtest_filter=Transport.send_recv_drain_one_unwanted" transport
```

After the fix, increasing the repeat count up to 100 failed to reproduce
the failure.

Fixes: f56e4dcd2545 ("transport: free un-wanted responses in pldm_transport_send_recv_msg()")
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: If67c58f5c7f06ce76d24b8c6b9430ae080d83441
diff --git a/src/transport/test.c b/src/transport/test.c
index 0f35ffc..dad8690 100644
--- a/src/transport/test.c
+++ b/src/transport/test.c
@@ -1,8 +1,12 @@
+/* NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) */
+#define _GNU_SOURCE
+#include "array.h"
 #include "container-of.h"
 #include "transport.h"
 #include "test.h"
 
 #include <errno.h>
+#include <poll.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -59,15 +63,28 @@
 		test->cursor++;
 	} else if (desc->type == PLDM_TRANSPORT_TEST_ELEMENT_MSG_RECV) {
 		/* Expire the timer immediately so it appears ready */
+		static const struct timespec ensure_ready = {
+			.tv_sec = 0,
+			.tv_nsec = 2,
+		};
 		static const struct itimerspec ready = {
 			.it_value = { 0, 1 },
 			.it_interval = { 0, 0 },
 		};
+		struct pollfd pfds[] = {
+			{ .fd = test->timerfd, .events = POLLIN },
+		};
+
 		rc = timerfd_settime(test->timerfd, 0, &ready, NULL);
 		if (rc < 0) {
 			return PLDM_REQUESTER_POLL_FAIL;
 		}
 
+		rc = ppoll(pfds, ARRAY_SIZE(pfds), &ensure_ready, NULL);
+		if (rc < 1) {
+			return PLDM_REQUESTER_POLL_FAIL;
+		}
+
 		/* Don't increment test->cursor as recv needs to consume the current test element */
 	} else {
 		return PLDM_REQUESTER_POLL_FAIL;