aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2019-03-08 15:37:03 (GMT)
committerHans Verkuil <hans.verkuil@cisco.com>2019-03-08 15:37:03 (GMT)
commit7f912dc2f989a1d400bb11d9c7a73f93801a2ee4 (patch)
treef522ac7f6462cc848702ca48cb0bfd7e03a8c912
parent5feb1938dca63b30f06c533bd892cfcf1b2894dd (diff)
v4l2-compliance: fix check for entity names
sizeof(name) is 64 for media_v2_entity but 32 for struct media_entity_desc. So only consider the first 32 bytes (31 characters) for the duplicate name tests and matching what ENUM_ENTITIES reports with what G_TOPOLOGY reports. Also relax the check of the possible interface types to allow alsa as this is upcoming with the Media Device Allocator API. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--utils/v4l2-compliance/v4l2-test-media.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/utils/v4l2-compliance/v4l2-test-media.cpp b/utils/v4l2-compliance/v4l2-test-media.cpp
index ec65ccf..c0b3de5 100644
--- a/utils/v4l2-compliance/v4l2-test-media.cpp
+++ b/utils/v4l2-compliance/v4l2-test-media.cpp
@@ -171,6 +171,23 @@ int testMediaTopology(struct node *node)
for (unsigned i = 0; i < topology.num_entities; i++) {
media_v2_entity &ent = v2_ents[i];
+ std::string key = ent.name;
+
+ /*
+ * The v2_entity_names_set set is used to check if a specific
+ * entity name is reused, and to check if the topology matches
+ * what ENUM_ENTITIES returns.
+ *
+ * However, the size of the entity name array of media_v2_entity
+ * is 64 characters, while it is 32 for media_entity_desc.
+ *
+ * So cut off the last 32 characters before storing the key.
+ * This means that the first 31 characters of the entity name
+ * must be unique, otherwise ENUM_ENTITIES would return
+ * duplicate entity names.
+ */
+ if (key.length() >= 32)
+ key.erase(31, key.length() - 1);
if (show_info) {
printf("\t\tEntity: 0x%08x (Name: '%s', Function: %s",
@@ -184,11 +201,11 @@ int testMediaTopology(struct node *node)
fail_on_test(!ent.id);
fail_on_test(checkFunction(ent.function, true));
fail_on_test(v2_entities_set.find(ent.id) != v2_entities_set.end());
- fail_on_test(v2_entity_names_set.find(ent.name) != v2_entity_names_set.end());
+ fail_on_test(v2_entity_names_set.find(key) != v2_entity_names_set.end());
if (!MEDIA_V2_ENTITY_HAS_FLAGS(node->media_version))
fail_on_test(ent.flags);
v2_entities_set.insert(ent.id);
- v2_entity_names_set.insert(ent.name);
+ v2_entity_names_set.insert(key);
v2_entity_map[ent.id] = &ent;
}
for (unsigned i = 0; i < topology.num_interfaces; i++) {
@@ -207,7 +224,7 @@ int testMediaTopology(struct node *node)
fail_on_test(!iface.id);
fail_on_test(!iface.intf_type);
fail_on_test(iface.intf_type < MEDIA_INTF_T_DVB_BASE);
- fail_on_test(iface.intf_type > MEDIA_INTF_T_V4L_BASE + 0xff);
+ fail_on_test(iface.intf_type > MEDIA_INTF_T_ALSA_BASE + 0xff);
fail_on_test(iface.flags);
fail_on_test(v2_interfaces_set.find(iface.id) != v2_interfaces_set.end());
v2_interfaces_set.insert(iface.id);

Privacy Policy