[Libva] [PATCH intel-driver 2/5] test: add more convenience macros and wrap VAStatus
U. Artie Eoff
ullysses.a.eoff at intel.com
Wed Sep 7 20:43:35 UTC 2016
Add some more convenience test macros and wrap the
VAStatus in a class so that it can be streamed by its
name instead of its value by the gtest framework.
Signed-off-by: U. Artie Eoff <ullysses.a.eoff at intel.com>
---
test/test.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 107 insertions(+), 2 deletions(-)
diff --git a/test/test.h b/test/test.h
index 90e74246110b..afca9a5ed2d6 100644
--- a/test/test.h
+++ b/test/test.h
@@ -26,13 +26,21 @@
#define TEST_H
#include <gtest/gtest.h>
+#include <iostream>
+#include <string>
#include <va/va.h>
#define EXPECT_STATUS(status) \
- EXPECT_EQ(VA_STATUS_SUCCESS, (status))
+ EXPECT_EQ(VaapiStatus(VA_STATUS_SUCCESS), VaapiStatus(status))
#define ASSERT_STATUS(status) \
- ASSERT_EQ(VA_STATUS_SUCCESS, (status))
+ ASSERT_EQ(VaapiStatus(VA_STATUS_SUCCESS), VaapiStatus(status))
+
+#define EXPECT_STATUS_EQ(expect, status) \
+ EXPECT_EQ(VaapiStatus(expect), VaapiStatus(status))
+
+#define ASSERT_STATUS_EQ(expect, status) \
+ ASSERT_EQ(VaapiStatus(expect), VaapiStatus(status))
#define EXPECT_ID(id) \
EXPECT_NE(VA_INVALID_ID, (id))
@@ -40,6 +48,12 @@
#define ASSERT_ID(id) \
ASSERT_NE(VA_INVALID_ID, (id))
+#define EXPECT_INVALID_ID(id) \
+ EXPECT_EQ(VA_INVALID_ID, (id))
+
+#define ASSERT_INVALID_ID(id) \
+ ASSERT_EQ(VA_INVALID_ID, (id))
+
#define EXPECT_PTR(ptr) \
EXPECT_FALSE(NULL == (ptr))
@@ -47,6 +61,97 @@
ASSERT_FALSE(NULL == (ptr))
#define EXPECT_PTR_NULL(ptr) \
+ EXPECT_TRUE(NULL == (ptr))
+
+#define ASSERT_PTR_NULL(ptr) \
ASSERT_TRUE(NULL == (ptr))
+class VaapiStatus
+{
+public:
+ explicit VaapiStatus(VAStatus status)
+ : m_status(status)
+ { }
+
+ bool operator ==(const VaapiStatus& other) const
+ {
+ return m_status == other.m_status;
+ }
+
+ friend std::ostream& operator <<(std::ostream& os, const VaapiStatus& t)
+ {
+ std::string status;
+ switch(t.m_status) {
+ case VA_STATUS_SUCCESS:
+ status = "VA_STATUS_SUCCESS"; break;
+ case VA_STATUS_ERROR_OPERATION_FAILED:
+ status = "VA_STATUS_ERROR_OPERATION_FAILED"; break;
+ case VA_STATUS_ERROR_ALLOCATION_FAILED:
+ status = "VA_STATUS_ERROR_ALLOCATION_FAILED"; break;
+ case VA_STATUS_ERROR_INVALID_DISPLAY:
+ status = "VA_STATUS_ERROR_INVALID_DISPLAY"; break;
+ case VA_STATUS_ERROR_INVALID_CONFIG:
+ status = "VA_STATUS_ERROR_INVALID_CONFIG"; break;
+ case VA_STATUS_ERROR_INVALID_CONTEXT:
+ status = "VA_STATUS_ERROR_INVALID_CONTEXT"; break;
+ case VA_STATUS_ERROR_INVALID_SURFACE:
+ status = "VA_STATUS_ERROR_INVALID_SURFACE"; break;
+ case VA_STATUS_ERROR_INVALID_BUFFER:
+ status = "VA_STATUS_ERROR_INVALID_BUFFER"; break;
+ case VA_STATUS_ERROR_INVALID_IMAGE:
+ status = "VA_STATUS_ERROR_INVALID_IMAGE"; break;
+ case VA_STATUS_ERROR_INVALID_SUBPICTURE:
+ status = "VA_STATUS_ERROR_INVALID_SUBPICTURE"; break;
+ case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
+ status = "VA_STATUS_ERROR_ATTR_NOT_SUPPORTED"; break;
+ case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
+ status = "VA_STATUS_ERROR_MAX_NUM_EXCEEDED"; break;
+ case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
+ status = "VA_STATUS_ERROR_UNSUPPORTED_PROFILE"; break;
+ case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
+ status = "VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT"; break;
+ case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
+ status = "VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT"; break;
+ case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
+ status = "VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE"; break;
+ case VA_STATUS_ERROR_SURFACE_BUSY:
+ status = "VA_STATUS_ERROR_SURFACE_BUSY"; break;
+ case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
+ status = "VA_STATUS_ERROR_FLAG_NOT_SUPPORTED"; break;
+ case VA_STATUS_ERROR_INVALID_PARAMETER:
+ status = "VA_STATUS_ERROR_INVALID_PARAMETER"; break;
+ case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
+ status = "VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED"; break;
+ case VA_STATUS_ERROR_UNIMPLEMENTED:
+ status = "VA_STATUS_ERROR_UNIMPLEMENTED"; break;
+ case VA_STATUS_ERROR_SURFACE_IN_DISPLAYING:
+ status = "VA_STATUS_ERROR_SURFACE_IN_DISPLAYING"; break;
+ case VA_STATUS_ERROR_INVALID_IMAGE_FORMAT:
+ status = "VA_STATUS_ERROR_INVALID_IMAGE_FORMAT"; break;
+ case VA_STATUS_ERROR_DECODING_ERROR:
+ status = "VA_STATUS_ERROR_DECODING_ERROR"; break;
+ case VA_STATUS_ERROR_ENCODING_ERROR:
+ status = "VA_STATUS_ERROR_ENCODING_ERROR"; break;
+ case VA_STATUS_ERROR_INVALID_VALUE:
+ status = "VA_STATUS_ERROR_INVALID_VALUE"; break;
+ case VA_STATUS_ERROR_UNSUPPORTED_FILTER:
+ status = "VA_STATUS_ERROR_UNSUPPORTED_FILTER"; break;
+ case VA_STATUS_ERROR_INVALID_FILTER_CHAIN:
+ status = "VA_STATUS_ERROR_INVALID_FILTER_CHAIN"; break;
+ case VA_STATUS_ERROR_HW_BUSY:
+ status = "VA_STATUS_ERROR_HW_BUSY"; break;
+ case VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE:
+ status = "VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE"; break;
+ case VA_STATUS_ERROR_UNKNOWN:
+ status = "VA_STATUS_ERROR_UNKNOWN"; break;
+ default:
+ status = "Unknown VAStatus";
+ }
+ os << status;
+ return os;
+ }
+
+ VAStatus m_status;
+};
+
#endif // TEST_H
--
2.1.0
More information about the Libva
mailing list