mirror of https://github.com/intel/libva-utils.git
test/fixture: consolidate config methods
Define 4 new config methods that provide the functionality of the existing 11 similar methods. The usage of the existing methods will be replaced by the new methods in successive commits. These new methods will also give control back to the test cases to handle config attributes depending on need/use-case and reduce the number fixture member variables needed. Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
This commit is contained in:
parent
ebe0e519d5
commit
c17bbc0820
|
@ -185,6 +185,103 @@ bool VAAPIFixture::doFindEntrypointInList(const VAEntrypoint& entrypoint) const
|
|||
!= m_entrypointList.end();
|
||||
}
|
||||
|
||||
void VAAPIFixture::getConfigAttributes(const VAProfile& profile,
|
||||
const VAEntrypoint& entrypoint, ConfigAttributes& attribs,
|
||||
const VAStatus& expectation) const
|
||||
{
|
||||
const bool defaults(attribs.empty());
|
||||
|
||||
if (defaults) {
|
||||
// fill config attributes with default config attributes
|
||||
const auto op = [](const VAConfigAttribType& t) {
|
||||
return VAConfigAttrib{type: t, value: VA_ATTRIB_NOT_SUPPORTED};
|
||||
};
|
||||
std::transform(g_vaConfigAttribTypes.begin(),
|
||||
g_vaConfigAttribTypes.end(), std::back_inserter(attribs), op);
|
||||
}
|
||||
|
||||
ASSERT_FALSE(attribs.empty());
|
||||
|
||||
EXPECT_STATUS_EQ(
|
||||
expectation,
|
||||
vaGetConfigAttributes(
|
||||
m_vaDisplay, profile, entrypoint, attribs.data(), attribs.size()));
|
||||
|
||||
if (defaults) {
|
||||
// remove unsupported config attributes
|
||||
const auto begin(attribs.begin());
|
||||
const auto end(attribs.end());
|
||||
const auto predicate = [](const VAConfigAttrib& a) {
|
||||
return a.value == VA_ATTRIB_NOT_SUPPORTED;
|
||||
};
|
||||
attribs.erase(std::remove_if(begin, end, predicate), end);
|
||||
}
|
||||
}
|
||||
|
||||
void VAAPIFixture::createConfig(const VAProfile& profile,
|
||||
const VAEntrypoint& entrypoint, const ConfigAttributes& attribs,
|
||||
const VAStatus& expectation)
|
||||
{
|
||||
ASSERT_INVALID_ID(m_configID)
|
||||
<< "test logic error: did you forget to call destroyConfig?";
|
||||
|
||||
EXPECT_STATUS_EQ(
|
||||
expectation,
|
||||
vaCreateConfig(m_vaDisplay, profile, entrypoint,
|
||||
(attribs.size() != 0 ?
|
||||
const_cast<VAConfigAttrib*>(attribs.data()) : NULL),
|
||||
attribs.size(), &m_configID))
|
||||
<< "profile = " << profile << std::endl
|
||||
<< "entrypoint = " << entrypoint << std::endl
|
||||
<< "numAttribs = " << attribs.size();
|
||||
|
||||
if (expectation == VA_STATUS_SUCCESS) {
|
||||
EXPECT_ID(m_configID);
|
||||
} else {
|
||||
EXPECT_INVALID_ID(m_configID);
|
||||
}
|
||||
}
|
||||
|
||||
void VAAPIFixture::queryConfigAttributes(
|
||||
const VAProfile& expectedProfile, const VAEntrypoint& expectedEntrypoint,
|
||||
ConfigAttributes& attributes, const VAStatus& expectedStatus) const
|
||||
{
|
||||
VAProfile actualProfile;
|
||||
VAEntrypoint actualEntrypoint;
|
||||
int numAttributes(0);
|
||||
|
||||
ASSERT_TRUE(attributes.empty())
|
||||
<< "test logic error: attributes must be empty";
|
||||
|
||||
attributes.resize(m_maxConfigAttributes);
|
||||
|
||||
EXPECT_STATUS_EQ(
|
||||
expectedStatus,
|
||||
vaQueryConfigAttributes(m_vaDisplay, m_configID, &actualProfile,
|
||||
&actualEntrypoint, attributes.data(), &numAttributes));
|
||||
|
||||
if (expectedStatus == VA_STATUS_SUCCESS) {
|
||||
EXPECT_EQ(expectedProfile, actualProfile);
|
||||
EXPECT_EQ(expectedEntrypoint, actualEntrypoint);
|
||||
ASSERT_GT(numAttributes, 0);
|
||||
|
||||
attributes.resize(numAttributes);
|
||||
|
||||
// reported config attributes should be supported
|
||||
for (const auto& attribute : attributes) {
|
||||
EXPECT_NE(VA_ATTRIB_NOT_SUPPORTED, attribute.value);
|
||||
}
|
||||
} else {
|
||||
attributes.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void VAAPIFixture::destroyConfig(const VAStatus& expectation)
|
||||
{
|
||||
EXPECT_STATUS_EQ(expectation, vaDestroyConfig(m_vaDisplay, m_configID));
|
||||
m_configID = VA_INVALID_ID;
|
||||
}
|
||||
|
||||
void VAAPIFixture::doFillConfigAttribList()
|
||||
{
|
||||
m_configAttribList.clear();
|
||||
|
|
|
@ -85,6 +85,15 @@ public:
|
|||
|
||||
void doLogSkipTest(const VAProfile&, const VAEntrypoint&) const;
|
||||
|
||||
void getConfigAttributes(const VAProfile&, const VAEntrypoint&,
|
||||
ConfigAttributes&, const VAStatus& = VA_STATUS_SUCCESS) const;
|
||||
void createConfig(const VAProfile&, const VAEntrypoint&,
|
||||
const ConfigAttributes& = ConfigAttributes(),
|
||||
const VAStatus& = VA_STATUS_SUCCESS);
|
||||
void queryConfigAttributes(const VAProfile&, const VAEntrypoint&,
|
||||
ConfigAttributes&, const VAStatus& = VA_STATUS_SUCCESS) const;
|
||||
void destroyConfig(const VAStatus& = VA_STATUS_SUCCESS);
|
||||
|
||||
protected:
|
||||
// You can remove any or all of the following functions if its body
|
||||
// is empty.
|
||||
|
|
Loading…
Reference in New Issue