Fix a flaky test in buffer_hub-test

UDS-based PDX guarantees commands execution on the same channel. However,
where there are incoming commands from different channels, the execution
order can no longer be guaranteed as the service basical holds a epoll
on sockets from different FDs.

The original test we put up is flaky for the following commands:

c1->ReleaseAsync
p->CreateConsumer

Not that the ReleaseAsync call may actually happen after a new consumer
gets created, which prevents the buffer from being fulling released back
to the producer.

To de-flaky the test, simplily poll the producer after the release to
confirm that the buffer is indeed released before moving on.

Bug: 70298522
Bug: 70046255
Test: buffer_hub-test
Change-Id: Ia3987642a40f62e7d151edbdf0f11dd9bee57223
diff --git a/libs/vr/libbufferhub/buffer_hub-test.cpp b/libs/vr/libbufferhub/buffer_hub-test.cpp
index a5cf9ae..471ec7b 100644
--- a/libs/vr/libbufferhub/buffer_hub-test.cpp
+++ b/libs/vr/libbufferhub/buffer_hub-test.cpp
@@ -451,13 +451,19 @@
   EXPECT_EQ(0, c1->AcquireAsync(&metadata, &invalid_fence));
   EXPECT_EQ(0, c1->ReleaseAsync(&metadata, invalid_fence));
 
+  // Note that the next PDX call is on the producer channel, which may be
+  // executed before Release impulse gets executed by bufferhubd. Thus, here we
+  // need to wait until the releasd is confirmed before creating another
+  // consumer.
+  EXPECT_LT(0, RETRY_EINTR(p->Poll(kPollTimeoutMs)));
+  EXPECT_TRUE(IsBufferReleased(p->buffer_state()));
+
   // Create another consumer immediately after the release, should not make the
-  // buffer un-released. This is guaranteed by IPC execution order in bufferhubd.
+  // buffer un-released.
   std::unique_ptr<BufferConsumer> c2 =
       BufferConsumer::Import(p->CreateConsumer());
   ASSERT_TRUE(c2.get() != nullptr);
 
-  EXPECT_LT(0, RETRY_EINTR(p->Poll(kPollTimeoutMs)));
   EXPECT_TRUE(IsBufferReleased(p->buffer_state()));
   EXPECT_EQ(0, p->GainAsync(&metadata, &invalid_fence));
   EXPECT_TRUE(IsBufferGained(p->buffer_state()));