summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2016-10-03 13:21:30 -0700
committerSean V Kelley <seanvk@posteo.de>2016-10-04 14:09:00 -0700
commit0c5176a46e329e3d95f14f998b75a320621c769e (patch)
tree42fb62608d502e0d9115bc4db9a76004c826568c /test
parent0287ca6f3871d202624ddbea97a4b3771e982e68 (diff)
test: add create surface test
Add test to verify correct result for create surfaces with supported and unsupported pixel formats. Currently the IYUV pixel format case fails... see https://bugs.freedesktop.org/show_bug.cgi?id=98033 Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com> Reviewed-by: Sean V Kelley <seanvk@posteo.de>
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am1
-rw-r--r--test/i965_surface_test.cpp120
-rw-r--r--test/test.h1
3 files changed, 122 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 99560f8..7d1ba43 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -58,6 +58,7 @@ test_i965_drv_video_SOURCES = \
i965_test_fixture.cpp \
i965_jpeg_decode_test.cpp \
i965_jpeg_encode_test.cpp \
+ i965_surface_test.cpp \
object_heap_test.cpp \
test_main.cpp \
$(NULL)
diff --git a/test/i965_surface_test.cpp b/test/i965_surface_test.cpp
new file mode 100644
index 0000000..10539ce
--- /dev/null
+++ b/test/i965_surface_test.cpp
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2016 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "i965_test_fixture.h"
+
+#include <algorithm>
+#include <set>
+
+static const std::set<unsigned> pixelFormats = {
+ /** Defined in va/va.h **/
+ VA_FOURCC_NV12, VA_FOURCC_AI44, VA_FOURCC_RGBA, VA_FOURCC_RGBX,
+ VA_FOURCC_BGRA, VA_FOURCC_BGRX, VA_FOURCC_ARGB, VA_FOURCC_XRGB,
+ VA_FOURCC_ABGR, VA_FOURCC_XBGR, VA_FOURCC_UYVY, VA_FOURCC_YUY2,
+ VA_FOURCC_AYUV, VA_FOURCC_NV11, VA_FOURCC_YV12, VA_FOURCC_P208,
+ VA_FOURCC_IYUV, VA_FOURCC_YV24, VA_FOURCC_YV32, VA_FOURCC_Y800,
+ VA_FOURCC_IMC3, VA_FOURCC_411P, VA_FOURCC_422H, VA_FOURCC_422V,
+ VA_FOURCC_444P, VA_FOURCC_RGBP, VA_FOURCC_BGRP, VA_FOURCC_411R,
+ VA_FOURCC_YV16, VA_FOURCC_P010, VA_FOURCC_P016,
+
+ /** Defined in i965_fourcc.h **/
+ VA_FOURCC_I420, VA_FOURCC_IA44, VA_FOURCC_IA88, VA_FOURCC_AI88,
+ VA_FOURCC_IMC1, VA_FOURCC_YVY2,
+
+ /** Bogus pixel formats **/
+ VA_FOURCC('B','E','E','F'), VA_FOURCC('P','O','R','K'),
+ VA_FOURCC('F','I','S','H'),
+};
+
+class CreateSurfacesTest
+ : public I965TestFixture
+{
+protected:
+ const std::set<unsigned> supported = {
+ VA_FOURCC_NV12, VA_FOURCC_I420, VA_FOURCC_IYUV, VA_FOURCC_IMC3,
+ VA_FOURCC_YV12, VA_FOURCC_IMC1, VA_FOURCC_P010, VA_FOURCC_422H,
+ VA_FOURCC_422V, VA_FOURCC_YV16, VA_FOURCC_YUY2, VA_FOURCC_UYVY,
+ VA_FOURCC_444P, VA_FOURCC_411P, VA_FOURCC_Y800, VA_FOURCC_RGBA,
+ VA_FOURCC_RGBX, VA_FOURCC_BGRA, VA_FOURCC_BGRX,
+ };
+};
+
+TEST_F(CreateSurfacesTest, SupportedPixelFormats)
+{
+ SurfaceAttribs attributes(1);
+ attributes.front().flags = VA_SURFACE_ATTRIB_SETTABLE;
+ attributes.front().type = VASurfaceAttribPixelFormat;
+ attributes.front().value.type = VAGenericValueTypeInteger;
+
+ for (const unsigned fourcc : supported) {
+ SCOPED_TRACE(
+ ::testing::Message()
+ << std::string(reinterpret_cast<const char*>(&fourcc), 4)
+ << "(0x" << std::hex << fourcc << std::dec << ")");
+
+ const i965_fourcc_info *info = get_fourcc_info(fourcc);
+ EXPECT_PTR(info);
+ EXPECT_TRUE(info->flag & 1);
+
+ attributes.front().value.value.i = fourcc;
+ Surfaces surfaces = createSurfaces(
+ 10, 10, VA_RT_FORMAT_YUV420, 1, attributes);
+ destroySurfaces(surfaces);
+ }
+}
+
+TEST_F(CreateSurfacesTest, UnsupportedPixelFormats)
+{
+ SurfaceAttribs attributes(1);
+ attributes.front().flags = VA_SURFACE_ATTRIB_SETTABLE;
+ attributes.front().type = VASurfaceAttribPixelFormat;
+ attributes.front().value.type = VAGenericValueTypeInteger;
+
+ std::set<unsigned> unsupported;
+ std::set_difference(pixelFormats.begin(), pixelFormats.end(),
+ supported.begin(), supported.end(),
+ std::inserter(unsupported, unsupported.begin()));
+
+ EXPECT_EQ(pixelFormats.size() - supported.size(), unsupported.size());
+
+ for (const unsigned fourcc : unsupported) {
+ SCOPED_TRACE(
+ ::testing::Message()
+ << std::string(reinterpret_cast<const char*>(&fourcc), 4)
+ << "(0x" << std::hex << fourcc << std::dec << ")");
+
+ const i965_fourcc_info *info = get_fourcc_info(fourcc);
+ EXPECT_FALSE(info ? info->flag & 1 : false);
+
+ attributes.front().value.value.i = fourcc;
+ Surfaces surfaces;
+ EXPECT_NONFATAL_FAILURE(
+ surfaces = createSurfaces(
+ 10, 10, VA_RT_FORMAT_YUV420, 1, attributes),
+ "VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT"
+ );
+ EXPECT_NONFATAL_FAILURE(
+ destroySurfaces(surfaces), "VA_STATUS_ERROR_INVALID_SURFACE");
+ }
+}
diff --git a/test/test.h b/test/test.h
index 000284a..5d3fdc8 100644
--- a/test/test.h
+++ b/test/test.h
@@ -26,6 +26,7 @@
#define TEST_H
#include <gtest/gtest.h>
+#include <gtest/gtest-spi.h> // for EXPECT_FATAL_FAILURE/EXPECT_NONFATAL_FAILURE
#include <iostream>
#include <string>
#include <va/va.h>