diff --git a/VisualC/SDL_VS2010.sln b/VisualC/SDL_VS2010.sln
index 3906116ff..b9578fbe7 100644
--- a/VisualC/SDL_VS2010.sln
+++ b/VisualC/SDL_VS2010.sln
@@ -67,6 +67,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpower", "tests\testpowe
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLtest", "SDLtest\SDLtest_VS2010.vcxproj", "{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -160,6 +165,14 @@ Global
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.ActiveCfg = Release|Win32
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.Build.0 = Release|Win32
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.ActiveCfg = Release|Win32
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.Build.0 = Debug|Win32
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.ActiveCfg = Debug|x64
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.Build.0 = Debug|x64
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.ActiveCfg = Release|Win32
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.Build.0 = Release|Win32
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.ActiveCfg = Release|x64
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/VisualC/SDL_VS2012.sln b/VisualC/SDL_VS2012.sln
index 5ee92e3d1..62272dbea 100644
--- a/VisualC/SDL_VS2012.sln
+++ b/VisualC/SDL_VS2012.sln
@@ -7,7 +7,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLmain", "SDLmain\SDLmain_
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CE748C1F-3C21-4825-AA6A-F895A023F7E7}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "automated", "tests\automated\automated_VS2010.vcxproj", "{DDD710DB-EC7B-4CCB-BD75-535D401A2FE0}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "automated", "tests\automated\automated_VS2012.vcxproj", "{DDD710DB-EC7B-4CCB-BD75-535D401A2FE0}"
ProjectSection(ProjectDependencies) = postProject
{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
@@ -67,6 +67,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpower", "tests\testpowe
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLtest", "SDLtest\SDLtest_VS2012.vcxproj", "{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -160,6 +165,14 @@ Global
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.ActiveCfg = Release|Win32
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.Build.0 = Release|Win32
{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.ActiveCfg = Release|Win32
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.Build.0 = Debug|Win32
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.ActiveCfg = Debug|x64
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.Build.0 = Debug|x64
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.ActiveCfg = Release|Win32
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.Build.0 = Release|Win32
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.ActiveCfg = Release|x64
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/VisualC/SDLtest/SDLtest_VS2010.vcxproj b/VisualC/SDLtest/SDLtest_VS2010.vcxproj
new file mode 100644
index 000000000..a15240f83
--- /dev/null
+++ b/VisualC/SDLtest/SDLtest_VS2010.vcxproj
@@ -0,0 +1,177 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ SDLtest
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}
+
+
+
+ StaticLibrary
+ false
+
+
+ StaticLibrary
+ false
+
+
+ StaticLibrary
+ false
+ MultiByte
+
+
+ StaticLibrary
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.30319.1
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+
+
+
+
+ OnlyExplicitInline
+ ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)
+ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ true
+ MultiThreadedDLL
+ true
+
+
+ Level3
+ true
+ Default
+
+
+ true
+
+
+
+
+ X64
+
+
+ OnlyExplicitInline
+ ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)
+ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ true
+ MultiThreadedDLL
+ true
+
+
+ Level3
+ true
+ Default
+
+
+ true
+
+
+
+
+
+ Disabled
+ ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)
+ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ MultiThreadedDebugDLL
+
+
+ Level3
+ true
+ OldStyle
+ Default
+
+
+ true
+
+
+
+
+ X64
+
+
+ Disabled
+ ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)
+ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ MultiThreadedDebugDLL
+
+
+ .\Debug/SDLtest.pch
+ Level3
+ true
+ OldStyle
+ Default
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualC/SDLtest/SDLtest_VS2012.vcxproj b/VisualC/SDLtest/SDLtest_VS2012.vcxproj
new file mode 100644
index 000000000..9c58947b0
--- /dev/null
+++ b/VisualC/SDLtest/SDLtest_VS2012.vcxproj
@@ -0,0 +1,181 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ SDLtest
+ {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}
+
+
+
+ StaticLibrary
+ false
+ v110
+
+
+ StaticLibrary
+ false
+ v110
+
+
+ StaticLibrary
+ false
+ MultiByte
+ v110
+
+
+ StaticLibrary
+ false
+ v110
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.30319.1
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+
+
+
+
+ OnlyExplicitInline
+ ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)
+ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ true
+ MultiThreadedDLL
+ true
+
+
+ Level3
+ true
+ Default
+
+
+ true
+
+
+
+
+ X64
+
+
+ OnlyExplicitInline
+ ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)
+ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ true
+ MultiThreadedDLL
+ true
+
+
+ Level3
+ true
+ Default
+
+
+ true
+
+
+
+
+
+ Disabled
+ ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)
+ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ MultiThreadedDebugDLL
+
+
+ Level3
+ true
+ OldStyle
+ Default
+
+
+ true
+
+
+
+
+ X64
+
+
+ Disabled
+ ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)
+ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ MultiThreadedDebugDLL
+
+
+ .\Debug/SDLtest.pch
+ Level3
+ true
+ OldStyle
+ Default
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/include/SDL_test_assert.h b/include/SDL_test_assert.h
index d1533916f..f0e1e6d22 100644
--- a/include/SDL_test_assert.h
+++ b/include/SDL_test_assert.h
@@ -44,6 +44,16 @@ extern "C" {
/* *INDENT-ON* */
#endif
+/**
+ * \brief Fails the assert.
+ */
+#define ASSERT_FAIL 0
+
+/**
+ * \brief Passes the assert.
+ */
+#define ASSERT_PASS 1
+
/**
* \brief Assert that logs and break execution flow on failures.
*
@@ -57,8 +67,10 @@ void SDLTest_Assert(int assertCondition, char *assertDescription);
*
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
* \param assertDescription Message to log with the assert describing it.
+ *
+ * \returns Returns the assertCondition so it can be used to externall to break execution flow if desired.
*/
-void SDLTest_AssertCheck(int assertCondition, char *assertDescription);
+int SDLTest_AssertCheck(int assertCondition, char *assertDescription);
/**
* \brief Resets the assert summary counters to zero.
diff --git a/src/joystick/darwin/SDL_sysjoystick.c b/src/joystick/darwin/SDL_sysjoystick.c
index b0f0a9837..d9fefcca7 100644
--- a/src/joystick/darwin/SDL_sysjoystick.c
+++ b/src/joystick/darwin/SDL_sysjoystick.c
@@ -920,7 +920,6 @@ SDL_bool
SDL_SYS_JoystickAttached(SDL_Joystick * joystick)
{
recDevice *device = gpDeviceList;
- int index;
while ( device )
{
diff --git a/src/test/SDL_test_assert.c b/src/test/SDL_test_assert.c
index 698c9115a..1123ccded 100644
--- a/src/test/SDL_test_assert.c
+++ b/src/test/SDL_test_assert.c
@@ -30,10 +30,10 @@
#include "SDL_test.h"
/*! \brief counts the failed asserts */
-static Uint32 SDLTest_testAssertsFailed = 0;
+static Uint32 SDLTest_AssertsFailed = 0;
/*! \brief counts the passed asserts */
-static Uint32 SDLTest_testAssertsPassed = 0;
+static Uint32 SDLTest_AssertsPassed = 0;
/* Assert check message format */
const char *SDLTest_AssertCheckFmt = "Assert %s: %s";
@@ -46,26 +46,27 @@ const char *SDLTest_AssertSummaryFmt = "Assert Summary: Total=%d Passed=%d Faile
*/
void SDLTest_Assert(int assertCondition, char *assertDescription)
{
- SDLTest_AssertCheck(assertCondition, assertDescription);
- SDL_assert((assertCondition));
+ SDL_assert((SDLTest_AssertCheck(assertCondition, assertDescription)));
}
/*
* Assert that logs but does not break execution flow on failures (i.e. for test cases).
*/
-void SDLTest_AssertCheck(int assertCondition, char *assertDescription)
+int SDLTest_AssertCheck(int assertCondition, char *assertDescription)
{
char *fmt = (char *)SDLTest_AssertCheckFmt;
- if (assertCondition)
+ if (assertCondition == ASSERT_FAIL)
{
- SDLTest_testAssertsPassed++;
- SDLTest_Log(fmt, "Passed", assertDescription);
+ SDLTest_AssertsFailed++;
+ SDLTest_LogError(fmt, "Failed", assertDescription);
}
else
{
- SDLTest_testAssertsFailed++;
- SDLTest_LogError(fmt, "Failed", assertDescription);
+ SDLTest_AssertsPassed++;
+ SDLTest_Log(fmt, "Passed", assertDescription);
}
+
+ return assertCondition;
}
/*
@@ -73,8 +74,8 @@ void SDLTest_AssertCheck(int assertCondition, char *assertDescription)
*/
void SDLTest_ResetAssertSummary()
{
- SDLTest_testAssertsPassed = 0;
- SDLTest_testAssertsFailed = 0;
+ SDLTest_AssertsPassed = 0;
+ SDLTest_AssertsFailed = 0;
}
/*
@@ -84,13 +85,13 @@ void SDLTest_ResetAssertSummary()
void SDLTest_LogAssertSummary()
{
char *fmt = (char *)SDLTest_AssertSummaryFmt;
- Uint32 totalAsserts = SDLTest_testAssertsPassed + SDLTest_testAssertsFailed;
- if (SDLTest_testAssertsFailed == 0)
+ Uint32 totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed;
+ if (SDLTest_AssertsFailed == 0)
{
- SDLTest_Log(fmt, totalAsserts, SDLTest_testAssertsPassed, SDLTest_testAssertsFailed);
+ SDLTest_Log(fmt, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
}
else
{
- SDLTest_LogError(fmt, totalAsserts, SDLTest_testAssertsPassed, SDLTest_testAssertsFailed);
+ SDLTest_LogError(fmt, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
}
}
diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c
index c52e4cc69..8140aae43 100644
--- a/src/test/SDL_test_harness.c
+++ b/src/test/SDL_test_harness.c
@@ -23,7 +23,10 @@
#include "SDL_test.h"
-// TODO: port over harness
+#include
+#include
+
+// TODO: port over remaining harness
/**
* Generates a random run seed string for the harness. The generated seed
@@ -140,3 +143,48 @@ SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iter
return keys[0];
}
+
+/**
+ * \brief Set timeout handler for test.
+ *
+ * Note: SDL_Init(SDL_INIT_TIMER) will be called if it wasn't done so before.
+ *
+ * \param timeout Timeout interval in seconds.
+ * \param callback Function that will be called after timeout has elapsed.
+ *
+ * \return Timer id or -1 on failure.
+ */
+SDL_TimerID
+SetTestTimeout(int timeout, void (*callback)())
+{
+ Uint32 timeoutInMilliseconds;
+ SDL_TimerID timerID;
+
+ if (callback == NULL) {
+ SDLTest_LogError("Timeout callback can't be NULL");
+ return -1;
+ }
+
+ if (timeout < 0) {
+ SDLTest_LogError("Timeout value must be bigger than zero.");
+ return -1;
+ }
+
+ /* Init SDL timer if not initialized before */
+ if (SDL_WasInit(SDL_INIT_TIMER) == 0) {
+ if (SDL_InitSubSystem(SDL_INIT_TIMER)) {
+ SDLTest_LogError("Failed to init timer subsystem: %s", SDL_GetError());
+ return -1;
+ }
+ }
+
+ /* Set timer */
+ timeoutInMilliseconds = timeout * 1000;
+ timerID = SDL_AddTimer(timeoutInMilliseconds, (SDL_TimerCallback)callback, 0x0);
+ if (timerID == 0) {
+ SDLTest_LogError("Creation of SDL timer failed: %s", SDL_GetError());
+ return -1;
+ }
+
+ return timerID;
+}
diff --git a/src/test/SDL_test_log.c b/src/test/SDL_test_log.c
index ca387d577..5c7ca731b 100644
--- a/src/test/SDL_test_log.c
+++ b/src/test/SDL_test_log.c
@@ -25,6 +25,9 @@
*/
+// quiet windows compiler warnings
+#define _CRT_SECURE_NO_WARNINGS
+
#include "SDL_config.h"
#include /* va_list */
diff --git a/src/test/SDL_test_random.c b/src/test/SDL_test_random.c
index 4f85199be..01fa413f2 100644
--- a/src/test/SDL_test_random.c
+++ b/src/test/SDL_test_random.c
@@ -30,6 +30,8 @@
#include "SDL_config.h"
+#include
+#include
#include
#include "SDL_test.h"