The sequence number produced by vivid it is not warrantied to increase one by one. It will "skip" frames if they cannot be produced on time. In our tests, we were assuming that there was no frame skipped by vivid, and this caused a series of flakes. Fix this, by saving the actual sequence number during captureBufs() and using it as reference for vivid_ro_ctrl. Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx> --- utils/v4l2-compliance/v4l2-test-buffers.cpp | 26 ++++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp index 1db6f4e9..58e01266 100644 --- a/utils/v4l2-compliance/v4l2-test-buffers.cpp +++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp @@ -1028,7 +1028,7 @@ static int setupM2M(struct node *node, cv4l_queue &q, bool init = true) static int captureBufs(struct node *node, struct node *node_m2m_cap, const cv4l_queue &q, cv4l_queue &m2m_q, unsigned frame_count, int pollmode, - unsigned &capture_count) + unsigned &capture_count, unsigned *sequences) { static constexpr const char *pollmode_str[] = { "", @@ -1185,6 +1185,8 @@ static int captureBufs(struct node *node, struct node *node_m2m_cap, const cv4l_ field2s(buf.g_field()).c_str(), buf.g_bytesused(), bufferflags2s(buf.g_flags()).c_str(), static_cast<__u64>(buf.g_timestamp().tv_sec), static_cast<__u64>(buf.g_timestamp().tv_usec)); + if (sequences) + sequences[frame_count - count] = buf.g_sequence(); for (unsigned p = 0; p < buf.g_num_planes(); p++) { if (max_bytesused[p] < buf.g_bytesused(p)) max_bytesused[p] = buf.g_bytesused(p); @@ -1603,7 +1605,7 @@ int testMmap(struct node *node, struct node *node_m2m_cap, unsigned frame_count, } fail_on_test(captureBufs(node, node_m2m_cap, q, m2m_q, frame_count, - pollmode, capture_count)); + pollmode, capture_count, NULL)); fail_on_test(node->streamoff(q.g_type())); fail_on_test(node->streamoff(q.g_type())); if (node->is_m2m) @@ -1914,7 +1916,7 @@ int testUserPtr(struct node *node, struct node *node_m2m_cap, unsigned frame_cou fail_on_test(setupM2M(node_m2m_cap, m2m_q)); } fail_on_test(captureBufs(node, node_m2m_cap, q, m2m_q, frame_count, - pollmode, capture_count)); + pollmode, capture_count, NULL)); fail_on_test(node->streamoff(q.g_type())); fail_on_test(node->streamoff(q.g_type())); if (node->is_m2m) { @@ -2127,7 +2129,7 @@ int testDmaBuf(struct node *expbuf_node, struct node *node, struct node *node_m2 fail_on_test(setupM2M(node_m2m_cap, m2m_q)); } fail_on_test(captureBufs(node, node_m2m_cap, q, m2m_q, frame_count, - pollmode, capture_count)); + pollmode, capture_count, NULL)); fail_on_test(node->streamoff(q.g_type())); fail_on_test(node->streamoff(q.g_type())); if (node->supports_orphaned_bufs) { @@ -2376,6 +2378,7 @@ int testRequests(struct node *node, bool test_streaming) unsigned num_bufs = q.g_buffers(); // Create twice as many requests as there are buffers unsigned num_requests = 2 * num_bufs; + unsigned sequences[num_requests]; last_seq.init(); media_fd = fhs.add(mi_get_media_fd(node->g_fd(), node->bus_info)); @@ -2664,7 +2667,7 @@ int testRequests(struct node *node, bool test_streaming) // min_bufs buffers we need to add min_bufs to the frame_count. fail_on_test(captureBufs(node, node, q, m2m_q, num_bufs + (node->is_m2m ? min_bufs : 0), - POLL_MODE_SELECT, capture_count)); + POLL_MODE_SELECT, capture_count, sequences)); } fail_on_test(node->streamoff(q.g_type())); @@ -2692,8 +2695,11 @@ int testRequests(struct node *node, bool test_streaming) fail_on_test(doioctl(node, VIDIOC_G_EXT_CTRLS, &vivid_ro_ctrls)); if (node->is_video && !node->can_output && vivid_ro_ctrl.value != (int)i) - warn_once("vivid_ro_ctrl.value (%d) != i (%u)\n", - vivid_ro_ctrl.value, i); + info("vivid_ro_ctrl.value (%d) != i (%u)\n", + vivid_ro_ctrl.value, i); + + if (node->is_video && !node->can_output) + fail_on_test(sequences[i] != (__u32) vivid_ro_ctrl.value); // Check that the dynamic control array is set as // expected and with the correct values. @@ -2769,9 +2775,11 @@ int testRequests(struct node *node, bool test_streaming) vivid_ro_ctrls.which = 0; fail_on_test(doioctl(node, VIDIOC_G_EXT_CTRLS, &vivid_ro_ctrls)); if (node->is_video && !node->can_output && - vivid_ro_ctrl.value != (int)(num_bufs - 1)) - warn("vivid_ro_ctrl.value (%d) != num_bufs - 1 (%d)\n", + vivid_ro_ctrl.value != (int)(num_bufs - 1)) { + fail_on_test(vivid_ro_ctrl.value < (int)(num_bufs - 1)); + info("vivid_ro_ctrl.value (%d) != num_bufs - 1 (%d)\n", vivid_ro_ctrl.value, num_bufs - 1); + } // the final dynamic array value, v4l2_query_ext_ctrl q_dyn_array = { -- 2.44.0.683.g7961c838ac-goog