test: refactor skip test semantics
Allow custom skip test message.
Basic checks to determine whether a test should be
skipped could fail (e.g. query profiles/entrypoints
to determine if test should be skipped). Thus, don't
log test as skipped if there are any failures before
the test fixture destructs.
Fixes #99
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
diff --git a/test/test_va_api_config_attribs.cpp b/test/test_va_api_config_attribs.cpp
index 4ba08d2..b9e7c92 100644
--- a/test/test_va_api_config_attribs.cpp
+++ b/test/test_va_api_config_attribs.cpp
@@ -107,7 +107,7 @@
// vaGetConfigAttributes.
if (not isSupported(profile, entrypoint)) {
- doLogSkipTest(profile, entrypoint);
+ skipTest(profile, entrypoint);
return;
}
diff --git a/test/test_va_api_createbuffer.cpp b/test/test_va_api_createbuffer.cpp
index df730cd..4e3b1c2 100644
--- a/test/test_va_api_createbuffer.cpp
+++ b/test/test_va_api_createbuffer.cpp
@@ -177,7 +177,7 @@
// them to a VAConfigID.
if (not isSupported(profile, entrypoint)) {
- doLogSkipTest(profile, entrypoint);
+ skipTest(profile, entrypoint);
return;
}
diff --git a/test/test_va_api_createcontext.cpp b/test/test_va_api_createcontext.cpp
index 9e6f099..5fc06aa 100644
--- a/test/test_va_api_createcontext.cpp
+++ b/test/test_va_api_createcontext.cpp
@@ -76,7 +76,7 @@
// supported profile and entrypoint
if (not isSupported(profile, entrypoint)) {
- doLogSkipTest(profile, entrypoint);
+ skipTest(profile, entrypoint);
return;
}
diff --git a/test/test_va_api_createsurfaces.cpp b/test/test_va_api_createsurfaces.cpp
index 76f4c50..754de8e 100644
--- a/test/test_va_api_createsurfaces.cpp
+++ b/test/test_va_api_createsurfaces.cpp
@@ -155,7 +155,7 @@
TEST_P(VAAPIQuerySurfaces, QuerySurfacesWithConfigAttribs)
{
if (not isSupported(profile, entrypoint)) {
- doLogSkipTest(profile, entrypoint);
+ skipTest(profile, entrypoint);
return;
}
@@ -170,7 +170,7 @@
TEST_P(VAAPIQuerySurfaces, QuerySurfacesNoConfigAttribs)
{
if (not isSupported(profile, entrypoint)) {
- doLogSkipTest(profile, entrypoint);
+ skipTest(profile, entrypoint);
return;
}
@@ -208,7 +208,7 @@
TEST_P(VAAPICreateSurfaces, CreateSurfacesWithConfigAttribs)
{
if (not isSupported(profile, entrypoint)) {
- doLogSkipTest(profile, entrypoint);
+ skipTest(profile, entrypoint);
return;
}
@@ -241,7 +241,7 @@
TEST_P(VAAPICreateSurfaces, CreateSurfacesNoConfigAttrib)
{
if (not isSupported(profile, entrypoint)) {
- doLogSkipTest(profile, entrypoint);
+ skipTest(profile, entrypoint);
return;
}
@@ -259,7 +259,7 @@
TEST_P(VAAPICreateSurfaces, CreateSurfacesNoAttrib)
{
if (not isSupported(profile, entrypoint)) {
- doLogSkipTest(profile, entrypoint);
+ skipTest(profile, entrypoint);
return;
}
diff --git a/test/test_va_api_fixture.cpp b/test/test_va_api_fixture.cpp
index 423e2e8..56319b4 100644
--- a/test/test_va_api_fixture.cpp
+++ b/test/test_va_api_fixture.cpp
@@ -43,6 +43,7 @@
, m_configID(VA_INVALID_ID)
, m_contextID(VA_INVALID_ID)
, m_bufferID(VA_INVALID_ID)
+ , m_skip("")
{
return;
}
@@ -59,6 +60,15 @@
unsetenv("LIBVA_DRIVER_NAME");
if (m_restoreDriverName)
setenv("LIBVA_DRIVER_NAME", m_restoreDriverName, 1);
+
+ if (not m_skip.empty()) {
+ EXPECT_FALSE(HasFailure())
+ << "skip message is set, but something failed";
+ if (not HasFailure()) {
+ RecordProperty("skipped", true);
+ std::cout << "[ SKIPPED ] " << m_skip << std::endl;
+ }
+ }
}
VADisplay VAAPIFixture::getDisplay()
@@ -436,13 +446,22 @@
EXPECT_STATUS(vaTerminate(m_vaDisplay));
}
-void VAAPIFixture::doLogSkipTest(const VAProfile& profile,
- const VAEntrypoint& entrypoint) const
+void VAAPIFixture::skipTest(const std::string& message)
{
- RecordProperty("skipped", true);
- std::cout << "[ SKIPPED ]"
- << " " << profile << " / " << entrypoint
- << " not supported on this hardware" << std::endl;
+ ASSERT_FALSE(message.empty())
+ << "test logic error: skip message cannot be empty";
+ ASSERT_TRUE(m_skip.empty())
+ << "test logic error: test already marked as skipped";
+
+ m_skip = message;
+}
+
+void VAAPIFixture::skipTest(const VAProfile& profile,
+ const VAEntrypoint& entrypoint)
+{
+ std::ostringstream oss;
+ oss << profile << " / " << entrypoint << " not supported on this hardware";
+ skipTest(oss.str());
}
TEST_F(VAAPIFixture, getDisplay)
diff --git a/test/test_va_api_fixture.h b/test/test_va_api_fixture.h
index 1b57dc1..4f711b8 100644
--- a/test/test_va_api_fixture.h
+++ b/test/test_va_api_fixture.h
@@ -47,8 +47,6 @@
const VAStatus& expectation = VA_STATUS_SUCCESS);
void doDestroyContext(const VAStatus& expectation = VA_STATUS_SUCCESS);
- void doLogSkipTest(const VAProfile&, const VAEntrypoint&) const;
-
void queryConfigProfiles(Profiles&) const;
void queryConfigEntrypoints(const VAProfile&, Entrypoints&,
const VAStatus& = VA_STATUS_SUCCESS) const;
@@ -75,6 +73,9 @@
const VAStatus& = VA_STATUS_SUCCESS);
void destroyBuffer(const VAStatus& = VA_STATUS_SUCCESS);
+ void skipTest(const std::string& message);
+ void skipTest(const VAProfile&, const VAEntrypoint&);
+
protected:
// You can remove any or all of the following functions if its body
// is empty.
@@ -106,6 +107,8 @@
VAConfigID m_configID;
VAContextID m_contextID;
VABufferID m_bufferID;
+
+ std::string m_skip;
};
} // namespace VAAPI