Commit 228b05da by Nicolas Capens

Use gtest for testing Subzero.

Change-Id: If2a5c51991bd60e1b6545799cd50f9520c85f21e Reviewed-on: https://swiftshader-review.googlesource.com/7570Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 4012582e
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "Reactor.hpp" #include "Reactor.hpp"
#include <cassert> #include "gtest/gtest.h"
using namespace sw; using namespace sw;
...@@ -29,11 +29,11 @@ int reference(int *p, int y) ...@@ -29,11 +29,11 @@ int reference(int *p, int y)
} }
int sum = x + y + z; int sum = x + y + z;
return sum; return sum;
} }
int main() TEST(SubzeroReactorSample, SubzeroReactor)
{ {
Routine *routine = nullptr; Routine *routine = nullptr;
...@@ -66,11 +66,15 @@ int main() ...@@ -66,11 +66,15 @@ int main()
int (*callable)(int*, int) = (int(*)(int*,int))routine->getEntry(); int (*callable)(int*, int) = (int(*)(int*,int))routine->getEntry();
int one[2] = {1, 0}; int one[2] = {1, 0};
int result = callable(&one[1], 2); int result = callable(&one[1], 2);
assert(result == reference(&one[1], 2)); EXPECT_EQ(result, reference(&one[1], 2));
} }
} }
delete routine; delete routine;
}
return 0; int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} }
// These are not the headers you're looking for
#error "Missing googletest submodule. Run git submodule update --init"
\ No newline at end of file
...@@ -93,6 +93,8 @@ ...@@ -93,6 +93,8 @@
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;SubmoduleCheck;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>gtest/gtest.h</ForcedIncludeFiles>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
...@@ -107,6 +109,8 @@ ...@@ -107,6 +109,8 @@
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;SubmoduleCheck;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>gtest/gtest.h</ForcedIncludeFiles>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
...@@ -123,6 +127,8 @@ ...@@ -123,6 +127,8 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;SubmoduleCheck;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>gtest/gtest.h</ForcedIncludeFiles>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
...@@ -141,6 +147,8 @@ ...@@ -141,6 +147,8 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;SubmoduleCheck;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>gtest/gtest.h</ForcedIncludeFiles>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
...@@ -158,6 +166,7 @@ ...@@ -158,6 +166,7 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\third_party\googletest\googletest\src\gtest-all.cc" />
<ClCompile Include="Main.cpp" /> <ClCompile Include="Main.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
...@@ -18,5 +18,8 @@ ...@@ -18,5 +18,8 @@
<ClCompile Include="Main.cpp"> <ClCompile Include="Main.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\third_party\googletest\googletest\src\gtest-all.cc">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
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