Adding swiftshader unittests to chromium
Chromium does not allow any third_party code to depend on base,
so the main test runner for swiftshader's tests in chromium can't
live inside the swiftshader repo. To solve this:
1) Added a test environment for swiftshader that will be used
for testing in chromium. Currently, it is simply empty.
2) Split unit tests in 2 files, unittests.cpp, which will
contain the tests ran by both chromium and swiftshader and
main.cpp, which will be used as the swiftshader test runner,
but NOT as the chromium test runner (that one will be added
in chromium at the same time I do the swiftshader update).
3) The BUILD.gn file was updated to make the chromium version
of the test depend on base and on the chromium version of the
swiftshader test runner (swiftshader_tests_main.cc, to be added).
Change-Id: I1128bb482565908bc285dcd6818d90d1d881a50e
Reviewed-on: https://swiftshader-review.googlesource.com/8409
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/tests/unittests/BUILD.gn b/tests/unittests/BUILD.gn
index 1df1063..e0ab454 100644
--- a/tests/unittests/BUILD.gn
+++ b/tests/unittests/BUILD.gn
@@ -18,10 +18,14 @@
deps = [
"../../src/OpenGL/libEGL:swiftshader_libEGL",
"../../src/OpenGL/libGLESv2:swiftshader_libGLESv2",
+ "//base",
+ "//base/test:test_support",
+ "//testing/gmock",
"//testing/gtest",
]
sources = [
- "main.cpp",
+ "//gpu/swiftshader_tests_main.cc",
+ "unittests.cpp",
]
}
diff --git a/tests/unittests/SwiftShaderTest.h b/tests/unittests/SwiftShaderTest.h
new file mode 100644
index 0000000..cc12096
--- /dev/null
+++ b/tests/unittests/SwiftShaderTest.h
@@ -0,0 +1,26 @@
+// Copyright 2017 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.
+
+#ifndef SWIFTSHADER_TEST_H_
+#define SWIFTSHADER_TEST_H_
+
+#include <gtest/gtest.h>
+
+class SwiftShaderTestEnvironment : public testing::Environment {
+ public:
+ void SetUp() override {}
+ void TearDown() override {}
+};
+
+#endif // SWIFTSHADER_TEST_H_
diff --git a/tests/unittests/main.cpp b/tests/unittests/main.cpp
index 1c29645..8f7e13f 100644
--- a/tests/unittests/main.cpp
+++ b/tests/unittests/main.cpp
@@ -1,4 +1,4 @@
-// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
+// Copyright 2017 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.
@@ -14,11 +14,6 @@
#include "gtest/gtest.h"
-TEST(SwiftShaderCompilationOnly, Unit)
-{
- // Empty test to trigger compilation of SwiftShader on build bots
-}
-
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
diff --git a/tests/unittests/unittests.cpp b/tests/unittests/unittests.cpp
new file mode 100644
index 0000000..a454801
--- /dev/null
+++ b/tests/unittests/unittests.cpp
@@ -0,0 +1,19 @@
+// Copyright 2017 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.
+
+#include "gtest/gtest.h"
+
+TEST(SwiftShaderCompilationOnly, Unit) {
+ // Empty test to trigger compilation of SwiftShader on build bots
+}
diff --git a/tests/unittests/unittests.vcxproj b/tests/unittests/unittests.vcxproj
index eb1bfbc..72efcd0 100644
--- a/tests/unittests/unittests.vcxproj
+++ b/tests/unittests/unittests.vcxproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@@ -160,6 +160,7 @@
<ItemGroup>
<ClCompile Include="..\..\third_party\googletest\googletest\src\gtest-all.cc" />
<ClCompile Include="main.cpp" />
+ <ClCompile Include="unittests.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/tests/unittests/unittests.vcxproj.filters b/tests/unittests/unittests.vcxproj.filters
index 0b08fc8..313501f 100644
--- a/tests/unittests/unittests.vcxproj.filters
+++ b/tests/unittests/unittests.vcxproj.filters
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
@@ -11,10 +11,13 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="main.cpp">
+ <ClCompile Include="..\..\third_party\googletest\googletest\src\gtest-all.cc">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\third_party\googletest\googletest\src\gtest-all.cc">
+ <ClCompile Include="unittests.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>