Commit 31b18a0e by Nicolas Capens

Add EGL initialization unit test.

This test verifies that the swiftshader EGL libraries exists, can be loaded, has its entry functions accessible, and we get the expected vendor/version strings. Change-Id: Ifc29286cfaa83fa4c2412c073d383f2c1b58766f Reviewed-on: https://swiftshader-review.googlesource.com/9168Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 50eaee7e
# Copyright 2016 The SwiftShader Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//testing/test.gni")
test("swiftshader_unittests") {
deps = [
"../../src/OpenGL/libEGL:swiftshader_libEGL",
"../../src/OpenGL/libGLESv2:swiftshader_libGLESv2",
"//base",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
]
sources = [
"//gpu/swiftshader_tests_main.cc",
"unittests.cpp",
]
}
# Copyright 2016 The SwiftShader Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//testing/test.gni")
test("swiftshader_unittests") {
deps = [
"//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL",
"//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2",
"//base",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
]
sources = [
"//gpu/swiftshader_tests_main.cc",
"unittests.cpp",
]
include_dirs = [
"../../include", # Khronos headers
]
# Make sure we're loading SwiftShader's libraries, not ANGLE's or the system
# provided ones. On Windows an explicit LoadLibrary("swiftshader\lib*.dll")
# is required before making the first EGL or OpenGL ES call.
if (is_win) {
ldflags = [
"/DELAYLOAD:libEGL.dll",
"/DELAYLOAD:libGLESv2.dll",
]
} else if (is_mac) {
ldflags = [
"-Wl,-install_name,@rpath/\$ORIGIN/swiftshader",
]
} else {
ldflags = [
"-Wl,-rpath=\$ORIGIN/swiftshader",
]
}
}
// These are not the headers you're looking for
#error "Missing googletest submodule. Run git submodule update --init"
\ No newline at end of file
......@@ -13,7 +13,61 @@
// limitations under the License.
#include "gtest/gtest.h"
#include "gmock/gmock.h"
TEST(SwiftShaderCompilationOnly, Unit) {
// Empty test to trigger compilation of SwiftShader on build bots
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#if defined(_WIN32)
#include <Windows.h>
#endif
class SwiftShaderTest : public testing::Test
{
protected:
void SetUp() override
{
#if defined(_WIN32)
// The DLLs are delay loaded (see BUILD.gn), so we can load
// the correct ones from the swiftshader subdirectory.
HMODULE libEGL = LoadLibraryA("swiftshader\\libEGL.dll");
EXPECT_NE(NULL, libEGL);
HMODULE libGLESv2 = LoadLibraryA("swiftshader\\libGLESv2.dll");
EXPECT_NE(NULL, libGLESv2);
#endif
}
};
TEST_F(SwiftShaderTest, CompilationOnly)
{
// Empty test to trigger compilation of SwiftShader on build bots
}
TEST_F(SwiftShaderTest, Initalization)
{
EXPECT_EQ(EGL_SUCCESS, eglGetError());
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_NE(EGL_NO_DISPLAY, display);
eglQueryString(display, EGL_VENDOR);
EXPECT_EQ(EGL_NOT_INITIALIZED, eglGetError());
EGLint major;
EGLint minor;
EGLBoolean initialized = eglInitialize(display, &major, &minor);
EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_EQ((EGLBoolean)EGL_TRUE, initialized);
EXPECT_EQ(1, major);
EXPECT_EQ(4, minor);
const char *vendor = eglQueryString(display, EGL_VENDOR);
EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_STREQ("Google Inc.", vendor);
const char *version = eglQueryString(display, EGL_VERSION);
EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_THAT(version, testing::HasSubstr("1.4 SwiftShader "));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment