OSDN Git Service

Add MSVC project for reproducing fuzzer testcases.
authorNicolas Capens <nicolas.capens@gmail.com>
Wed, 23 May 2018 03:26:59 +0000 (23:26 -0400)
committerNicolas Capens <nicolascapens@google.com>
Wed, 23 May 2018 15:50:03 +0000 (15:50 +0000)
Change-Id: Icdeb96a3044ddf215a59ab832703bb447d85c3ab
Reviewed-on: https://swiftshader-review.googlesource.com/18948
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
SwiftShader.sln
tests/fuzzers/VertexRoutineFuzzer.cpp
tests/fuzzers/VertexRoutineFuzzer.vcxproj [new file with mode: 0644]
tests/fuzzers/VertexRoutineFuzzer.vcxproj.filters [new file with mode: 0644]

index c216b78..b1786ed 100644 (file)
@@ -259,6 +259,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SubzeroLLVMDependencies", "
 EndProject\r
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittests", "tests\unittests\unittests.vcxproj", "{CF8EBC89-8762-49DC-9440-6C82B3499913}"\r
 EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VertexRoutineFuzzer", "tests\fuzzers\VertexRoutineFuzzer.vcxproj", "{FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {7B02CB19-4CDF-4F79-BC9B-7F3F6164A003} = {7B02CB19-4CDF-4F79-BC9B-7F3F6164A003}\r
+               {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}\r
+       EndProjectSection\r
+EndProject\r
 Global\r
        GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
                Debug|Win32 = Debug|Win32\r
@@ -782,6 +788,18 @@ Global
                {CF8EBC89-8762-49DC-9440-6C82B3499913}.Release|Win32.Build.0 = Release|Win32\r
                {CF8EBC89-8762-49DC-9440-6C82B3499913}.Release|x64.ActiveCfg = Release|x64\r
                {CF8EBC89-8762-49DC-9440-6C82B3499913}.Release|x64.Build.0 = Release|x64\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Debug|Win32.Build.0 = Debug|Win32\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Debug|x64.ActiveCfg = Debug|x64\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Debug|x64.Build.0 = Debug|x64\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Profile|Win32.ActiveCfg = Release|Win32\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Profile|Win32.Build.0 = Release|Win32\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Profile|x64.ActiveCfg = Release|x64\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Profile|x64.Build.0 = Release|x64\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Release|Win32.ActiveCfg = Release|Win32\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Release|Win32.Build.0 = Release|Win32\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Release|x64.ActiveCfg = Release|x64\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}.Release|x64.Build.0 = Release|x64\r
        EndGlobalSection\r
        GlobalSection(SolutionProperties) = preSolution\r
                HideSolutionNode = FALSE\r
@@ -825,6 +843,7 @@ Global
                {9088FC9E-9843-4E0D-85D0-1B657AFC480A} = {B7E24D8E-6BE9-4DEF-A8B9-6A6E60CA60E9}\r
                {4EC107AB-89E8-4A0B-8366-B3E81085AE07} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}\r
                {CF8EBC89-8762-49DC-9440-6C82B3499913} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}\r
+               {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}\r
        EndGlobalSection\r
        GlobalSection(ExtensibilityGlobals) = postSolution\r
                SolutionGuid = {4DF423D2-8425-48A7-9CEC-835C4C3CA957}\r
index 11ac1a4..8f005dc 100644 (file)
@@ -90,7 +90,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
                return 0;
        }
 
-       if (data[size -1] != 0)
+       if(data[size - 1] != 0)
        {
                return 0;
        }
@@ -211,3 +211,26 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
 
        return 0;
 }
+
+#if defined(FUZZER_STANDALONE_REPRODUCE)
+int main(int argc, char *argv[])
+{
+       FILE *file = fopen("clusterfuzz-testcase", "r");
+
+       fseek(file, 0L, SEEK_END);
+       long numbytes = ftell(file);
+       fseek(file, 0L, SEEK_SET);
+       uint8_t *buffer = (uint8_t*)calloc(numbytes, sizeof(uint8_t));
+       fread(buffer, sizeof(char), numbytes, file);
+       fclose(file);
+
+       while(true)
+       {
+               LLVMFuzzerTestOneInput(buffer, numbytes);
+       }
+
+       free(buffer);
+
+       return 0;
+}
+#endif
\ No newline at end of file
diff --git a/tests/fuzzers/VertexRoutineFuzzer.vcxproj b/tests/fuzzers/VertexRoutineFuzzer.vcxproj
new file mode 100644 (file)
index 0000000..255742f
--- /dev/null
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|x64">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|x64">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <VCProjectVersion>15.0</VCProjectVersion>\r
+    <ProjectGuid>{FBDCFF88-0CE1-43C3-B694-8F45946FAFE3}</ProjectGuid>\r
+    <RootNamespace>VertexRoutineFuzzer</RootNamespace>\r
+    <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v141</PlatformToolset>\r
+    <CharacterSet>NotSet</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>v141</PlatformToolset>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>NotSet</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v141</PlatformToolset>\r
+    <CharacterSet>NotSet</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>v141</PlatformToolset>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>NotSet</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="Shared">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup />\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <SDLCheck>true</SDLCheck>\r
+      <ConformanceMode>true</ConformanceMode>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)src;$(SolutionDir)src\OpenGL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+      <PreprocessorDefinitions>FUZZER_STANDALONE_REPRODUCE;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
+    </ClCompile>\r
+    <Link>\r
+      <AdditionalDependencies>WS2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <SDLCheck>true</SDLCheck>\r
+      <ConformanceMode>true</ConformanceMode>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)src;$(SolutionDir)src\OpenGL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+      <PreprocessorDefinitions>FUZZER_STANDALONE_REPRODUCE;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
+    </ClCompile>\r
+    <Link>\r
+      <AdditionalDependencies>WS2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <SDLCheck>true</SDLCheck>\r
+      <ConformanceMode>true</ConformanceMode>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)src;$(SolutionDir)src\OpenGL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+      <PreprocessorDefinitions>FUZZER_STANDALONE_REPRODUCE;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
+    </ClCompile>\r
+    <Link>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <AdditionalDependencies>WS2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <SDLCheck>true</SDLCheck>\r
+      <ConformanceMode>true</ConformanceMode>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)src;$(SolutionDir)src\OpenGL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+      <PreprocessorDefinitions>FUZZER_STANDALONE_REPRODUCE;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
+    </ClCompile>\r
+    <Link>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <AdditionalDependencies>WS2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\src\OpenGL\common\debug.cpp" />\r
+    <ClCompile Include="VertexRoutineFuzzer.cpp" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ProjectReference Include="..\..\src\OpenGL\compiler\Compiler.vcxproj">\r
+      <Project>{5b3a6db8-1e7e-40d7-92b9-da8aae619fad}</Project>\r
+    </ProjectReference>\r
+    <ProjectReference Include="..\..\src\SwiftShader\SwiftShader.vcxproj">\r
+      <Project>{7b02cb19-4cdf-4f79-bc9b-7f3f6164a003}</Project>\r
+    </ProjectReference>\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/tests/fuzzers/VertexRoutineFuzzer.vcxproj.filters b/tests/fuzzers/VertexRoutineFuzzer.vcxproj.filters
new file mode 100644 (file)
index 0000000..e3640f4
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup>\r
+    <Filter Include="Source Files">\r
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r
+    </Filter>\r
+    <Filter Include="Header Files">\r
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>\r
+    </Filter>\r
+    <Filter Include="Resource Files">\r
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\r
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\r
+    </Filter>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="VertexRoutineFuzzer.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\src\OpenGL\common\debug.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+  </ItemGroup>\r
+</Project>
\ No newline at end of file