Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
51003174
Commit
51003174
authored
Jun 18, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ported platform tests, added AssertPass and AssertFail
parent
c2022fc6
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
747 additions
and
5 deletions
+747
-5
Makefile.am
test/test-automation/Makefile.am
+3
-2
SDL_test.c
test/test-automation/SDL_test.c
+34
-2
configure.ac
test/test-automation/configure.ac
+2
-1
Makefile.am
test/test-automation/testplatform/Makefile.am
+9
-0
Makefile.in
test/test-automation/testplatform/Makefile.in
+533
-0
testplatform.c
test/test-automation/testplatform/testplatform.c
+166
-0
No files found.
test/test-automation/Makefile.am
View file @
51003174
ACLOCAL_AMFLAGS
=
-I
acinclude
-I
build-scripts
SUBDIRS
=
testdummy testrect
SUBDIRS
=
testdummy testrect
testplatform
bin_PROGRAMS
=
runner
runner_SOURCES
=
runner.c SDL_test.c
...
...
@@ -14,8 +14,9 @@ install-tests:
-
cp
-f
testdummy/.libs/
*
.so tests/ 2> /dev/null
-
cp
-f
testrect/.libs/
*
.dylib tests/ 2> /dev/null
-
cp
-f
testrect/.libs/
*
.so tests/ 2> /dev/null
-
cp
-f
testplatform/.libs/
*
.dylib tests/ 2> /dev/null
-
cp
-f
testplatform/.libs/
*
.so tests/ 2> /dev/null
distclean-local
:
-
rm
-Rf
tests/ docs/
test/test-automation/SDL_test.c
View file @
51003174
...
...
@@ -66,10 +66,11 @@ AssertEquals(Uint32 expected, Uint32 actual, char* message, ...)
va_start
(
args
,
message
);
SDL_vsnprintf
(
buf
,
sizeof
(
buf
),
message
,
args
);
va_end
(
args
);
printf
(
"Assert
Equals failed: expected %d, got %d; %s
\n
"
,
expected
,
actual
,
buf
);
printf
(
"AssertEquals failed: expected %d, got %d; %s
\n
"
,
expected
,
actual
,
buf
);
_testReturnValue
=
1
;
_testAssertsFailed
++
;
}
else
{
printf
(
"AssertEquals passed
\n
"
);
_testAssertsPassed
++
;
}
}
...
...
@@ -85,12 +86,43 @@ AssertTrue(int condition, char *message, ...)
SDL_vsnprintf
(
buf
,
sizeof
(
buf
),
message
,
args
);
va_end
(
args
);
printf
(
"Assert
Is
True failed: %s
\n
"
,
buf
);
printf
(
"AssertTrue failed: %s
\n
"
,
buf
);
_testReturnValue
=
1
;
_testAssertsFailed
++
;
}
else
{
printf
(
"AssertTrue passed
\n
"
);
_testAssertsPassed
++
;
}
}
void
AssertPass
(
char
*
message
,
...)
{
va_list
args
;
char
buf
[
256
];
va_start
(
args
,
message
);
SDL_vsnprintf
(
buf
,
sizeof
(
buf
),
message
,
args
);
va_end
(
args
);
printf
(
"AssertPass: %s
\n
"
,
buf
);
_testAssertsPassed
++
;
}
void
AssertFail
(
char
*
message
,
...)
{
va_list
args
;
char
buf
[
256
];
va_start
(
args
,
message
);
SDL_vsnprintf
(
buf
,
sizeof
(
buf
),
message
,
args
);
va_end
(
args
);
printf
(
"AssertFail: %s
\n
"
,
buf
);
_testAssertsFailed
++
;
}
#endif
test/test-automation/configure.ac
View file @
51003174
...
...
@@ -34,7 +34,8 @@ AC_FUNC_FORK
AC_CONFIG_FILES([Makefile
testdummy/Makefile
testrect/Makefile])
testrect/Makefile
testplatform/Makefile])
AC_OUTPUT
echo ""
...
...
test/test-automation/testplatform/Makefile.am
0 → 100644
View file @
51003174
lib_LTLIBRARIES
=
libtestplatform.la
libtestplatform_la_SOURCES
=
testplatform.c ../SDL_test.c
libtestplatform_la_CLAGS
=
-fPIC
-g
libtestplatform_la_LDFLAGS
=
`
sdl-config
--libs
`
distclean-local
:
-
rm
*
.dylib
-
rm
*
.so
test/test-automation/testplatform/Makefile.in
0 → 100644
View file @
51003174
This diff is collapsed.
Click to expand it.
test/test-automation/testplatform/testplatform.c
0 → 100644
View file @
51003174
/**
* Original code: automated SDL platform test written by Edgar Simo "bobbens"
*/
#include <stdio.h>
#include <SDL/SDL.h>
#include "../SDL_test.h"
/* Test cases */
static
const
TestCaseReference
test1
=
(
TestCaseReference
){
"platform_testTypes"
,
"description"
,
TEST_ENABLED
,
0
,
0
};
static
const
TestCaseReference
test2
=
(
TestCaseReference
){
"platform_testEndianessAndSwap"
,
"description"
,
TEST_ENABLED
,
0
,
0
};
static
const
TestCaseReference
test3
=
(
TestCaseReference
){
"platform_testGetFunctions"
,
"description"
,
TEST_ENABLED
,
0
,
0
};
static
const
TestCaseReference
test4
=
(
TestCaseReference
){
"platform_testHasFunctions"
,
"description"
,
TEST_ENABLED
,
0
,
0
};
/* Test suite */
extern
const
TestCaseReference
*
testSuite
[]
=
{
&
test1
,
&
test2
,
&
test3
,
&
test4
,
NULL
};
TestCaseReference
**
QueryTestSuite
()
{
return
(
TestCaseReference
**
)
testSuite
;
}
/**
* @brief Compare sizes of types.
*
* @note Watcom C flags these as Warning 201: "Unreachable code" if you just
* compare them directly, so we push it through a function to keep the
* compiler quiet. --ryan.
*/
static
int
_compareSizeOfType
(
size_t
sizeoftype
,
size_t
hardcodetype
)
{
return
sizeoftype
!=
hardcodetype
;
}
/**
* @brief Tests type sizes.
*/
int
platform_testTypes
(
void
*
arg
)
{
int
ret
;
ret
=
_compareSizeOfType
(
sizeof
(
Uint8
),
1
);
AssertTrue
(
ret
==
0
,
"sizeof(Uint8) = %lu instead of 1"
,
sizeof
(
Uint8
)
);
ret
=
_compareSizeOfType
(
sizeof
(
Uint16
),
2
);
AssertTrue
(
ret
==
0
,
"sizeof(Uint16) = %lu instead of 2"
,
sizeof
(
Uint16
)
);
ret
=
_compareSizeOfType
(
sizeof
(
Uint32
),
4
);
AssertTrue
(
ret
==
0
,
"sizeof(Uint32) = %lu instead of 4"
,
sizeof
(
Uint32
)
);
ret
=
_compareSizeOfType
(
sizeof
(
Uint64
),
8
);
AssertTrue
(
ret
==
0
,
"sizeof(Uint64) = %lu instead of 8"
,
sizeof
(
Uint64
)
);
}
/**
* @brief Tests platform endianness and SDL_SwapXY functions.
*/
int
platform_testEndianessAndSwap
(
void
*
arg
)
{
int
real_byteorder
;
Uint16
value
=
0x1234
;
Uint16
value16
=
0xCDAB
;
Uint16
swapped16
=
0xABCD
;
Uint32
value32
=
0xEFBEADDE
;
Uint32
swapped32
=
0xDEADBEEF
;
Uint64
value64
,
swapped64
;
value64
=
0xEFBEADDE
;
value64
<<=
32
;
value64
|=
0xCDAB3412
;
swapped64
=
0x1234ABCD
;
swapped64
<<=
32
;
swapped64
|=
0xDEADBEEF
;
if
((
*
((
char
*
)
&
value
)
>>
4
)
==
0x1
)
{
real_byteorder
=
SDL_BIG_ENDIAN
;
}
else
{
real_byteorder
=
SDL_LIL_ENDIAN
;
}
/* Test endianness. */
AssertTrue
(
real_byteorder
==
SDL_BYTEORDER
,
"Machine detected as %s endian but appears to be %s endian."
,
(
SDL_BYTEORDER
==
SDL_LIL_ENDIAN
)
?
"little"
:
"big"
,
(
real_byteorder
==
SDL_LIL_ENDIAN
)
?
"little"
:
"big"
);
/* Test 16 swap. */
AssertTrue
(
SDL_Swap16
(
value16
)
==
swapped16
,
"SDL_Swap16(): 16 bit swapped incorrectly: 0x%X => 0x%X"
,
value16
,
SDL_Swap16
(
value16
)
);
/* Test 32 swap. */
AssertTrue
(
SDL_Swap32
(
value32
)
==
swapped32
,
"SDL_Swap32(): 32 bit swapped incorrectly: 0x%X => 0x%X"
,
value32
,
SDL_Swap32
(
value32
)
);
/* Test 64 swap. */
AssertTrue
(
SDL_Swap64
(
value64
)
==
swapped64
,
#ifdef _MSC_VER
"SDL_Swap64(): 64 bit swapped incorrectly: 0x%I64X => 0x%I64X"
,
#else
"SDL_Swap64(): 64 bit swapped incorrectly: 0x%llX => 0x%llX"
,
#endif
value64
,
SDL_Swap64
(
value64
)
);
}
/*!
* \brief Tests SDL_GetXYZ() functions
*/
int
platform_testGetFunctions
(
void
*
arg
)
{
int
ret
;
ret
=
SDL_GetPlatform
();
AssertPass
(
"SDL_GetPlatform()"
);
ret
=
SDL_GetCPUCount
();
AssertPass
(
"SDL_GetCPUCount()"
);
}
/*!
* \brief Tests SDL_HasXYZ() functions
*/
int
platform_testHasFunctions
(
void
*
arg
)
{
int
ret
;
// TODO: independently determine and compare values as well
ret
=
SDL_HasRDTSC
();
AssertPass
(
"SDL_HasRDTSC()"
);
ret
=
SDL_HasAltiVec
();
AssertPass
(
"SDL_HasAltiVec()"
);
ret
=
SDL_HasMMX
();
AssertPass
(
"SDL_HasMMX()"
);
ret
=
SDL_Has3DNow
();
AssertPass
(
"SDL_Has3DNow()"
);
ret
=
SDL_HasSSE
();
AssertPass
(
"SDL_HasSSE()"
);
ret
=
SDL_HasSSE2
();
AssertPass
(
"SDL_HasSSE2()"
);
ret
=
SDL_HasSSE3
();
AssertPass
(
"SDL_HasSSE3()"
);
ret
=
SDL_HasSSE41
();
AssertPass
(
"SDL_HasSSE41()"
);
ret
=
SDL_HasSSE42
();
AssertPass
(
"SDL_HasSSE42()"
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment