From 34a4184d917a5215677d8e7fadea3a13acacf31e Mon Sep 17 00:00:00 2001 From: Devin Moore Date: Wed, 22 Apr 2020 15:49:21 -0700 Subject: [PATCH 1/4] Convert Python OMX VTS test to Gtest Moving the extra tests from test/vts-testcase/hal/media/omx/V1_0/host_omxstore/VtsHalMediaOmxStoreV1_0HostTest.py to the OMX Gtest in VtsHalMediaOmxV1_0TargetMasterTest. This is mostly validating the RoleInfo and NodeInfo data obtained from IOmxStore interface. Bug: 152237762 Test: atest VtsHalMediaOmxV1_0TargetMasterTest on cf and pixel devices Change-Id: I8174b8953ee5e484777afb21b2d170cec0159edc Merged-In: I8174b8953ee5e484777afb21b2d170cec0159edc --- .../omx/1.0/vts/functional/master/Android.bp | 1 + .../VtsHalMediaOmxV1_0TargetMasterTest.cpp | 343 +++++++++++++++++- 2 files changed, 325 insertions(+), 19 deletions(-) diff --git a/media/omx/1.0/vts/functional/master/Android.bp b/media/omx/1.0/vts/functional/master/Android.bp index 8e58821e12..5953eb5681 100644 --- a/media/omx/1.0/vts/functional/master/Android.bp +++ b/media/omx/1.0/vts/functional/master/Android.bp @@ -19,6 +19,7 @@ cc_test { defaults: ["VtsHalMediaOmxV1_0Defaults"], srcs: ["VtsHalMediaOmxV1_0TargetMasterTest.cpp"], test_suites: [ + "general-tests", "vts", ], } diff --git a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp index c14f1da8bc..9b4722ec57 100644 --- a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp +++ b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp @@ -20,6 +20,7 @@ #endif #include +#include #include #include @@ -33,21 +34,22 @@ #include #include -using ::android::hardware::media::omx::V1_0::IOmx; -using ::android::hardware::media::omx::V1_0::IOmxObserver; -using ::android::hardware::media::omx::V1_0::IOmxNode; -using ::android::hardware::media::omx::V1_0::IOmxStore; -using ::android::hardware::media::omx::V1_0::Message; -using ::android::hardware::media::omx::V1_0::CodecBuffer; -using ::android::hardware::media::omx::V1_0::PortMode; -using ::android::hidl::allocator::V1_0::IAllocator; -using ::android::hidl::memory::V1_0::IMemory; -using ::android::hidl::memory::V1_0::IMapper; +using ::android::sp; +using ::android::base::Join; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::media::omx::V1_0::CodecBuffer; +using ::android::hardware::media::omx::V1_0::IOmx; +using ::android::hardware::media::omx::V1_0::IOmxNode; +using ::android::hardware::media::omx::V1_0::IOmxObserver; +using ::android::hardware::media::omx::V1_0::IOmxStore; +using ::android::hardware::media::omx::V1_0::Message; +using ::android::hardware::media::omx::V1_0::PortMode; +using ::android::hidl::allocator::V1_0::IAllocator; +using ::android::hidl::memory::V1_0::IMapper; +using ::android::hidl::memory::V1_0::IMemory; #include #include @@ -70,6 +72,11 @@ class MasterHidlTest : public ::testing::TestWithParam { } }; +struct AttributePattern { + const testing::internal::RE key; + const testing::internal::RE value; +}; + void displayComponentInfo(hidl_vec& nodeList) { for (size_t i = 0; i < nodeList.size(); i++) { printf("%s | ", nodeList[i].mName.c_str()); @@ -80,6 +87,109 @@ void displayComponentInfo(hidl_vec& nodeList) { } } +/* + * Returns the role based on is_encoder and mime. + * + * The mapping from a pair (is_encoder, mime) to a role string is + * defined in frameworks/av/media/libmedia/MediaDefs.cpp and + * frameworks/av/media/libstagefright/omx/OMXUtils.cpp. This function + * does essentially the same work as GetComponentRole() in + * OMXUtils.cpp. + * + * Args: + * is_encoder: A boolean indicating whether the role is for an + * encoder or a decoder. + * mime: A string of the desired mime type. + * + * Returns: + * A const string for the requested role name, empty if mime is not + * recognized. + */ +const std::string getComponentRole(bool isEncoder, const std::string mime) { + // Mapping from mime types to roles. + // These values come from MediaDefs.cpp and OMXUtils.cpp + const std::map audioMimeToRole = { + {"3gpp", "amrnb"}, {"ac3", "ac3"}, {"amr-wb", "amrwb"}, + {"eac3", "eac3"}, {"flac", "flac"}, {"g711-alaw", "g711alaw"}, + {"g711-mlaw", "g711mlaw"}, {"gsm", "gsm"}, {"mp4a-latm", "aac"}, + {"mpeg", "mp3"}, {"mpeg-L1", "mp1"}, {"mpeg-L2", "mp2"}, + {"opus", "opus"}, {"raw", "raw"}, {"vorbis", "vorbis"}, + }; + const std::map videoMimeToRole = { + {"3gpp", "h263"}, {"avc", "avc"}, {"dolby-vision", "dolby-vision"}, + {"hevc", "hevc"}, {"mp4v-es", "mpeg4"}, {"mpeg2", "mpeg2"}, + {"x-vnd.on2.vp8", "vp8"}, {"x-vnd.on2.vp9", "vp9"}, + }; + const std::map imageMimeToRole = { + {"vnd.android.heic", "heic"}, + }; + + // Suffix begins after the mime prefix. + const size_t prefixEnd = mime.find("/"); + if (prefixEnd == std::string::npos || prefixEnd == mime.size()) return ""; + const std::string mime_suffix = mime.substr(prefixEnd + 1, mime.size() - 1); + const std::string middle = isEncoder ? "encoder." : "decoder."; + std::string prefix; + std::string suffix; + if (mime.rfind("audio/", 0) != std::string::npos) { + const auto it = audioMimeToRole.find(mime_suffix); + if (it == audioMimeToRole.end()) return ""; + prefix = "audio_"; + suffix = it->second; + } else if (mime.rfind("video/", 0) != std::string::npos) { + const auto it = videoMimeToRole.find(mime_suffix); + if (it == videoMimeToRole.end()) return ""; + prefix = "video_"; + suffix = it->second; + } else if (mime.rfind("image/", 0) != std::string::npos) { + const auto it = imageMimeToRole.find(mime_suffix); + if (it == imageMimeToRole.end()) return ""; + prefix = "image_"; + suffix = it->second; + } else { + return ""; + } + return prefix + middle + suffix; +} + +void validateAttributes( + const std::map& knownPatterns, + const std::vector& unknownPatterns, + hidl_vec attributes) { + std::set attributeKeys; + for (const auto& attr : attributes) { + // Make sure there are no duplicates + const auto [nodeIter, inserted] = attributeKeys.insert(attr.key); + EXPECT_EQ(inserted, true) << "Attribute \"" << attr.key << "\" has duplicates."; + + // Check the value against the corresponding regular + // expression. + const auto knownPattern = knownPatterns.find(attr.key); + if (knownPattern != knownPatterns.end()) { + EXPECT_EQ(testing::internal::RE::FullMatch(attr.value, knownPattern->second), true) + << "Attribute \"" << attr.key << "\" has invalid value \"" << attr.value << "."; + ; + } else { + // Failed to find exact attribute, check against + // possible patterns. + bool keyFound = false; + for (const auto& unknownPattern : unknownPatterns) { + if (testing::internal::RE::PartialMatch(attr.key, unknownPattern.key)) { + keyFound = true; + EXPECT_EQ(testing::internal::RE::FullMatch(attr.value, unknownPattern.value), + true) + << "Attribute \"" << attr.key << "\" has invalid value \"" << attr.value + << "."; + } + } + if (!keyFound) { + std::cout << "Warning, Unrecognized attribute \"" << attr.key << "\" with value \"" + << attr.value << "\"." << std::endl; + } + } + } +} + // Make sure IOmx and IOmxStore have the same set of instances. TEST(MasterHidlTest, instanceMatchValidation) { auto omxInstances = android::hardware::getAllHalInstanceNames(IOmx::descriptor); @@ -91,7 +201,7 @@ TEST(MasterHidlTest, instanceMatchValidation) { } } -// list service attributes +// list service attributes and verify expected formats TEST_P(MasterHidlTest, ListServiceAttr) { description("list service attributes"); android::hardware::media::omx::V1_0::Status status; @@ -105,7 +215,36 @@ TEST_P(MasterHidlTest, ListServiceAttr) { }) .isOk()); ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); - if (attributes.size() == 0) ALOGV("Warning, Attribute list empty"); + if (attributes.size() == 0) { + std::cout << "Warning, Attribute list empty" << std::endl; + } else { + /* + * knownPatterns is a map whose keys are the known "key" for a service + * attribute pair (see IOmxStore::Attribute), and whose values are the + * corresponding regular expressions that will have to match with the + * "value" of the attribute pair. If listServiceAttributes() returns an + * attribute that has a matching key but an unmatched value, the test + * will fail. + */ + const std::map knownPatterns = { + {"max-video-encoder-input-buffers", "0|[1-9][0-9]*"}, + {"supports-multiple-secure-codecs", "0|1"}, + {"supports-secure-with-non-secure-codec", "0|1"}, + }; + /* + * unknownPatterns is a vector of pairs of regular expressions. + * For each attribute whose key is not known (i.e., does not match any + * of the keys in the "knownPatterns" variable defined above), that key will be + * tried for a match with the first element of each pair of the variable + * "unknownPatterns". If a match occurs, the value of that same attribute will be + * tried for a match with the second element of the pair. If this second + * match fails, the test will fail. + */ + const std::vector unknownPatterns = { + {"supports-[a-z0-9-]*", "0|1"}}; + + validateAttributes(knownPatterns, unknownPatterns, attributes); + } } // get node prefix @@ -114,17 +253,183 @@ TEST_P(MasterHidlTest, getNodePrefix) { hidl_string prefix; omxStore->getNodePrefix( [&prefix](hidl_string const& _nl) { prefix = _nl; }); - if (prefix.empty()) ALOGV("Warning, Node Prefix empty"); + if (prefix.empty()) std::cout << "Warning, Node Prefix empty" << std::endl; } -// list roles +// list roles and validate all RoleInfo objects TEST_P(MasterHidlTest, ListRoles) { description("list roles"); hidl_vec roleList; omxStore->listRoles([&roleList](hidl_vec const& _nl) { roleList = _nl; }); - if (roleList.size() == 0) ALOGV("Warning, RoleInfo list empty"); + if (roleList.size() == 0) { + GTEST_SKIP() << "Warning, RoleInfo list empty"; + return; + } + + // Basic patterns for matching + const std::string toggle = "(0|1)"; + const std::string string = "(.*)"; + const std::string num = "(0|([1-9][0-9]*))"; + const std::string size = "(" + num + "x" + num + ")"; + const std::string ratio = "(" + num + ":" + num + ")"; + const std::string range_num = "((" + num + "-" + num + ")|" + num + ")"; + const std::string range_size = "((" + size + "-" + size + ")|" + size + ")"; + const std::string range_ratio = "((" + ratio + "-" + ratio + ")|" + ratio + ")"; + const std::string list_range_num = "(" + range_num + "(," + range_num + ")*)"; + + // Matching rules for node attributes with fixed keys + const std::map knownPatterns = { + {"alignment", size}, + {"bitrate-range", range_num}, + {"block-aspect-ratio-range", range_ratio}, + {"block-count-range", range_num}, + {"block-size", size}, + {"blocks-per-second-range", range_num}, + {"complexity-default", num}, + {"complexity-range", range_num}, + {"feature-adaptive-playback", toggle}, + {"feature-bitrate-control", "(VBR|CBR|CQ)[,(VBR|CBR|CQ)]*"}, + {"feature-can-swap-width-height", toggle}, + {"feature-intra-refresh", toggle}, + {"feature-partial-frame", toggle}, + {"feature-secure-playback", toggle}, + {"feature-tunneled-playback", toggle}, + {"frame-rate-range", range_num}, + {"max-channel-count", num}, + {"max-concurrent-instances", num}, + {"max-supported-instances", num}, + {"pixel-aspect-ratio-range", range_ratio}, + {"quality-default", num}, + {"quality-range", range_num}, + {"quality-scale", string}, + {"sample-rate-ranges", list_range_num}, + {"size-range", range_size}, + }; + + // Strings for matching rules for node attributes with key patterns + const std::vector unknownPatterns = { + {"measured-frame-rate-" + size + "-range", range_num}, + {"feature-[a-zA-Z0-9_-]+", string}, + }; + + // Matching rules for node names and owners + const testing::internal::RE nodeNamePattern = "[a-zA-Z0-9.-]+"; + const testing::internal::RE nodeOwnerPattern = "[a-zA-Z0-9._-]+"; + + std::set roleKeys; + std::map> nodeToRoles; + std::map> ownerToNodes; + for (const IOmxStore::RoleInfo& role : roleList) { + // Make sure there are no duplicates + const auto [roleIter, inserted] = roleKeys.insert(role.role); + EXPECT_EQ(inserted, true) << "Role \"" << role.role << "\" has duplicates."; + + // Make sure role name follows expected format based on type and + // isEncoder + const std::string role_name = getComponentRole(role.isEncoder, role.type); + EXPECT_EQ(role_name, role.role) << "Role \"" << role.role << "\" does not match " + << (role.isEncoder ? "an encoder " : "a decoder ") + << "for mime type \"" << role.type << "."; + + // Check the nodes for this role + std::set nodeKeys; + for (const IOmxStore::NodeInfo& node : role.nodes) { + // Make sure there are no duplicates + const auto [nodeIter, inserted] = nodeKeys.insert(node.name); + EXPECT_EQ(inserted, true) << "Node \"" << node.name << "\" has duplicates."; + + // Check the format of node name + EXPECT_EQ(testing::internal::RE::FullMatch(node.name, nodeNamePattern), true) + << "Node name \"" << node.name << " is invalid."; + // Check the format of node owner + EXPECT_EQ(testing::internal::RE::FullMatch(node.owner, nodeOwnerPattern), true) + << "Node owner \"" << node.owner << " is invalid."; + + validateAttributes(knownPatterns, unknownPatterns, node.attributes); + + ownerToNodes[node.owner].insert(node.name); + nodeToRoles[node.name].insert(role.role); + } + } + + // Verify the information with IOmx::listNodes(). + // IOmxStore::listRoles() and IOmx::listNodes() should give consistent + // information about nodes and roles. + for (const auto& [owner, nodes] : ownerToNodes) { + // Obtain the IOmx instance for each "owner" + const sp omx = omxStore->getOmx(owner); + EXPECT_NE(nullptr, omx); + + // Invoke IOmx::listNodes() + android::hardware::media::omx::V1_0::Status status; + hidl_vec nodeList; + EXPECT_TRUE( + omx->listNodes([&status, &nodeList](android::hardware::media::omx::V1_0::Status _s, + hidl_vec const& _nl) { + status = _s; + nodeList = _nl; + }).isOk()); + ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); + + // Verify that roles for each node match with the information from + // IOmxStore::listRoles(). + std::set nodeKeys; + for (IOmx::ComponentInfo node : nodeList) { + // Make sure there are no duplicates + const auto [nodeIter, inserted] = nodeKeys.insert(node.mName); + EXPECT_EQ(inserted, true) + << "IOmx::listNodes() lists duplicate nodes \"" << node.mName << "\"."; + + // Skip "hidden" nodes, i.e. those that are not advertised by + // IOmxStore::listRoles(). + if (nodes.find(node.mName) == nodes.end()) { + std::cout << "Warning, IOmx::listNodes() lists unknown node \"" << node.mName + << "\" for IOmx instance \"" << owner << "\"." << std::endl; + continue; + } + + // All the roles advertised by IOmxStore::listRoles() for this + // node must be included in roleKeys. + std::set difference; + std::set_difference(nodeToRoles[node.mName].begin(), nodeToRoles[node.mName].end(), + roleKeys.begin(), roleKeys.end(), + std::inserter(difference, difference.begin())); + EXPECT_EQ(difference.empty(), true) << "IOmx::listNodes() for IOmx " + "instance \"" + << owner + << "\" does not report some " + "expected nodes: " + << android::base::Join(difference, ", ") << "."; + } + // Check that all nodes obtained from IOmxStore::listRoles() are + // supported by the their corresponding IOmx instances. + std::set difference; + std::set_difference(nodes.begin(), nodes.end(), nodeKeys.begin(), nodeKeys.end(), + std::inserter(difference, difference.begin())); + EXPECT_EQ(difference.empty(), true) << "IOmx::listNodes() for IOmx " + "instance \"" + << owner + << "\" does not report some " + "expected nodes: " + << android::base::Join(difference, ", ") << "."; + } + + if (!nodeToRoles.empty()) { + // Check that the prefix is a sensible string. + hidl_string prefix; + omxStore->getNodePrefix([&prefix](hidl_string const& _nl) { prefix = _nl; }); + EXPECT_EQ(testing::internal::RE::PartialMatch(prefix, nodeNamePattern), true) + << "\"" << prefix << "\" is not a valid prefix for node names."; + + // Check that all node names have the said prefix. + for (const auto& node : nodeToRoles) { + EXPECT_NE(node.first.rfind(prefix, 0), std::string::npos) + << "Node \"" << node.first << "\" does not start with prefix \"" << prefix + << "\"."; + } + } } // list components and roles. @@ -143,7 +448,7 @@ TEST_P(MasterHidlTest, ListNodes) { .isOk()); ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); if (nodeList.size() == 0) - ALOGV("Warning, ComponentInfo list empty"); + std::cout << "Warning, ComponentInfo list empty" << std::endl; else { // displayComponentInfo(nodeList); for (size_t i = 0; i < nodeList.size(); i++) { From 0f9e6d56dc5829a36c7e16d25a345a11160eb2f4 Mon Sep 17 00:00:00 2001 From: Pawin Vongmasa Date: Sat, 20 Jun 2020 11:29:54 -0700 Subject: [PATCH 2/4] OMX VTS: Use GetComponentRole from OMXUtils Test: atest VtsHalMediaOmxV1_0TargetMasterTest Bug: 159410244 Change-Id: Iba2a7259ddc5fc634b22d8c5954178dede6b71d5 Merged-In: Iba2a7259ddc5fc634b22d8c5954178dede6b71d5 --- .../omx/1.0/vts/functional/common/Android.bp | 1 + .../VtsHalMediaOmxV1_0TargetMasterTest.cpp | 69 +------------------ 2 files changed, 4 insertions(+), 66 deletions(-) diff --git a/media/omx/1.0/vts/functional/common/Android.bp b/media/omx/1.0/vts/functional/common/Android.bp index 7e7463a446..3845b9f36f 100644 --- a/media/omx/1.0/vts/functional/common/Android.bp +++ b/media/omx/1.0/vts/functional/common/Android.bp @@ -74,5 +74,6 @@ cc_defaults { shared_libs: [ "libnativehelper", "libstagefright_foundation", + "libstagefright_omx_utils", ], } diff --git a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp index 9b4722ec57..4e253134c4 100644 --- a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp +++ b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp @@ -33,6 +33,7 @@ #include #include #include +#include using ::android::sp; using ::android::base::Join; @@ -87,71 +88,6 @@ void displayComponentInfo(hidl_vec& nodeList) { } } -/* - * Returns the role based on is_encoder and mime. - * - * The mapping from a pair (is_encoder, mime) to a role string is - * defined in frameworks/av/media/libmedia/MediaDefs.cpp and - * frameworks/av/media/libstagefright/omx/OMXUtils.cpp. This function - * does essentially the same work as GetComponentRole() in - * OMXUtils.cpp. - * - * Args: - * is_encoder: A boolean indicating whether the role is for an - * encoder or a decoder. - * mime: A string of the desired mime type. - * - * Returns: - * A const string for the requested role name, empty if mime is not - * recognized. - */ -const std::string getComponentRole(bool isEncoder, const std::string mime) { - // Mapping from mime types to roles. - // These values come from MediaDefs.cpp and OMXUtils.cpp - const std::map audioMimeToRole = { - {"3gpp", "amrnb"}, {"ac3", "ac3"}, {"amr-wb", "amrwb"}, - {"eac3", "eac3"}, {"flac", "flac"}, {"g711-alaw", "g711alaw"}, - {"g711-mlaw", "g711mlaw"}, {"gsm", "gsm"}, {"mp4a-latm", "aac"}, - {"mpeg", "mp3"}, {"mpeg-L1", "mp1"}, {"mpeg-L2", "mp2"}, - {"opus", "opus"}, {"raw", "raw"}, {"vorbis", "vorbis"}, - }; - const std::map videoMimeToRole = { - {"3gpp", "h263"}, {"avc", "avc"}, {"dolby-vision", "dolby-vision"}, - {"hevc", "hevc"}, {"mp4v-es", "mpeg4"}, {"mpeg2", "mpeg2"}, - {"x-vnd.on2.vp8", "vp8"}, {"x-vnd.on2.vp9", "vp9"}, - }; - const std::map imageMimeToRole = { - {"vnd.android.heic", "heic"}, - }; - - // Suffix begins after the mime prefix. - const size_t prefixEnd = mime.find("/"); - if (prefixEnd == std::string::npos || prefixEnd == mime.size()) return ""; - const std::string mime_suffix = mime.substr(prefixEnd + 1, mime.size() - 1); - const std::string middle = isEncoder ? "encoder." : "decoder."; - std::string prefix; - std::string suffix; - if (mime.rfind("audio/", 0) != std::string::npos) { - const auto it = audioMimeToRole.find(mime_suffix); - if (it == audioMimeToRole.end()) return ""; - prefix = "audio_"; - suffix = it->second; - } else if (mime.rfind("video/", 0) != std::string::npos) { - const auto it = videoMimeToRole.find(mime_suffix); - if (it == videoMimeToRole.end()) return ""; - prefix = "video_"; - suffix = it->second; - } else if (mime.rfind("image/", 0) != std::string::npos) { - const auto it = imageMimeToRole.find(mime_suffix); - if (it == imageMimeToRole.end()) return ""; - prefix = "image_"; - suffix = it->second; - } else { - return ""; - } - return prefix + middle + suffix; -} - void validateAttributes( const std::map& knownPatterns, const std::vector& unknownPatterns, @@ -328,7 +264,8 @@ TEST_P(MasterHidlTest, ListRoles) { // Make sure role name follows expected format based on type and // isEncoder - const std::string role_name = getComponentRole(role.isEncoder, role.type); + const std::string role_name( + ::android::GetComponentRole(role.isEncoder, role.type.c_str())); EXPECT_EQ(role_name, role.role) << "Role \"" << role.role << "\" does not match " << (role.isEncoder ? "an encoder " : "a decoder ") << "for mime type \"" << role.type << "."; From 3836d5584a8f4cf698e7d4cf2642fa2abd26d36d Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Wed, 29 Jul 2020 13:35:36 -0700 Subject: [PATCH 3/4] omx: rename master to store Update language to comply with Android's inclusive language guidance See https://source.android.com/setup/contribute/respectful-code for reference BUG=161896447 Change-Id: I9b1f8ed9da444024cd2fa2f3a62b6874dcd96cf7 --- media/omx/1.0/vts/functional/README.md | 8 ++++---- .../vts/functional/{master => store}/Android.bp | 4 ++-- .../VtsHalMediaOmxV1_0TargetStoreTest.cpp} | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) rename media/omx/1.0/vts/functional/{master => store}/Android.bp (87%) rename media/omx/1.0/vts/functional/{master/VtsHalMediaOmxV1_0TargetMasterTest.cpp => store/VtsHalMediaOmxV1_0TargetStoreTest.cpp} (98%) diff --git a/media/omx/1.0/vts/functional/README.md b/media/omx/1.0/vts/functional/README.md index c5a686747f..67f4aa5112 100644 --- a/media/omx/1.0/vts/functional/README.md +++ b/media/omx/1.0/vts/functional/README.md @@ -1,12 +1,12 @@ ## Omx Hal @ 1.0 tests ## --- ## Overview : -The scope of the tests presented here is not restricted solely to testing omx hal @ 1.0 API but also test to omx core functionality and to an extent omx components as well. The current directory contains the following folders: audio, common, component, master and video. Besides common all other folders contain test fixtures for testing AV decoder, encoder components. Common constitutes files that are used across by these test applications. +The scope of the tests presented here is not restricted solely to testing omx hal @ 1.0 API but also test to omx core functionality and to an extent omx components as well. The current directory contains the following folders: audio, common, component, store and video. Besides common all other folders contain test fixtures for testing AV decoder, encoder components. Common constitutes files that are used across by these test applications. -#### master : -Functionality of master is to enumerate all the omx components (and the roles it supports) available in android media framework. +#### store : +Functionality of store is to enumerate all the omx components (and the roles it supports) available in android media framework. -usage: atest VtsHalMediaOmxV1\_0TargetMasterTest +usage: atest VtsHalMediaOmxV1\_0TargetStoreTest #### component : This folder includes test fixtures that tests aspects common to all omx compatible components. For instance, port enabling/disabling, enumerating port formats, state transitions, flush, ..., stay common to all components irrespective of the service they offer. Test fixtures here are directed towards testing these (omx core). Every standard OMX compatible component is expected to pass these tests. diff --git a/media/omx/1.0/vts/functional/master/Android.bp b/media/omx/1.0/vts/functional/store/Android.bp similarity index 87% rename from media/omx/1.0/vts/functional/master/Android.bp rename to media/omx/1.0/vts/functional/store/Android.bp index 5953eb5681..28d12ffa5d 100644 --- a/media/omx/1.0/vts/functional/master/Android.bp +++ b/media/omx/1.0/vts/functional/store/Android.bp @@ -15,9 +15,9 @@ // cc_test { - name: "VtsHalMediaOmxV1_0TargetMasterTest", + name: "VtsHalMediaOmxV1_0TargetStoreTest", defaults: ["VtsHalMediaOmxV1_0Defaults"], - srcs: ["VtsHalMediaOmxV1_0TargetMasterTest.cpp"], + srcs: ["VtsHalMediaOmxV1_0TargetStoreTest.cpp"], test_suites: [ "general-tests", "vts", diff --git a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp b/media/omx/1.0/vts/functional/store/VtsHalMediaOmxV1_0TargetStoreTest.cpp similarity index 98% rename from media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp rename to media/omx/1.0/vts/functional/store/VtsHalMediaOmxV1_0TargetStoreTest.cpp index 4e253134c4..0ad06344e5 100644 --- a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp +++ b/media/omx/1.0/vts/functional/store/VtsHalMediaOmxV1_0TargetStoreTest.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#define LOG_TAG "media_omx_hidl_master_test" +#define LOG_TAG "media_omx_hidl_store_test" #ifdef __LP64__ #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS #endif @@ -55,7 +55,7 @@ using ::android::hidl::memory::V1_0::IMemory; #include #include -class MasterHidlTest : public ::testing::TestWithParam { +class StoreHidlTest : public ::testing::TestWithParam { public: virtual void SetUp() override { omxStore = IOmxStore::getService(GetParam()); @@ -127,7 +127,7 @@ void validateAttributes( } // Make sure IOmx and IOmxStore have the same set of instances. -TEST(MasterHidlTest, instanceMatchValidation) { +TEST(StoreHidlTest, instanceMatchValidation) { auto omxInstances = android::hardware::getAllHalInstanceNames(IOmx::descriptor); auto omxStoreInstances = android::hardware::getAllHalInstanceNames(IOmxStore::descriptor); ASSERT_EQ(omxInstances.size(), omxInstances.size()); @@ -138,7 +138,7 @@ TEST(MasterHidlTest, instanceMatchValidation) { } // list service attributes and verify expected formats -TEST_P(MasterHidlTest, ListServiceAttr) { +TEST_P(StoreHidlTest, ListServiceAttr) { description("list service attributes"); android::hardware::media::omx::V1_0::Status status; hidl_vec attributes; @@ -184,7 +184,7 @@ TEST_P(MasterHidlTest, ListServiceAttr) { } // get node prefix -TEST_P(MasterHidlTest, getNodePrefix) { +TEST_P(StoreHidlTest, getNodePrefix) { description("get node prefix"); hidl_string prefix; omxStore->getNodePrefix( @@ -193,7 +193,7 @@ TEST_P(MasterHidlTest, getNodePrefix) { } // list roles and validate all RoleInfo objects -TEST_P(MasterHidlTest, ListRoles) { +TEST_P(StoreHidlTest, ListRoles) { description("list roles"); hidl_vec roleList; omxStore->listRoles([&roleList](hidl_vec const& _nl) { @@ -370,7 +370,7 @@ TEST_P(MasterHidlTest, ListRoles) { } // list components and roles. -TEST_P(MasterHidlTest, ListNodes) { +TEST_P(StoreHidlTest, ListNodes) { description("enumerate component and roles"); android::hardware::media::omx::V1_0::Status status; hidl_vec nodeList; @@ -419,6 +419,6 @@ TEST_P(MasterHidlTest, ListNodes) { } INSTANTIATE_TEST_CASE_P( - PerInstance, MasterHidlTest, + PerInstance, StoreHidlTest, testing::ValuesIn(android::hardware::getAllHalInstanceNames(IOmxStore::descriptor)), android::hardware::PrintInstanceNameToString); From 237e3d7ffc5cd41a439ab878295ad38023c7dc90 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Wed, 29 Jul 2020 13:35:36 -0700 Subject: [PATCH 4/4] omx vts: update language to comply with Android's inclusive language guidance See https://source.android.com/setup/contribute/respectful-code for reference BUG=161896447 Change-Id: I0ced401233497bbbfce90e9b84147bb08399e421 --- .../common/media_hidl_test_common.cpp | 4 ++-- .../functional/common/media_hidl_test_common.h | 4 ++-- .../VtsHalMediaOmxV1_0TargetVideoEncTest.cpp | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp index d9d11571c4..a507eeadb3 100644 --- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp +++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp @@ -785,8 +785,8 @@ const std::vector>& getTestPar for (IOmx::ComponentInfo info : componentInfos) { for (std::string role : info.mRoles) { if (filter.empty()) { - if (kWhiteListRoles.find(role.c_str()) == kWhiteListRoles.end()) { - // This is for component test and the role is not in the white list. + if (kKnownRoles.find(role.c_str()) == kKnownRoles.end()) { + // This is for component test and the role is not supported. continue; } } else if (role.find(filter) == std::string::npos) { diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h index bb03dd0341..02c42c195d 100644 --- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h +++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h @@ -78,8 +78,8 @@ enum bufferOwner { unknown, }; -// White list audio/video roles to be tested. -static std::set kWhiteListRoles{ +// List known and thus tested audio/video roles. +static std::set kKnownRoles{ "audio_encoder.aac", "audio_encoder.amrnb", "audio_encoder.amrwb", "audio_encoder.flac", "audio_decoder.aac", "audio_decoder.amrnb", "audio_decoder.amrwb", "audio_decoder.flac", "audio_decoder.g711alaw", diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp index 397bee6464..5105d53f92 100644 --- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp +++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp @@ -289,11 +289,11 @@ struct CodecProducerListener : public IProducerListener { }; // Mock IOmxBufferSource class. GraphicBufferSource.cpp in libstagefright/omx/ -// implements this class. Below is dummy class introduced to test if callback +// implements this class. Below class is introduced to test if callback // functions are actually being called or not -struct DummyBufferSource : public IOmxBufferSource { +struct MockBufferSource : public IOmxBufferSource { public: - DummyBufferSource(sp node) { + MockBufferSource(sp node) { callback = 0; executing = false; omxNode = node; @@ -311,7 +311,7 @@ struct DummyBufferSource : public IOmxBufferSource { android::Vector iBuffer, oBuffer; }; -Return DummyBufferSource::onOmxExecuting() { +Return MockBufferSource::onOmxExecuting() { executing = true; callback |= 0x1; size_t index; @@ -332,25 +332,25 @@ Return DummyBufferSource::onOmxExecuting() { return Void(); }; -Return DummyBufferSource::onOmxIdle() { +Return MockBufferSource::onOmxIdle() { callback |= 0x2; executing = false; return Void(); }; -Return DummyBufferSource::onOmxLoaded() { +Return MockBufferSource::onOmxLoaded() { callback |= 0x4; return Void(); }; -Return DummyBufferSource::onInputBufferAdded(uint32_t buffer) { +Return MockBufferSource::onInputBufferAdded(uint32_t buffer) { (void)buffer; EXPECT_EQ(executing, false); callback |= 0x8; return Void(); }; -Return DummyBufferSource::onInputBufferEmptied( +Return MockBufferSource::onInputBufferEmptied( uint32_t buffer, const ::android::hardware::hidl_handle& fence) { (void)fence; callback |= 0x10; @@ -1143,7 +1143,7 @@ TEST_P(VideoEncHidlTest, BufferSourceCallBacks) { setupRAWPort(omxNode, kPortIndexInput, nFrameWidth, nFrameHeight, 0, xFramerate, eColorFormat); - sp buffersource = new DummyBufferSource(omxNode); + sp buffersource = new MockBufferSource(omxNode); ASSERT_NE(buffersource, nullptr); status = omxNode->setInputSurface(buffersource); ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);